Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve doc for toBoundedInteger #95

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/Data/Scientific/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -764,10 +764,14 @@ toBoundedRealFloat s@(Scientific c e)

-- | Convert a `Scientific` to a bounded integer.
--
-- If the given `Scientific` is not an integer or doesn't fit in the
-- target representation, it will return `Nothing`.
-- Returns `Nothing` iff either:
--
-- This function also guards against computing huge Integer magnitudes (@10^e@)
-- * The given Scientific does not fit in the target representation (via the `Bounded` constraint)
-- * The given Scientific is not an integer but a float.
--
-- If you need to distinguish between the cases, you can first use `isFloating`.
--
-- __Safe__: This function guards against computing huge Integer magnitudes (@10^e@)
-- that could fill up all space and crash your program.
toBoundedInteger :: forall i. (Integral i, Bounded i) => Scientific -> Maybe i
toBoundedInteger s@(Scientific c e)
Expand Down