Skip to content

Commit

Permalink
core: Fix doc string of integerValue
Browse files Browse the repository at this point in the history
  • Loading branch information
wismill committed Jul 3, 2024
1 parent 0b3db85 commit 5ff20de
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions unicode-data/lib/Unicode/Char/Numeric.hs
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,16 @@ numericValue = V.numericValue
-- This is a special case of 'numericValue'.
--
-- __Warning:__ There is a risk of /integer overflow/ depending of the chosen
-- concrete return type. As of Unicode 15.0 the results range from 0 to 1e12.
--
-- >>> integerValue '\x5146' :: Maybe Int64 -- OK
-- Just 1000000000000
-- >>> integerValue '\x5146' :: Maybe Int32 -- Will overflow!
-- Just (-727379968)
-- concrete return type. As of Unicode 15.1 the results range from 0 to 1e16.
--
-- >>> minimum [v | v@Just{} <- integerValue <$> [minBound..]]
-- Just 0
-- >>> maximum (integerValue <$> [minBound..])
-- Just 10000000000000000
-- >>> integerValue '\x4EAC' :: Maybe Int64 -- OK
-- Just 10000000000000000
-- >>> integerValue '\x4EAC' :: Maybe Int32 -- Will overflow!
-- Just 1874919424
--
-- Therefore it is advised to use: @'integerValue' \@'Int64'@.
--
Expand Down

0 comments on commit 5ff20de

Please sign in to comment.