free-5.1.3: Monads for free

Copyright | (C) 2012 Edward Kmett
License | BSD-style (see the file LICENSE)
Maintainer | Edward Kmett <ekmett@gmail.com>
Stability | provisional
Portability | GADTs, Rank2Types
Safe Haskell | Safe
Language | Haskell2010

Control.Alternative.Free.Final

Description

Final encoding of free `Alternative` functors.

Synopsis

- newtype Alt f a = Alt {
  - _runAlt :: forall g. Alternative g => (forall x. f x -> g x) -> g a
  }
- runAlt :: forall f g a. Alternative g => (forall x. f x -> g x) -> Alt f a -> g a
- liftAlt :: f a -> Alt f a
- hoistAlt :: (forall a. f a -> g a) -> Alt f b -> Alt g b

# Documentation

newtype Alt f a Source #

The free `Alternative` for any `f`.

Constructors

Alt |

Fields

- _runAlt :: forall g. Alternative g => (forall x. f x -> g x) -> g a

#### Instances

Instances details

Functor (Alt f) Source # |
Instance details Defined in Control.Alternative.Free.Final Methods fmap :: (a -> b) -> Alt f a -> Alt f b # (<$) :: a -> Alt f b -> Alt f a #
Applicative (Alt f) Source # |
Instance details Defined in Control.Alternative.Free.Final Methods pure :: a -> Alt f a (<*>) :: Alt f (a -> b) -> Alt f a -> Alt f b liftA2 :: (a -> b -> c) -> Alt f a -> Alt f b -> Alt f c (*>) :: Alt f a -> Alt f b -> Alt f b (<*) :: Alt f a -> Alt f b -> Alt f a
Alternative (Alt f) Source # |
Instance details Defined in Control.Alternative.Free.Final Methods empty :: Alt f a (<|>) :: Alt f a -> Alt f a -> Alt f a some :: Alt f a -> Alt f [a] many :: Alt f a -> Alt f [a]
Alt (Alt f) Source # |
Instance details Defined in Control.Alternative.Free.Final Methods (<!>) :: Alt f a -> Alt f a -> Alt f a Source # some :: Applicative (Alt f) => Alt f a -> Alt f [a] Source # many :: Applicative (Alt f) => Alt f a -> Alt f [a] Source #
Apply (Alt f) Source # |
Instance details Defined in Control.Alternative.Free.Final Methods (<.>) :: Alt f (a -> b) -> Alt f a -> Alt f b Source # (.>) :: Alt f a -> Alt f b -> Alt f b Source # (<.) :: Alt f a -> Alt f b -> Alt f a Source # liftF2 :: (a -> b -> c) -> Alt f a -> Alt f b -> Alt f c Source #
Semigroup (Alt f a) Source # |
Instance details Defined in Control.Alternative.Free.Final Methods (<>) :: Alt f a -> Alt f a -> Alt f a sconcat :: NonEmpty (Alt f a) -> Alt f a stimes :: Integral b => b -> Alt f a -> Alt f a
Monoid (Alt f a) Source # |
Instance details Defined in Control.Alternative.Free.Final Methods mempty :: Alt f a mappend :: Alt f a -> Alt f a -> Alt f a mconcat :: [Alt f a] -> Alt f a

runAlt :: forall f g a. Alternative g => (forall x. f x -> g x) -> Alt f a -> g a Source #

Given a natural transformation from `f` to `g`, this gives a canonical monoidal natural transformation from ``Alt` f` to `g`.

liftAlt :: f a -> Alt f a Source #

A version of `lift` that can be used with `f`.

hoistAlt :: (forall a. f a -> g a) -> Alt f b -> Alt g b Source #

Given a natural transformation from `f` to `g` this gives a monoidal natural transformation from `Alt f` to `Alt g`.