git.iko.soy/typeable/validationt
on bf15ce7 help sign in
6 files changed+54−52
since splitsnapshots
unifiedsplit
.travis.yml+24−13 README.md+1−2 src/Control/Monad/Validation.hs+5−18 stack.yaml+1−1 test/Doc.hs+1−1 validationt.cabal+22−17
.travis.yml+24−13
@@ -12,27 +12,38 @@ cache:
1212
1313jobs:
1414 include:
15− - ghc: 8.10.2
16− env: SNAPSHOT="nightly-2020-11-03"
17− - ghc: 8.8.4
18− env: SNAPSHOT="lts-16.20"
19− - ghc: 8.6.5
20− env: SNAPSHOT="lts-14.22"
15+
16+ # Cabal
2117 - ghc: 8.4.4
22− env: SNAPSHOT="lts-12.26"
18+ - ghc: 8.6.5
19+
20+ # Stack
21+ - ghc: 8.6.5
22+ env: STACK_YAML="$TRAVIS_BUILD_DIR/stack.yaml"
2323
2424install:
2525 - |
26− # install stack
27− curl -sSL https://get.haskellstack.org/ | sh
26+ if [ -z "$STACK_YAML" ]; then
27+ ghc --version
28+ cabal --version
29+ cabal new-update
30+ cabal new-build --enable-tests --enable-benchmarks
31+ else
32+ # install stack
33+ curl -sSL https://get.haskellstack.org/ | sh
2834
29− # build project with stack
30− stack --version
31− stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks --resolver=$SNAPSHOT
35+ # build project with stack
36+ stack --version
37+ stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks
38+ fi
3239
3340script:
3441 - |
35− stack test --system-ghc
42+ if [ -z "$STACK_YAML" ]; then
43+ cabal new-test --enable-tests
44+ else
45+ stack test --system-ghc
46+ fi
3647
3748notifications:
3849 email: false
README.md+1−2
@@ -2,8 +2,7 @@
22
33# ValidationT
44
5−A simple data validation library. The main idea is to provide an easy way to
6−validate web form data by aggregating errors for each field.
5+A very small validation data library.
76
87## Usage
98
src/Control/Monad/Validation.hs+5−18
@@ -16,7 +16,6 @@ module Control.Monad.Validation
1616 , vWarningL
1717 , vZoom
1818 , vZoomL
19− , vPromote
2019 , mmSingleton
2120 , setMempty
2221 , neConcat
@@ -38,14 +37,11 @@ import Data.Foldable as F
3837import Data.Functor
3938import Data.List as L
4039import Data.Map.Strict as M
40+import Data.Monoid
4141import Data.Text as T
4242import Data.Vector as V
4343import Test.QuickCheck
4444
45−#if MIN_VERSION_mtl(2,3,0)
46−import Control.Monad
47−import Control.Monad.Fix
48−#endif
4945
5046-- | Collects all thrown warnings in 'StateT' and errors
5147-- in 'ExceptT' into a single value using 'Monoid'.
@@ -89,7 +85,7 @@ instance (Ord k, Semigroup v) => Semigroup (MonoidMap k v) where
8985
9086instance (Ord k, Monoid v) => Monoid (MonoidMap k v) where
9187 mempty = MonoidMap M.empty
92− mappend = (<>)
88+ mappend = mmAppend
9389
9490instance (ToJSON k, ToJSON v) => ToJSON (MonoidMap k v) where
9591 toJSON (MonoidMap m) = toJSON $ L.map toObj $ M.toList m
@@ -147,12 +143,12 @@ neConcat f a
147143textErrors :: [Text] -> Maybe Text
148144textErrors = neConcat (\a b -> a <> ", " <> b)
149145
150−-- | Returns 'mempty' instead of error if no warnings have occurred.
146+-- | Returns 'mempty' instead of error if no warnings have occured.
151147-- Returns 'Nothing' as the second element of tuple if computation was
152148-- interrupted by 'vError'.
153149--
154150-- Returns all concatenated errors and warnings and the result if no
155−-- errors have occurred (warnings could have occurred).
151+-- errors have occured (warnings could have occured).
156152--
157153-- >>> :{
158154-- runValidationT $ do
@@ -178,7 +174,7 @@ runValidationT (ValidationT m) = do
178174 Right a -> (warnings, Just a)
179175
180176-- | Like 'runValidationT' but doesn't return the result
181−-- if any warning has occurred.
177+-- if any warning has occured.
182178--
183179-- >>> :{
184180-- runValidationTEither $ do
@@ -289,12 +285,3 @@ vZoomL
289285 -> ValidationT a m x
290286 -> ValidationT b m x
291287vZoomL l = vZoom (setMempty l)
292−
293−-- | Turn any warnings the have occurred into errors.
294−vPromote
295− :: (Monad m, Monoid a, Eq a)
296− => ValidationT a m x
297− -> ValidationT a m x
298−vPromote m = do
299− err <- lift $ runValidationTEither m
300− either vError return err
stack.yaml+1−1
@@ -15,7 +15,7 @@
1515# resolver:
1616# name: custom-snapshot
1717# location: "./custom-snapshot.yaml"
18−resolver: lts-22.4
18+resolver: lts-14.21
1919
2020# User packages to be built.
2121# Various formats can be used as shown in the example below.
test/Doc.hs+1−1
@@ -3,4 +3,4 @@ module Main (main) where
33import Test.DocTest
44
55main :: IO ()
6−main = doctest [ "-XOverloadedStrings", "-isrc", "src" ]
6+main = doctest [ "-XOverloadedStrings", "src" ]
validationt.cabal+22−17
@@ -3,10 +3,8 @@
33
44name: validationt
55version: 0.3.0
6−synopsis: Straightforward validation monad
7−description:
8− A simple data validation library. The main idea is to provide an easy way to validate web form data by aggregating errors for each field.
9− .
6+synopsis: Straightforward validation monad.
7+description: Convenient solution for validating web forms and APIs.
108homepage: https://github.com/typeable/validationt
119license: BSD3
1210license-file: LICENSE
@@ -16,12 +14,9 @@ maintainer: makeit@typeable.io
1614category: Control
1715build-type: Simple
1816extra-source-files: ChangeLog.md
19− , README.md
2017cabal-version: >=1.10
2118tested-with: GHC == 8.4.4
2219 , GHC == 8.6.5
23− , GHC == 8.8.4
24− , GHC == 8.10.2
2520
2621source-repository head
2722 type: git
@@ -29,14 +24,14 @@ source-repository head
2924
3025library
3126 exposed-modules: Control.Monad.Validation
32− build-depends: base >=4.10 && < 5
33− , aeson >=1.0
27+ build-depends: base >=4.8 && < 5
28+ , aeson >= 1.0
3429 , containers
35− , exceptions >=0.9
30+ , exceptions
3631 , lens
3732 , monad-control
38− , mtl <2.3 || >2.3
39− , QuickCheck >=2.8.2
33+ , mtl
34+ , QuickCheck
4035 , text
4136 , transformers
4237 , transformers-base
@@ -55,12 +50,22 @@ library
5550 -Wmissing-export-lists
5651
5752test-suite doctest
58− default-language: Haskell2010
5953 type: exitcode-stdio-1.0
6054 hs-source-dirs: test
6155 ghc-options: -Wall
6256 main-is: Doc.hs
63− build-depends:
64− base >= 4.10.0.0
65− , doctest >= 0.11.4
66− , validationt
57+ default-language: Haskell2010
58+ build-depends: base >=4.8 && < 5
59+ , aeson >= 1.0
60+ , doctest
61+ , containers
62+ , exceptions
63+ , lens
64+ , monad-control
65+ , mtl
66+ , QuickCheck
67+ , text
68+ , transformers
69+ , transformers-base
70+ , vector
71+ , doctest