-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathvalidation.cabal
More file actions
140 lines (121 loc) · 4.81 KB
/
validation.cabal
File metadata and controls
140 lines (121 loc) · 4.81 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
name: validation
version: 1.2.2
license: BSD3
license-file: LICENCE
author: Tony Morris <ʇǝu˙sıɹɹoɯʇ@ןןǝʞsɐɥ> <dibblego>, Nick Partridge <nkpart>
maintainer: Tony Morris <ʇǝu˙sıɹɹoɯʇ@ןןǝʞsɐɥ> <dibblego>, Nick Partridge <nkpart>
copyright: Copyright (C) 2010-2013 Tony Morris, Nick Partridge
Copyright (C) 2014,2015 NICTA Limited
Copyright (c) 2016-2019 Commonwealth Scientific and Industrial Research Organisation (CSIRO) ABN 41 687 119 230
Copyright (c) 2019-2026 Tony Morris
synopsis: A data-type like Either but with an accumulating Applicative
category: Data
description:
<<https://logo.systemf.com.au/systemf-450x450.png>>
.
A data type like @Either@ but with an accumulating @Applicative@ instance.
.
== @Validation@
.
The @Validation@ data type is isomorphic to @Either@, but has an instance
of @Applicative@ that accumulates on the error side. That is to say, if two
(or more) errors are encountered, they are appended using a @Semigroup@
operation.
.
As a consequence of this @Applicative@ instance, there is no corresponding
@Bind@ or @Monad@ instance. @Validation@ is an example of, "An applicative
functor that is not a monad."
.
The library provides:
.
* Classy optics (@GetValidation@, @HasValidation@, @ReviewValidation@,
@AsValidation@, and corresponding classes for @Failure@ and @Success@)
following the conventions of @makeClassy@ and @makeClassyPrisms@ from @lens@.
* Polymorphic prisms (@__Failure@, @__Success@) for type-changing operations.
* Isomorphisms to @Either@ and @(Bool, a)@.
.
== @Validator@
.
The @Validator@ newtype is a profunctor transformer:
.
@newtype Validator e p x a = Validator (p x (Validation e a))@
.
@Validator e (->) x a@ is isomorphic to @x -> Validation e a@. The profunctor
parameter @p@ generalises this to other optic-like contexts such as @Tagged@,
@Iso@, and @Prism@.
.
Instances include @Functor@, @Apply@, @Applicative@, @Alt@, @Selective@,
@Profunctor@, @Strong@, @Choice@, @Semigroupoid@, @Category@, @Arrow@,
@ArrowApply@, @ArrowChoice@, and @Wrapped@.
.
The @Applicative@ instance accumulates errors in parallel (using @Semigroup@),
while @Category@ composition short-circuits on @Failure@ (like monadic bind).
.
The library also provides profunctor newtype wrappers (@Iso''@, @Prism''@) that
allow @Validator@ to be parameterised over monomorphic isos and prisms.
homepage: https://github.com/system-f/validation
bug-reports: https://github.com/system-f/validation/issues
cabal-version: >= 1.10
build-type: Simple
extra-source-files: changelog
tested-with: GHC == 9.10.3, GHC == 9.8.4, GHC == 9.6.7, GHC==9.0.1, GHC==8.10.4, GHC==8.8.4, GHC==8.6.5, GHC==8.4.4
source-repository head
type: git
location: git@github.com:system-f/validation.git
library
default-language:
Haskell2010
build-depends:
base >= 4.11 && < 5
, assoc >= 1 && < 2
, deepseq >= 1.4.3 && < 2
, selective >= 0.6 && < 1
, semigroups >= 0.18.2 && < 1
, semigroupoids >= 5.2.2 && < 7
, bifunctors >= 5.5 && < 6
, lens >= 4.0.5 && < 6
, profunctors >= 5 && < 6
, tagged >= 0.8 && < 1
ghc-options:
-Wall
hs-source-dirs:
src
exposed-modules:
Data.Validation
test-suite hedgehog
type:
exitcode-stdio-1.0
main-is:
hedgehog_tests.hs
default-language:
Haskell2010
build-depends:
base >= 4.11 && < 5
, assoc >= 1 && < 2
, bifunctors >= 5.5 && < 6
, hedgehog >= 0.5 && < 2
, lens >= 4.0.5 && < 6
, semigroupoids >= 5.2.2 && < 7
, semigroups >= 0.18.2 && < 1
, validation
ghc-options:
-Wall
-threaded
hs-source-dirs:
test
test-suite doctest
type:
exitcode-stdio-1.0
main-is:
doctest_tests.hs
default-language:
Haskell2010
build-depends:
base >= 4.11 && < 5
, process >= 1.6 && < 2
, validation
ghc-options:
-Wall
-threaded
hs-source-dirs:
test