In Frege how can I convert an String safely to a Maybe Int?

96 Views Asked by At

In Frege I want to convert an String to an Int, but need to handle unparsable strings too.

So I guess I'm looking for something like a readMaybe function. Where do I find this? Or how can I use Java's parseInt and catch the exception in Frege?

1

There are 1 best solutions below

0
mb21 On BEST ANSWER

In Frege, it's as simple as:

myStr.double

which returns an Either.

(Found this in the Frege Translation of "Learn You a Haskell for Great Good!.")