packages feed

valid 0.1.0.0 → 0.1.1.0

raw patch · 2 files changed

+21/−2 lines, 2 filesdep +util

Dependencies added: util

Files

Data/Valid.hs view
@@ -1,5 +1,11 @@ module Data.Valid where +import Data.Bifoldable+import Data.Bifunctor+import Data.Bitraversable+import Data.Functor.Classes+import Util (compose2)+ data Valid e a = Failure e | Valid a   deriving (Eq, Read, Show, Functor, Foldable, Traversable) @@ -9,3 +15,16 @@     Failure x <*> Valid   _ = Failure x     Valid   _ <*> Failure y = Failure y     Valid   f <*> Valid   x = Valid (f x)++instance Bifunctor Valid where bimap = bimapDefault+instance Bifoldable Valid where bifoldMap = bifoldMapDefault+instance Bitraversable Valid where bitraverse f g = fmap fromEither . bitraverse f g . toEither++instance Eq2 Valid where liftEq2 f g = compose2 (liftEq2 f g) toEither toEither++fromEither :: Either e a -> Valid e a+fromEither = either Failure Valid++toEither :: Valid e a -> Either e a+toEither (Failure e) = Left  e+toEither (Valid   a) = Right a
valid.cabal view
@@ -1,5 +1,5 @@ name:                valid-version:             0.1.0.0+version:             0.1.1.0 synopsis:            Type isomorphic to `Either` with `Applicative` instance which combines errors -- description: license:             BSD3@@ -15,7 +15,7 @@ library   hs-source-dirs:      .   exposed-modules:     Data.Valid-  build-depends:       base >= 4.7 && < 5+  build-depends:       base >= 4.7 && < 5, util >= 0.1.12 && < 0.2   default-language:    Haskell2010   default-extensions:  UnicodeSyntax                      , LambdaCase