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 infixl 4 #

Sequential application.

A few functors support an implementation of `<*>`

that is more
efficient than the default one.

(*>) :: Applicative f => forall a b. f a -> f b -> f b infixl 4 #

Sequence actions, discarding the value of the first argument.

(<*) :: Applicative f => forall a b. f a -> f b -> f a infixl 4 #

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`

`String`

`show`

:

`>>>`

Nothing`show <$> Nothing`

`>>>`

Just "3"`show <$> Just 3`

Convert from an

to an `Either`

`Int`

`Int`

`Either`

`Int`

`String`

using `show`

:

`>>>`

Left 17`show <$> Left 17`

`>>>`

Right "17"`show <$> Right 17`

Double each element of a list:

`>>>`

[2,4,6]`(*2) <$> [1,2,3]`

Apply `even`

to the second element of a pair:

`>>>`

(2,True)`even <$> (2,2)`

(<**>) :: Applicative f => f a -> f (a -> b) -> f b infixl 4 #

A variant of `<*>`

with the arguments reversed.

data UnbalancedError Source #