packages feed

yaya 0.2.0.0 → 0.2.1.0

raw patch · 6 files changed

+84/−5 lines, 6 files

Files

CHANGELOG.md view
@@ -4,6 +4,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to the [Haskell Package Versioning Policy](https://pvp.haskell.org/). +## 0.2.1.0 – 2019–01–08+### Added+- exports of type class methods via `Yaya.Retrofit`+ ## 0.2.0.0 – 2019–01–08 ### Added - `DFunctor` instances for `Mu` and `Nu`
src/Yaya/Retrofit.hs view
@@ -5,10 +5,10 @@   ) where  import Yaya.Fold-       ( Corecursive-       , Projectable-       , Recursive+       ( Corecursive (..)+       , Projectable (..)+       , Recursive (..)        , recursiveEq        , recursiveShowsPrec-       , Steppable+       , Steppable (..)        )
+ test/Test/Fold/Retrofit.hs view
@@ -0,0 +1,28 @@+{-# LANGUAGE TemplateHaskell  #-}+{-# LANGUAGE TypeApplications #-}++module Test.Fold.Retrofit where++import           Hedgehog+import qualified Hedgehog.Gen as Gen++import           Yaya.Fold.Common+import           Yaya.Hedgehog.Expr+import           Yaya.Hedgehog.Fold++import           Test.Retrofit++prop_exprAnaRefl :: Property+prop_exprAnaRefl =+  property $ law_anaRefl =<< forAll (Gen.sized (expression @DExpr))++prop_exprCataCancel :: Property+prop_exprCataCancel =+  property $ law_cataCancel size =<< forAll (genExpr (Gen.sized (expression @DExpr)))++prop_exprCataRefl :: Property+prop_exprCataRefl =+  property $ law_cataRefl =<< forAll (Gen.sized (expression @DExpr))++tests :: IO Bool+tests = checkParallel $$(discover)
+ test/Test/Retrofit.hs view
@@ -0,0 +1,41 @@+-- | The point of this module is that it should compile _without_ importing any+--   other Yaya modules.+module Test.Retrofit where++import qualified Yaya.Hedgehog.Expr as ExprF+import           Yaya.Retrofit++data DExpr+  = Lit Int+  | Add DExpr DExpr+  | Mult DExpr DExpr++instance Projectable DExpr ExprF.Expr where+  project = \case+    Lit i -> ExprF.Lit i+    Add a b -> ExprF.Add a b+    Mult a b -> ExprF.Mult a b++instance Steppable DExpr ExprF.Expr where+  embed = \case+    ExprF.Lit i -> Lit i+    ExprF.Add a b -> Add a b+    ExprF.Mult a b -> Mult a b++instance Corecursive DExpr ExprF.Expr where+  ana ψ = embed . fmap (ana ψ) . ψ++-- | This is unsafe, but we really just want to make sure all the methods are+--   available.+instance Recursive DExpr ExprF.Expr where+  cata φ = φ . fmap (cata φ) . project++-- | This can be derived in this case, but we want to ensure we could define it+--   if necessary.+instance Eq DExpr where+  (==) = recursiveEq++-- | This can be derived in this case, but we want to ensure we could define it+--   if necessary.+instance Show DExpr where+  showsPrec = recursiveShowsPrec
test/test.hs view
@@ -4,6 +4,7 @@  import qualified Test.Fold as Fold import qualified Test.Fold.Common as Fold.Common+import qualified Test.Fold.Retrofit as Fold.Retrofit  main :: IO () main = do@@ -12,6 +13,7 @@    results <- sequence [ Fold.tests                       , Fold.Common.tests+                      , Fold.Retrofit.tests                       ]    unless (and results) exitFailure
yaya.cabal view
@@ -1,5 +1,5 @@ name:                yaya-version:             0.2.0.0+version:             0.2.1.0 synopsis:            Total recursion schemes. description:         Recursion schemes allow you to separate recursion from your                      business logic – making your own operations simpler, more@@ -63,11 +63,15 @@   main-is:             test.hs   other-modules:       Test.Fold                      , Test.Fold.Common+                     , Test.Fold.Retrofit+                     , Test.Retrofit   build-depends:       base                      , deriving-compat                      , hedgehog                      , yaya >= 0.1.0                      , yaya-hedgehog >= 0.1.0+  default-extensions:  LambdaCase+                     , MultiParamTypeClasses   ghc-options:         -threaded -rtsopts -with-rtsopts=-N -Wall   default-language:    Haskell2010