packages feed

one-liner 0.5.1 → 0.5.2

raw patch · 2 files changed

+21/−2 lines, 2 filesdep ~transformers

Dependency ranges changed: transformers

Files

examples/realworld.hs view
@@ -15,6 +15,8 @@ import Data.Functor.Contravariant.Divisible import Data.Void import Data.Binary+import Test.QuickCheck.Arbitrary+import Test.QuickCheck.Gen  -- http://hackage.haskell.org/package/lens-4.3.3/docs/Generics-Deriving-Lens.html whenCastableOrElse :: forall a b f. (Typeable a, Typeable b) => (b -> f b) -> (a -> f a) -> a -> f a@@ -76,3 +78,20 @@  gput :: (ADT t, Constraints t Binary) => t -> Put gput t = putWord8 (toEnum (ctorIndex t)) <> gfoldMap (For :: For Binary) put t++-- https://hackage.haskell.org/package/QuickCheck-2.8.1/docs/Test-QuickCheck-Arbitrary.html+newtype CoArb a = CoArb { unCoArb :: forall b. a -> Gen b -> Gen b }+instance Contravariant CoArb where+  contramap f (CoArb g) = CoArb $ \a -> g (f a)+instance Divisible CoArb where+  divide f (CoArb g) (CoArb h) = CoArb $ \a -> case f a of+    (b, c) -> g b . h c+  conquer = CoArb $ const id+instance Decidable CoArb where+  choose f (CoArb g) (CoArb h) = CoArb $ \a -> case f a of+    Left b -> variant 0 . g b+    Right c -> variant 1 . h c+  lose f = CoArb $ absurd . f++gcoarbitrary :: (ADT t, Constraints t CoArbitrary) => t -> Gen b -> Gen b+gcoarbitrary = unCoArb $ consume (For :: For CoArbitrary) (CoArb coarbitrary)
one-liner.cabal view
@@ -1,5 +1,5 @@ Name:                 one-liner-Version:              0.5.1+Version:              0.5.2 Synopsis:             Constraint-based generics Description:          Write short and concise generic instances of type classes.                       .@@ -35,7 +35,7 @@    Build-depends:       base         >= 4.7 && < 5-    , transformers >= 0.3 && < 0.5+    , transformers >= 0.3 && < 0.6     , contravariant >= 1.2 && < 1.4     , ghc-prim