generic-lift: Lift any pure function over any Applicative stack.

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]

This package contains a family of functions based on familiar Applicative, Functor, Traversable, and Foldable methods with the special property that they operate on stacks of arbitrary depth.

For example, liftAll is like the liftA* functions except that it can lift a function through multiple layers of Applicatives instead of just one. Additionally, it can lift a function of arbitrary arity.

Usage of the term "stack" in this documentation refers to something like

Maybe [Either Bool [Int]]

where Int is embedded in a nesting of types that all share some common interface, such as Applicative.

You will want to have TypeApplications turned on so that you can supply a type argument that the compiler is not able to infer on it's own. This is the type of the stack with () as the embedded value. For example:

>>> :set -XTypeApplications
>>> liftAll @[Maybe [()]] (+) [Just [3 :: Int]] [Just [6, 7]]
[Just [9,10]]
>>> data Foo = Foo Int String Double deriving Show
>>> liftAll @[[()]] Foo [[2]] [["string"]] [[5]]
[[Foo 2 "string" 5.0]]
>>> fmapAll @[Maybe ()] length [Just "string"]
[Just 6]
>>> traverseAll @(Either String [()]) print (Right [1,2,3])
1
2
3
Right [(),(),()]

(Additional examples are in the haddocks.)


[Skip to ReadMe]

Properties

Version1.0.0
Change logNone available
Dependenciesbase (>=4.7 && <5) [details]
LicenseBSD-3-Clause
Copyright2019 Aaron Allen
AuthorAaron Allen
Maintaineraaronallen8455@gmail.com
CategoryControl, Utils
Home pagehttps://github.com/aaronallen8455/generic-lift#readme
Source repositoryhead: git clone https://github.com/aaronallen8455/generic-lift
UploadedSat Sep 14 05:47:39 UTC 2019 by aaronallen8455

Modules

[Index]

Downloads

Maintainers' corner

For package maintainers and hackage trustees


Readme for generic-lift-1.0.0

[back to package description]

generic-lift