| Safe Haskell | Safe |
|---|---|
| Language | Haskell2010 |
Text.LambdaOptions.Parseable
Documentation
class Parseable a where Source #
Class describing parseable values. Much like the Read class.
Minimal complete definition
Methods
Instances
| Parseable Char Source # | Parses a single character string. |
| Parseable Float Source # | |
| Parseable Int Source # | Parses an |
| Parseable Integer Source # | |
| Parseable Word Source # | Parses a |
| Parseable () Source # | Always succeeds and never consumes any input. |
| Parseable String Source # | Identity parser. Ex: @parse "abc" == (Just "abc", 1) |
| Parseable a => Parseable (Maybe a) Source # | Greedily parses a single argument or no argument. Never fails. |
| Parseable a => Parseable (List a) Source # | Greedily parses arguments item-wise. Never fails.
Example: |
| (Parseable a, Parseable b) => Parseable (a, b) Source # | |
| (Parseable a, Parseable b, Parseable c) => Parseable (a, b, c) Source # | |
repeatedParse :: Parseable a => Int -> [String] -> (Maybe [a], Int) Source #
Repeatedly applies parse the given number of times, accumulating the results.
Useful for implementing new parsers.
Example:
data Point = Point Float Float Float
instance Parseable Point where
parse strs = case repeatedParse 3 strs of
(Just [x,y,z], n) -> (Just (Point x y z), n)`
(Nothing, n) -> (Nothing, n)