edit: A monad for rewriting things.

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain]

Edit is a monad for rewriting things.


[Skip to ReadMe]

Properties

Versions0.0.1.0, 0.0.1.1, 0.0.1.1, 1.0.0.0, 1.0.1.0
Change logChangeLog.md
Dependenciesbase (>=4.9 && <4.12), deepseq (>=1.1 && <1.5), transformers (==0.5.*) [details]
LicenseBSD-3-Clause
CopyrightVarun Gandhi 2018
AuthorVarun Gandhi <theindigamer15@gmail.com>
MaintainerVarun Gandhi <theindigamer15@gmail.com>
CategoryData
Home pagehttps://github.com/theindigamer/edit
Source repositoryhead: git clone https://github.com/theindigamer/edit.git
UploadedMon May 28 16:51:20 UTC 2018 by theindigamer

Modules

[Index]

Flags

NameDescriptionDefaultType
arbitrary_instance

Adds QuickCheck as a dependency to provide an Arbitrary instance.

DisabledManual
comonad_instance

Adds comonad as a dependency to provide a Comonad instance.

DisabledManual
tutorial

Build the tutorial. Adds dependencies on uniplate and containers.

DisabledManual

Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info

Downloads

Maintainers' corner

For package maintainers and hackage trustees


Readme for edit-0.0.1.1

[back to package description]

Edit Hackage 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 and want to bubble up information whether something was changed or not.

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.