gdritter repos s-cargot / 6036b46
More haddocks for export HaskLike functions Getty Ritter 7 years ago
1 changed file(s) with 13 addition(s) and 6 deletion(s). Collapse all Expand all
2828
2929 {- $info
3030
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.
3738
3839 -}
3940
5556 instance IsString HaskLikeAtom where
5657 fromString = HSIdent . fromString
5758
59 -- | Parse a Haskell string literal as defined by the Haskell 2010
60 -- language specification.
5861 parseHaskellString :: Parser Text
5962 parseHaskellString = pack . catMaybes <$> between (char '"') (char '"') (many (val <|> esc))
6063 where val = Just <$> satisfy (\ c -> c /= '"' && c /= '\\' && c > '\026')
8588 "\STX\ETX\EOT\ENQ\ACK\BEL\DLE\DC1\DC2\DC3\DC4\NAK" ++
8689 "\SYN\ETB\CAN\SUB\ESC\DEL")
8790
91 -- | Parse a Haskell floating-point number as defined by the Haskell
92 -- 2010 language specification.
8893 parseHaskellFloat :: Parser Double
8994 parseHaskellFloat = do
9095 n <- decNumber
109114 power :: Num a => Parser (a -> a)
110115 power = negate <$ char '-' <|> id <$ char '+' <|> return id
111116
117 -- | Parse a Haskell integer literal as defined by the Haskell 2010
118 -- language specification.
112119 parseHaskellInt :: Parser Integer
113120 parseHaskellInt = do
114121 s <- power