Skip to content

ChrisPenner/update-monad

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Update Monad

The update monad is a generalized (and pretty abstract) monad which can be specialized to implement any of Reader, Writer, or State! Check out this paper for a description.

This repo implements both the update monad transformer (UpdateT) and an experiment called FreeUpdateT which forgoes the traditional requirement of using a monoid as the 'action' of the update monad by substituting a free monoid (i.e. [action]). It also defers the choice of an act :: action -> state -> state function until the last second when the monad is run (rather than using a typeclass); this conveniently allows you to substitute out the act function for testing or alternate behaviour without needing to rewrite or transform the monadic values themselves. Nifty!

Yes; I know I could implement Update in terms of UpdateT Identity; but implementing them separately is clearer for people learning how it works.

About

An implementation of the Update Monad and a 'Free' version from https://danelahman.github.io/papers/types13postproc.pdf

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published