| Maintainer | bastiaan.heeren@ou.nl |
|---|---|
| Stability | provisional |
| Portability | portable (depends on ghc) |
| Safe Haskell | Safe |
| Language | Haskell98 |
Ideas.Utils.Parsing
Description
Utility functions for parsing with Parsec library
- (<*>) :: Applicative f => forall a b. f (a -> b) -> f a -> f b
- (*>) :: Applicative f => forall a b. f a -> f b -> f b
- (<*) :: Applicative f => forall a b. f a -> f b -> f a
- (<$>) :: Functor f => (a -> b) -> f a -> f b
- (<$) :: Functor f => forall a b. a -> f b -> f a
- (<**>) :: Applicative f => f a -> f (a -> b) -> f b
- parseSimple :: Parser a -> String -> Either String a
- complete :: Parser a -> Parser a
- skip :: Parser a -> Parser ()
- (<..>) :: Char -> Char -> Parser Char
- ranges :: [(Char, Char)] -> Parser Char
- stopOn :: [String] -> Parser String
- naturalOrFloat :: Parser (Either Integer Double)
- float :: Parser Double
- data UnbalancedError
- balanced :: [(Char, Char)] -> String -> Maybe UnbalancedError
Documentation
(<*>) :: Applicative f => forall a b. f (a -> b) -> f a -> f b #
Sequential application.
(*>) :: Applicative f => forall a b. f a -> f b -> f b #
Sequence actions, discarding the value of the first argument.
(<*) :: Applicative f => forall a b. f a -> f b -> f a #
Sequence actions, discarding the value of the second argument.
(<$>) :: Functor f => (a -> b) -> f a -> f b infixl 4 #
An infix synonym for fmap.
The name of this operator is an allusion to $.
Note the similarities between their types:
($) :: (a -> b) -> a -> b (<$>) :: Functor f => (a -> b) -> f a -> f b
Whereas $ is function application, <$> is function
application lifted over a Functor.
Examples
Convert from a to a Maybe Int using Maybe Stringshow:
>>>show <$> NothingNothing>>>show <$> Just 3Just "3"
Convert from an to an Either Int IntEither IntString using show:
>>>show <$> Left 17Left 17>>>show <$> Right 17Right "17"
Double each element of a list:
>>>(*2) <$> [1,2,3][2,4,6]
Apply even to the second element of a pair:
>>>even <$> (2,2)(2,True)
(<**>) :: Applicative f => f a -> f (a -> b) -> f b infixl 4 #
A variant of <*> with the arguments reversed.
data UnbalancedError Source #
Instances