We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ef12043 commit 312f296Copy full SHA for 312f296
src/Data/BigInt.purs
@@ -24,13 +24,15 @@ module Data.BigInt
24
, shr
25
, quot
26
, rem
27
+ , toInt
28
, toNumber
29
) where
30
31
import Prelude
32
33
import Data.Array.NonEmpty (NonEmptyArray)
34
import Data.Int (floor)
35
+import Data.Int as Int
36
import Data.Maybe (Maybe(..), fromJust)
37
import Data.String.NonEmpty (NonEmptyString)
38
import Data.String.NonEmpty as NES
@@ -56,6 +58,9 @@ foreign import fromBaseImpl
56
58
-- | Convert an integer to a BigInt.
57
59
foreign import fromInt :: Int -> BigInt
60
61
+toInt :: BigInt -> Maybe Int
62
+toInt = toNumber >>> Int.fromNumber
63
+
64
-- | FFI wrapper to parse a Number into a BigInt.
65
foreign import fromNumberImpl
66
:: forall a
0 commit comments