Created
November 10, 2009 10:37
-
-
Save merbjedi/230792 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| p_term :: Parser Term | |
| p_term = t <* spaces | |
| where | |
| t = IntTerm <$> p_num (readSigned readDec) | |
| <|> FloatTerm <$> p_num (readSigned readFloat) | |
| <|> AtomTerm <$> p_atom | |
| <|> TupleTerm <$> p_tuple | |
| <|> BytelistTerm . C.pack <$> p_string | |
| <|> ListTerm <$> p_list | |
| <|> BinaryTerm . B.pack <$> p_binary |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Again, reading very naturally: a term is t possibly followed by some whitespace. (a <* b means roughly “run a, then b, but the value of the expression is the value of a”). t in turn can be either a p_num wrapped with an IntTerm, and so forth. (In this context, <|> can very roughly be thought of as “otherwise, try..” and <$> as “wrap the results of the argument to the right with the thing on the left”.) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment