]> git.rmz.io Git - my-scheme.git/commit
Parse Numbers
authorSamir Benmendil <me@rmz.io>
Sun, 14 Jan 2018 00:41:31 +0000 (00:41 +0000)
committerSamir Benmendil <me@rmz.io>
Sun, 14 Jan 2018 00:41:31 +0000 (00:41 +0000)
commit7495ece1a44cd1a8cccae2bdbc61fa6873f106d2
treeced84a1aeae850f016a4468fa359594cb145277f
parent081ba0cc6439a82a508100a59d6fa5dba80609d9
Parse Numbers

`many1 digit` matches one or more digits. But it's result is actually a
`Parser String`. We need a way to operate on the value inside the `Parser
String` monad. This is where `liftM` comes in.

Another new thing here is the `.` operator which applies the function on
the right to any input of the function on the left. Or in other words it
applies the right function and passes the result to the function on the
left. In this case, `read` is applied to the parsed digits and the
result (of type Integer) is passed to the `Number` constructor of
`LispVal`.
app/Main.hs