packages feed

contracheck-applicative 0.1.0.1 → 0.1.1.0

raw patch · 4 files changed

+16/−18 lines, 4 filesdep −bytestringdep −textdep ~containersdep ~contravariantdep ~mmorphPVP ok

version bump matches the API change (PVP)

Dependencies removed: bytestring, text

Dependency ranges changed: containers, contravariant, mmorph

API changes (from Hackage documentation)

Files

ChangeLog.md view
@@ -1,3 +1,3 @@ # Changelog for contracheck-applicative -## Unreleased changes+## 0.1.1.0 Drop Checkable instances for Text and ByteString
contracheck-applicative.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: 44c9537d1ff6d399e254d9f95bcfffe456f3583dff7a3cccf9d85b7227db32cd+-- hash: 7bcfb4f8bca1b4c9e06b625e368c40c38640e33f9dfa799987c2dd92d33689a9  name:           contracheck-applicative-version:        0.1.0.1+version:        0.1.1.0 synopsis:       Validation types/typeclass based on the contravariance. description:    This package provides types and a typeclass that allow for effectful validation and easy composition. For documentation see the [README](https://gitlab.com/Birkmann/validation-check/-/blob/master/README.md). If there are any issues, contact me at 99fabianb@sis.gl. category:       Validation@@ -32,9 +32,7 @@   ghc-options: -Wall -Wcompat -Wincomplete-patterns -Wincomplete-record-updates -Wincomplete-uni-patterns -Wredundant-constraints -Wpartial-fields   build-depends:       base >=4.7 && <5-    , bytestring >=0.10.10 && <0.11-    , containers >=0.6.2 && <0.7-    , contravariant >=1.5.2 && <1.6-    , mmorph >=1.1.3 && <1.2-    , text >=1.2.4 && <1.3+    , containers >=0.4 && <0.7+    , contravariant >=1.0.0 && <1.6+    , mmorph >=1.0.0 && <1.2   default-language: Haskell2010
src/Control/Validation/Check.hs view
@@ -184,6 +184,10 @@     = Check { runCheck :: Unvalidated a -> m (CheckResult e) }         deriving ( Monoid, Semigroup ) via (a -> Ap m (CheckResult e))         deriving ( Contravariant, Divisible, Decidable) via (Op (Ap m (CheckResult e)))++instance MFunctor (Check e) where+    hoist f = withCheck (f .)+ withCheck :: ( (Unvalidated a -> m (CheckResult d))                   -> Unvalidated b -> n (CheckResult e))              -> Check d m a -> Check e n b@@ -194,15 +198,14 @@ validateBy :: Functor m => Check e m a -> Unvalidated a -> m (Either (Seq e) a) validateBy c u@(Unvalidated x) = fmap (checkResultToEither x) . runCheck c $ u +-- | 'validateBy' for trivial context. validateBy' :: Check' e a -> Unvalidated a -> Either (Seq e) a validateBy' c = runIdentity . validateBy c +-- | A 'Check' with a trivial context type Check' e = Check e Identity -instance MFunctor (Check e) where-    hoist f = withCheck (f .)--+-- | Generalize a 'Check' without context to any 'Check' with an applicative context generalizeCheck :: Applicative m => Check' e a -> Check e m a generalizeCheck = hoist (pure . runIdentity) @@ -238,13 +241,13 @@ -- * Additional >: discards its argument: `?>>`, `?~>>`. -- * Tilde works with non-trivial contexts: `?~>`, `?~>>`. +-- | General construction function for checks. checking :: (a -> m (CheckResult e)) -> Check e m a checking = Check . (. unsafeValidate)  checking' :: (a -> CheckResult e) -> Check' e a checking' = checking . (Identity .) - test', (?>) :: Applicative m => (a -> Bool) -> (a -> e) -> Check e m a  test' p onErr = Check $ \(Unvalidated x) -> pure $ if p x      then Passed@@ -286,10 +289,11 @@ infix 7 ?~>>   --- | Lifting checks+-- | Lift a check to a foldable foldWithCheck :: (Foldable f, Applicative m) => Check e m a -> Check e m (f a) foldWithCheck c = checking $ getAp . foldMap (Ap . runCheck c . unvalidated) +-- | Lift a check to a traversable traverseWithCheck :: (Traversable t, Applicative m) => Check e m a -> Check e m (t a) traverseWithCheck c = checking $ fmap fold . traverse (runCheck c . unvalidated) 
src/Control/Validation/Class.hs view
@@ -22,8 +22,6 @@ import Data.Kind(Type) import Data.Void(Void) import Data.Int(Int8, Int16, Int32, Int64)-import Data.ByteString(ByteString)-import Data.Text(Text)     import Control.Validation.Check import Data.Functor.Identity(Identity(..)) import Data.Sequence(Seq)@@ -139,8 +137,6 @@ deriving via TrivialCheck Int32      instance Validatable Void Identity Int32 deriving via TrivialCheck Int64      instance Validatable Void Identity Int64 deriving via TrivialCheck Integer    instance Validatable Void Identity Integer-deriving via TrivialCheck ByteString instance Validatable Void Identity ByteString-deriving via TrivialCheck Text       instance Validatable Void Identity Text   instance (Validatable e m a, Applicative m) => (Validatable e m (Maybe a)) where     checkChain = traverseWithCheck `overChain` checkChain