Control.Comonad.Trans.Discont.Memo

comonad-transformers-2.0.2: Comonad transformers

Portability | portable
Stability | provisional
Maintainer | Edward Kmett <ekmett@gmail.com>

Control.Comonad.Trans.Discont.Memo

Contents

- The `discontinuation` comonad
- The discontinuation comonad transformer

Description

`Discont` is the density comonad of a constant functor, just as `Cont` is a Codensity monad of a constant functor. (For the definition of Density and Codensity, see the non-Haskell 98 `adjunctions` package)

Note that while `Discont` and `Store` are isomorphic, `DiscontT` and `StoreT` are not.

Like the memoizing store comonad, version memoizes the result of applying the continuation to the current context.

Synopsis

- type Discont s = DiscontT s Identity
- discont :: (s -> a) -> s -> Discont s a
- runDiscont :: Discont s a -> (s -> a, s)
- data DiscontT s w a
- discontT :: (w s -> a) -> w s -> DiscontT s w a
- runDiscontT :: DiscontT s w a -> (w s -> a, w s)

# The `discontinuation` comonad

type Discont s = DiscontT s Identity

discont :: (s -> a) -> s -> Discont s a

# The discontinuation comonad transformer

runDiscont :: Discont s a -> (s -> a, s)

data DiscontT s w a

Instances

ComonadTrans (DiscontT s) |
Functor (DiscontT s w) |
(Typeable s, Typeable1 w) => Typeable1 (DiscontT s w) |
Comonad (DiscontT s w) |
Extend (DiscontT s w) |

discontT :: (w s -> a) -> w s -> DiscontT s w a

runDiscontT :: DiscontT s w a -> (w s -> a, w s)