Add Nat.fromText

This commit is contained in:
Mitchell Rosen 2019-08-10 15:38:18 -04:00
parent aafbe93915
commit 5f1e072868
4 changed files with 5 additions and 1 deletions

View File

@ -22,3 +22,4 @@ The format for this list: name, GitHub handle, and then optional blurb about wha
* Scott Christopher (@scott-christopher)
* Alex Zolotko (@azolotko)
* Ian Denhardt (@zenhack)
* Mitchell Rosen (@mitchellwrosen)

View File

@ -241,6 +241,7 @@ builtinsSrc =
, B "Nat.isOdd" $ nat --> boolean
, B "Nat.toInt" $ nat --> int
, B "Nat.toText" $ nat --> text
, B "Nat.fromText" $ text --> optional nat
, B "Float.+" $ float --> float --> float
, B "Float.-" $ float --> float --> float

View File

@ -331,6 +331,8 @@ builtinCompilationEnv = CompilationEnv (builtinsMap <> IR.builtins) mempty
, mk1 "Float.truncate" atf (pure . I) truncate
, mk1 "Nat.toText" atn (pure . T) (Text.pack . show)
, mk1 "Nat.fromText" att (pure . IR.maybeToOptional . fmap N) (
(\x -> readMaybe x :: Maybe Word64) . Text.unpack)
-- Float Utils
, mk1 "Float.abs" atf (pure . F) abs

View File

@ -185,7 +185,7 @@ library
io-streams,
lens,
ListLike,
megaparsec,
megaparsec >= 5.0.0 && < 7.0.0,
memory,
mmorph,
monad-loops,