Stability | experimental |
---|---|

Maintainer | Sebastian Fischer <mailto:sebf@informatik.uni-kiel.de> |

This library provides an interface to monads that support explicit sharing. A project website with tutorials can be found at http://sebfisch.github.com/explicit-sharing.

- module Control.Monad
- class Sharing m where
- class Shareable m a where
- class Convertible m a b where
- convert :: a -> m b

- data Lazy m a
- evalLazy :: (Monad m, Convertible (Lazy m) a b) => Lazy m a -> m b
- runSharing :: MonadPlus m => (forall s. (MonadPlus s, Sharing s) => s a) -> m a

# Documentation

module Control.Monad

# Classes

Interface of monads that support explicit sharing.

class Shareable m a whereSource

Interface of shareable nested monadic data types. The provided
function `shareArgs`

is supposed to map the given function on every
monadic argument.

We provide instances of the `Shareable`

class for some predefined
Haskell types. For flat types the function `shareArgs`

just returns
its argument which has no arguments to which the given function
could be applied.

class Convertible m a b whereSource

Interface for convertible datatypes. The provided function
`convArgs`

is supposed to map the given function on every argument
of the given value and combine the results to give the converted
value.

We provide instances of the `Convertible`

class for some predefined
Haskell types. For flat types the function `convArgs`

just returns
its argument which has no arguments to which the given function
could be applied.

Monad m => Convertible m Char Char | |

Monad m => Convertible m Double Double | |

Monad m => Convertible m Float Float | |

Monad m => Convertible m Integer Integer | |

Monad m => Convertible m Int Int | |

Monad m => Convertible m Bool Bool | |

(Monad m, Convertible m a b) => Convertible m [m a] [b] | An instance to convert lists with monadic elements into ordinary lists. |

(Monad m, Convertible m a b) => Convertible m [a] [m b] | An instance to convert ordinary lists into lists with monadic elements. |

Monad m => Convertible m [Char] [Char] | |

Monad m => Convertible m [Double] [Double] | |

Monad m => Convertible m [Float] [Float] | |

Monad m => Convertible m [Integer] [Integer] | |

Monad m => Convertible m [Int] [Int] | |

Monad m => Convertible m [Bool] [Bool] | |

(Monad m, Convertible m a b) => Convertible m [a] (List m b) | This instance enables the function |

(Monad m, Convertible m a b) => Convertible m (List m a) [b] | This instance enables the function |

# Monad transformer

Continuation-based, store-passing implementation of explicit
sharing. It is an inlined version of `ContT (ReaderT Store m)`

where the result type of continuations is polymorphic.

evalLazy :: (Monad m, Convertible (Lazy m) a b) => Lazy m a -> m bSource

Lifts all monadic effects to the top-level and unwraps the monad transformer for explicit sharing.

runSharing :: MonadPlus m => (forall s. (MonadPlus s, Sharing s) => s a) -> m aSource