-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhydraulics.cabal
64 lines (59 loc) · 2.31 KB
/
hydraulics.cabal
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
name: hydraulics
version: 1.0.0
synopsis: Lift any pure function over any Applicative stack.
description:
This package contains a family of functions based on familiar 'Applicative',
'Functor', 'Traversable', and 'Foldable' methods but with the ability
to operate on stacks of arbitrary depth.
.
For example, 'liftAll' is like the 'liftA2' and 'liftA3' functions except that it can lift a
function through multiple layers of @Applicative@s instead of just one. Additionally,
it can lift a function of arbitrary arity, not just a 2 argument function like with 'liftA2'.
.
The term \"stack\" is used in this library's documentation to refer
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@, @Traversable@, or @Foldable@.
.
It's necessary to turn on <https://gitlab.haskell.org/ghc/ghc/wikis/type-application TypeApplications>
so that you can supply a type argument that tells the compiler about the stack you are operating on.
You specify the stack by giving it's type with @()@ as the embedded value. The @()@ should be at the level
in the stack at which your target value is embedded.
Here is an example GHCi session:
.
>>> :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.)
homepage: https://github.com/aaronallen8455/hydraulics#readme
license: BSD3
license-file: LICENSE
author: Aaron Allen
maintainer: [email protected]
copyright: 2020 Aaron Allen
category: Control, Utils
build-type: Simple
extra-source-files: README.md
cabal-version: >=1.10
library
hs-source-dirs: src
exposed-modules: Control.Lift
build-depends: base >= 4.7 && < 5
default-language: Haskell2010
source-repository head
type: git
location: https://github.com/aaronallen8455/hydraulics