Giter Club home page Giter Club logo

edit's Introduction

Edit Hackage badge Stackage badge

The Edit monad allows you to easily bubble up whether a change was made or not when rewriting things. Some cases where this can be handy:

  1. You are making a sequence of transformations on some type and want to keep track of whether any of them changed it or not.
  2. You are rewriting a recursive type (or a garden of mutually recursive types!) and want to bubble up information whether something was changed or not.

For example, Reddit user /u/p__bing says

[..] I work as an iOS developer and we have this same exact idea implemented, as a monad, in Swift, to make our UI updates faster (if a change goes through our model layer and comes out Clean, we don’t bother touching the UI).

A small example:

>>> halveEvens x = if x `mod` 2 == 0 then (Dirty $ x `div` 2) else (Clean x)
>>> traverse halveEvens [1, 2, 3]
Dirty [1,1,3]
>>> traverse halveEvens [1, 3, 5]
Clean [1,3,5]

More thorough documentation is available on Hackage under the Data.Edit module. There is a tutorial too under Data.Edit.Tutorial.

There is also a corresponding monad transformer EditT available under Control.Monad.Trans.EditT.

Contributing

Please open an issue on the Github issue tracker to discuss missing documentation, API changes etc.

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.