initial commit

This commit is contained in:
Athan Clark 2018-08-31 16:47:41 -06:00
commit b4b63bf71d
6 changed files with 101 additions and 0 deletions

9
.gitignore vendored Normal file
View file

@ -0,0 +1,9 @@
/bower_components/
/node_modules/
/.pulp-cache/
/output/
/generated-docs/
/.psc-package/
/.psc*
/.purs*
/.psa*

23
bower.json Normal file
View file

@ -0,0 +1,23 @@
{
"name": "purescript-bignumber",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"output"
],
"license": "BSD-3-Clause",
"dependencies": {
"purescript-prelude": "^3.1.1",
"purescript-either": "^3.2.0",
"purescript-exceptions": "^3.0.0",
"purescript-record": "git@github.com:athanclark/purescript-record.git#850360dbfa1bf765a19b3ec207a706622fa47ac7"
},
"repository": {
"type": "git",
"url": "git://github.com/athanclark/purescript-bignumber.git"
},
"devDependencies": {
"purescript-psci-support": "^3.0.0"
}
}

14
package.json Normal file
View file

@ -0,0 +1,14 @@
{
"name": "purescript-bignumber",
"version": "1.0.0",
"description": "",
"main": "index.js",
"directories": {
"test": "test"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}

18
src/Data/BigNumber.js Normal file
View file

@ -0,0 +1,18 @@
"use strict";
var BigNumber = require('bignumber.js');
exports.parseBigNumber = function parseBigNumber (Left,Right,s) {
var x;
try {
x = new BigNumber(s);
} catch (e) {
return Left(e);
}
return x;
};
exports.configImpl = function configImpl (cfg) {
BigNumber.config(cfg);
};

28
src/Data/BigNumber.purs Normal file
View file

@ -0,0 +1,28 @@
module Data.BigNumber where
import Prelude
import Data.Either (Either)
import Data.Function.Uncurried (Fn3)
import Data.Record.Class (class Subrow)
import Control.Monad.Eff (Eff, kind Effect)
import Control.Monad.Eff.Exception (Error)
import Control.Monad.Eff.Uncurried (EffFn1, runEffFn1)
foreign import data BIGNUMBER :: Effect
foreign import data BigNumber :: Type
foreign import parseBigNumber :: Fn3 (forall e a. e -> Either e a) (forall e a. a -> Either e a) String (Either Error BigNumber)
foreign import configImpl :: forall o eff. EffFn1 (bigNumber :: BIGNUMBER | eff) o Unit
type ConfigParams =
( "DECIMAL_PLACES" :: Int
)
config :: forall o eff
. Subrow o ConfigParams
=> { | o } -> Eff (bigNumber :: BIGNUMBER | eff) Unit
config = runEffFn1 configImpl

9
test/Main.purs Normal file
View file

@ -0,0 +1,9 @@
module Test.Main where
import Prelude
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Console (CONSOLE, log)
main :: forall e. Eff (console :: CONSOLE | e) Unit
main = do
log "You should add some tests."