diff --git a/CONTRIBUTORS.markdown b/CONTRIBUTORS.markdown index 6590936dd..dbaf46456 100644 --- a/CONTRIBUTORS.markdown +++ b/CONTRIBUTORS.markdown @@ -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) diff --git a/parser-typechecker/src/Unison/Builtin.hs b/parser-typechecker/src/Unison/Builtin.hs index 5744dfb04..3d000af6d 100644 --- a/parser-typechecker/src/Unison/Builtin.hs +++ b/parser-typechecker/src/Unison/Builtin.hs @@ -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 diff --git a/parser-typechecker/src/Unison/Runtime/Rt1.hs b/parser-typechecker/src/Unison/Runtime/Rt1.hs index 05a0a5470..c3246d0a5 100644 --- a/parser-typechecker/src/Unison/Runtime/Rt1.hs +++ b/parser-typechecker/src/Unison/Runtime/Rt1.hs @@ -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 diff --git a/parser-typechecker/unison-parser-typechecker.cabal b/parser-typechecker/unison-parser-typechecker.cabal index 3755e12f1..e27276aef 100644 --- a/parser-typechecker/unison-parser-typechecker.cabal +++ b/parser-typechecker/unison-parser-typechecker.cabal @@ -185,7 +185,7 @@ library io-streams, lens, ListLike, - megaparsec, + megaparsec >= 5.0.0 && < 7.0.0, memory, mmorph, monad-loops,