Maintainer | bastiaan.heeren@ou.nl |
---|---|
Stability | provisional |
Portability | portable (depends on ghc) |
Safe Haskell | Safe |
Language | Haskell98 |
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
.
Examples
Convert from a
to a Maybe
Int
using Maybe
String
show
:
>>>
show <$> Nothing
Nothing>>>
show <$> Just 3
Just "3"
Convert from an
to an Either
Int
Int
Either
Int
String
using show
:
>>>
show <$> Left 17
Left 17>>>
show <$> Right 17
Right "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