Giter Club home page Giter Club logo

tardis's Introduction

TardisT

The State monad allows you to send information forwards to the future, or to receive such information from the past. The Reverse State monad allows you to do the reverse: send information backwards to the past, or receive information from the future.

TardisT is a monad transformer that provides state operations that allow you to send information to both the future and the past, as well as receive information from both directions. It is isomorphic to a StateT on top of a ReverseStateT, or vice-versa.

See Control/Monad/Tardis/Example.hs for an example.


You can decide how evil you would like this library to be. By default, it will not include typeclass instances that require "scary" language extensions.

cabal install tardis

You can instead install it with the additional instances by indicating that it is OK:

cabal install -f use-undecidable-instances

You can tell whether you have the extra instances with this ghci session:

ghci> :m +Control.Monad.Tardis
ghci> :m +Control.Monad.Trans.Identity
ghci> :t IdentityT (return ()) >> getPast

If you don't have the additional instances, it will say the type is:

(Monad m, MonadTardis bw b (IdentityT m)) => IdentityT m b

If you do have the additional instances, it will say the type is:

MonadTardis bw b m => IdentityT m b

See Control/Monad/Tardis.hs for details.


This was inspired by Luke Palmer's blog post on the "reverse state monad".

http://lukepalmer.wordpress.com/2008/08/10/mindfuck-the-reverse-state-monad/

See also:

http://panicsonic.blogspot.com/2007/12/backwards-state-or-power-of-laziness.html


(c) 2012 Dan Burton

tardis's People

Contributors

danburton avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.