-
Notifications
You must be signed in to change notification settings - Fork 1
/
idiomatic.cabal
93 lines (87 loc) · 2.76 KB
/
idiomatic.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: idiomatic
version: 0.1.1.0
synopsis: Deriving Applicative for sum types.. Idiomatically.
description:
'Idiomatically' is used with 'DerivingVia' to derive 'Applicative'
for types with multiple constructors.
.
The name comes from the original paper on 'Applicative's: <http://strictlypositive.org/Idiom.pdf Idioms: applicative programming with effects>.
.
It features an extensible domain-specific language of sums with
`Applicative` instances. `Idiomatically` is then passed a type-level
list of applicative sums that specify how deriving should take
place.
.
> {-# Language DataKinds #-}
> {-# Language DeriveGeneric #-}
> {-# Language DerivingStrategies #-}
> {-# Language DerivingVia #-}
>
> import Generic.Applicative
>
> data Zip a = No | a ::: Zip a
> deriving
> stock (Show, Generic1)
>
> deriving (Functor, Applicative)
> via Idiomatically Zip '[RightBias Terminal]
.
This derives the standard behaviour of `ZipList` but this same
"RightBias Terminal" behaviour describes the `Maybe` and
`Validation` applicative as well.
.
> pure @Zip a = a ::: a ::: a ::: ...
>
> liftA2 (+) No No = No
> liftA2 (+) No (⊥:::⊥) = No
> liftA2 (+) (⊥:::⊥) No = No
> liftA2 (+) (2:::No) (10:::No) = 12:::No
.
`Idiomatically` shares an intimate relationship with `Generically1`:
it is defined in terms of `Generically1` and they are
interchangeable when there is an empty list of sums:
.
> type Generically1 :: (k -> Type) -> (k -> Type)
> type Generically1 f = Idiomatically f '[]
.
Based on <http://ekmett.github.io/reader/2012/abstracting-with-applicatives/index.html Abstracting with Applicatives>.
homepage: https://github.com/Icelandjack/idiomatic
license: BSD3
license-file: LICENSE
author: Baldur Blöndal
maintainer: Baldur Blöndal
category: Generics
build-type: Simple
extra-source-files:
ChangeLog.md
README.md
cabal-version: >=1.10
source-repository head
type: git
location: https://github.com/Icelandjack/idiomatic
library
exposed-modules:
Generic.Applicative
Generic.Applicative.Internal
Generic.Applicative.Idiom
build-depends: base == 4.*
hs-source-dirs: src
default-language: Haskell98
ghc-options: -Wall
flag examples
description: Enable examples
default: False
manual: True
-- cabal configure -f examples
-- cabal run ZipList-example
executable ZipList-example
main-is: ZipList.hs
hs-source-dirs: examples
default-language: Haskell98
build-depends:
base == 4.*,
idiomatic
if flag(examples)
buildable: True
else
buildable: False