dun goofed
This commit is contained in:
parent
dc2b908841
commit
19a8737eac
5 changed files with 48 additions and 4 deletions
|
@ -13,6 +13,7 @@
|
|||
"purescript-exceptions": "^3.0.0",
|
||||
"purescript-tuples-native": "^0.1.0",
|
||||
"purescript-integers": "^3.2.0",
|
||||
"purescript-generics": "^4.0.0",
|
||||
"purescript-records": "git@github.com:athanclark/purescript-record.git#d553530acf2c56e0a12a0f3020997947e80db162"
|
||||
},
|
||||
"repository": {
|
||||
|
|
13
package-lock.json
generated
Normal file
13
package-lock.json
generated
Normal file
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"name": "purescript-bignumber",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"bignumber.js": {
|
||||
"version": "7.2.1",
|
||||
"resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-7.2.1.tgz",
|
||||
"integrity": "sha512-S4XzBk5sMB+Rcb/LNcpzXr57VRTxgAvaAEDAl1AwRx27j00hT84O6OkteE7u8UB3NuaaygCRrEpqox4uDOrbdQ=="
|
||||
}
|
||||
}
|
||||
}
|
15
package.json
15
package.json
|
@ -1,7 +1,6 @@
|
|||
{
|
||||
"name": "purescript-bignumber",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"directories": {
|
||||
"test": "test"
|
||||
|
@ -10,5 +9,17 @@
|
|||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
"license": "ISC",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/athanclark/purescript-bignumber.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/athanclark/purescript-bignumber/issues"
|
||||
},
|
||||
"homepage": "https://github.com/athanclark/purescript-bignumber#readme",
|
||||
"description": "",
|
||||
"dependencies": {
|
||||
"bignumber.js": "^7.2.1"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ exports.parseBigNumberImpl = function parseBigNumberImpl (Left,Right,s) {
|
|||
} catch (e) {
|
||||
return Left(e);
|
||||
}
|
||||
return x;
|
||||
return Right(x);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -13,13 +13,17 @@ module Data.BigNumber
|
|||
|
||||
import Prelude
|
||||
import Data.Int as Int
|
||||
import Data.Maybe (Maybe (..))
|
||||
import Data.Either (Either (..))
|
||||
import Data.Tuple (Tuple (..))
|
||||
import Data.Function.Uncurried (Fn3, runFn3, Fn2, runFn2, Fn5, runFn5)
|
||||
import Data.Record.Class (class Subrow)
|
||||
import Data.Tuple.Native (T2, prj)
|
||||
import Data.Typelevel.Num.Reps (d0, d1)
|
||||
-- import Data.Semiring (class Semiring)
|
||||
import Data.Generic
|
||||
(class Generic, toSpine, fromSpine, GenericSpine (SProd), GenericSignature (SigProd))
|
||||
import Data.Array as Array
|
||||
import Type.Proxy (Proxy (..))
|
||||
import Control.Monad.Eff (Eff, kind Effect)
|
||||
import Control.Monad.Eff.Exception (Error)
|
||||
import Control.Monad.Eff.Uncurried (EffFn1, runEffFn1)
|
||||
|
@ -30,6 +34,21 @@ foreign import data BIGNUMBER :: Effect
|
|||
|
||||
foreign import data BigNumber :: Type
|
||||
|
||||
instance genericBigNumber :: Generic BigNumber where
|
||||
toSpine x = SProd "Data.BigNumber.BigNumber" [\_ -> toSpine (toString x)]
|
||||
toSignature Proxy = SigProd "Data.BigNumber.BigNumber" []
|
||||
fromSpine s = case s of
|
||||
SProd tag xs
|
||||
| tag == "Data.BigNumber.BigNumber" -> case Array.head xs of
|
||||
Just f -> do
|
||||
n <- fromSpine (f unit)
|
||||
case parseBigNumber n of
|
||||
Left _ -> Nothing
|
||||
Right x -> pure x
|
||||
Nothing -> Nothing
|
||||
| otherwise -> Nothing
|
||||
_ -> Nothing
|
||||
|
||||
|
||||
foreign import parseBigNumberImpl :: Fn3 (forall e a. e -> Either e a) (forall e a. a -> Either e a) String (Either Error BigNumber)
|
||||
|
||||
|
|
Loading…
Reference in a new issue