More haddocks for export HaskLike functions
Getty Ritter
7 years ago
28 | 28 | |
29 | 29 | {- $info |
30 | 30 | |
31 | This module is intended for simple, ad-hoc configuration or data formats | |
32 | that might not need their on rich structure but might benefit from a few | |
33 | various kinds of literals. The 'haskLikeParser' understands identifiers as | |
34 | defined by R5RS, as well as string, integer, and floating-point literals | |
35 | as defined by the Haskell spec. It does __not__ natively understand other | |
36 | data types, such as booleans, vectors, bitstrings. | |
31 | This module is intended for simple, ad-hoc configuration or data | |
32 | formats that might not need their on rich structure but might benefit | |
33 | from a few various kinds of literals. The 'haskLikeParser' understands | |
34 | identifiers as defined by R5RS, as well as string, integer, and | |
35 | floating-point literals as defined by the Haskell 2010 spec. It does | |
36 | __not__ natively understand other data types, such as booleans, | |
37 | vectors, bitstrings. | |
37 | 38 | |
38 | 39 | -} |
39 | 40 | |
55 | 56 | instance IsString HaskLikeAtom where |
56 | 57 | fromString = HSIdent . fromString |
57 | 58 | |
59 | -- | Parse a Haskell string literal as defined by the Haskell 2010 | |
60 | -- language specification. | |
58 | 61 | parseHaskellString :: Parser Text |
59 | 62 | parseHaskellString = pack . catMaybes <$> between (char '"') (char '"') (many (val <|> esc)) |
60 | 63 | where val = Just <$> satisfy (\ c -> c /= '"' && c /= '\\' && c > '\026') |
85 | 88 | "\STX\ETX\EOT\ENQ\ACK\BEL\DLE\DC1\DC2\DC3\DC4\NAK" ++ |
86 | 89 | "\SYN\ETB\CAN\SUB\ESC\DEL") |
87 | 90 | |
91 | -- | Parse a Haskell floating-point number as defined by the Haskell | |
92 | -- 2010 language specification. | |
88 | 93 | parseHaskellFloat :: Parser Double |
89 | 94 | parseHaskellFloat = do |
90 | 95 | n <- decNumber |
109 | 114 | power :: Num a => Parser (a -> a) |
110 | 115 | power = negate <$ char '-' <|> id <$ char '+' <|> return id |
111 | 116 | |
117 | -- | Parse a Haskell integer literal as defined by the Haskell 2010 | |
118 | -- language specification. | |
112 | 119 | parseHaskellInt :: Parser Integer |
113 | 120 | parseHaskellInt = do |
114 | 121 | s <- power |