summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsellout <>2019-11-08 17:35:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2019-11-08 17:35:00 (GMT)
commitbc35ac0556080908bfd3ca3d56d396f49c47bf59 (patch)
treea0f27555a697158fca4c347eb65cd1acc39de88e
parent6060f959f32094921180e76f0bd97727728a233f (diff)
version 0.1.2.1HEAD0.1.2.1master
-rw-r--r--CHANGELOG.md8
-rw-r--r--src/Yaya/Hedgehog/Expr.hs1
-rw-r--r--src/Yaya/Hedgehog/Fold.hs44
-rw-r--r--yaya-hedgehog.cabal2
4 files changed, 32 insertions, 23 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 30fe420..88d1483 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
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.1.2.1 – 2019–11–08
+### Changed
+- improved documentation
+
+## 0.1.2.0 – 2019–11–08
+### Added
+- `law_cataCompose`
+
## 0.1.1.0 – 2019–01–08
### Added
- `law_anaRefl` as dual to `law_cataRefl`
diff --git a/src/Yaya/Hedgehog/Expr.hs b/src/Yaya/Hedgehog/Expr.hs
index 9d96d76..35bcaea 100644
--- a/src/Yaya/Hedgehog/Expr.hs
+++ b/src/Yaya/Hedgehog/Expr.hs
@@ -1,4 +1,5 @@
{-# LANGUAGE DeriveTraversable #-}
+{-# LANGUAGE StrictData #-}
{-# LANGUAGE TemplateHaskell #-}
module Yaya.Hedgehog.Expr where
diff --git a/src/Yaya/Hedgehog/Fold.hs b/src/Yaya/Hedgehog/Fold.hs
index 8364f0a..dd62087 100644
--- a/src/Yaya/Hedgehog/Fold.hs
+++ b/src/Yaya/Hedgehog/Fold.hs
@@ -5,6 +5,7 @@
module Yaya.Hedgehog.Fold where
import Control.Arrow
+import Data.Proxy
import Data.Void
import Hedgehog
import Numeric.Natural
@@ -17,11 +18,6 @@ law_cataCancel
=> Algebra f a -> f t -> m ()
law_cataCancel φ = uncurry (===) . (cata φ . embed &&& φ . fmap (cata φ))
--- law_anaCancel
--- :: (Eq (f t), Show a, Steppable t f, Corecursive t f, Functor f, MonadTest m)
--- => Coalgebra f a -> a -> m ()
--- law_anaCancel ψ = uncurry (===) . (project . ana ψ &&& fmap (ana ψ) . ψ)
-
law_cataRefl
:: (Eq t, Show t, Steppable t f, Recursive t f, MonadTest m) => t -> m ()
law_cataRefl = uncurry (===) . (cata embed &&& id)
@@ -39,32 +35,36 @@ law_anaRefl = uncurry (===) . (ana project &&& id)
-- uncurry (==) ((f . φ &&& φ . fmap f) fa)
-- ==> uncurry (===) ((f . cata φ &&& cata φ) t)
--- law_cataCompose
--- :: (Eq b, Show b, Recursive t f, Steppable u g, Recursive u g, MonadTest m)
--- => Algebra g b -> (forall a. f a -> g a) -> t -> m ()
--- law_cataCompose φ ε =
--- uncurry (===) . (cata φ . cata (embed . ε) &&& cata (φ . ε))
+law_cataCompose
+ :: forall t f u g m b
+ . (Eq b, Show b, Recursive t f, Steppable u g, Recursive u g, MonadTest m)
+ => Proxy u -> Algebra g b -> (forall a. f a -> g a) -> t -> m ()
+law_cataCompose _ φ ε =
+ uncurry (===) . (cata φ . cata (embed . ε :: f u -> u) &&& cata (φ . ε))
-- | Creates a generator for any `Steppable` type whose pattern functor has
--- terminal cases (e.g., not `Identity` or `((,) a)`). `leaf` can only
--- generate terminal cases, and `any` can generate any case. If the provided
--- `any` generates terminal cases, then the resulting tree may have a height
--- less than the `Size`, otherwise it will be a perfect tree with a height of
--- exactly the provided `Size`.
+-- terminal cases (e.g., not `Data.Functor.Identity` or `((,) a)`). @leaf@ can
+-- only generate terminal cases, and `any` can generate any case. If the
+-- provided `any` generates terminal cases, then the resulting tree may have a
+-- height less than the `Size`, otherwise it will be a perfect tree with a
+-- height of exactly the provided `Size`.
--
-- This is similar to `Gen.recursive` in that it separates the non-recursive
-- cases from the recursive ones, except
--- • the types here also ensure that the non-recursive cases aren’t recursive,
--- • different generator distributions may be used for rec & non-rec cases, and
--- • the non-recursive cases aren’t included in recursive calls (see above for
+--
+-- * the types here also ensure that the non-recursive cases aren’t recursive,
+--
+-- * different generator distributions may be used for rec & non-rec cases, and
+--
+-- * the non-recursive cases aren’t included in recursive calls (see above for
-- why).
--
--- If there’s no existing `Gen (f Void)` for your pattern functor, you can
+-- If there’s no existing @Gen (f Void)@ for your pattern functor, you can
-- either create one manually, or pass `Hedgehog.Gen.discard` to the usual
--- `Gen a -> Gen (f a)` generator.
+-- @Gen a -> Gen (f a)@ generator.
--
--- *NB*: Hedgehog’s `Size` is signed, so this can raise an exception if given a
--- negative `Size`.
+-- NB: Hedgehog’s `Size` is signed, so this can raise an exception if given a
+-- negative `Size`.
embeddableOfHeight
:: (Steppable t f, Functor f)
=> Gen (f Void) -> (Gen t -> Gen (f t)) -> Size -> Gen t
diff --git a/yaya-hedgehog.cabal b/yaya-hedgehog.cabal
index 3e817be..59b6d08 100644
--- a/yaya-hedgehog.cabal
+++ b/yaya-hedgehog.cabal
@@ -1,5 +1,5 @@
name: yaya-hedgehog
-version: 0.1.1.0
+version: 0.1.2.1
synopsis: Hedgehog testing support for the Yaya recursion scheme
library.
description: If you use Yaya in your own code and have tests written