HORIZON HASKELLDocslts/ghc-10.0.x77a86622026-10-31Search packagesCtrl K
Theme: |

GHC 10.0.0.20260917 · lts/ghc-10.0.x · 77a8662 · 2026-10-31

Modulegenvalidity-hspec-1.0.0.4Haskell2010

Test.Validity.Monad

Monad properties

You will need TypeApplications to use these.

Synopsis
valuemonadSpecOnGens
  1. :: (Show a, Show (f a), Show (f b), Show (f c), Eq (f a), Eq (f b), Eq (f c), Monad f, Typeable f, Typeable a, Typeable b, Typeable c)
  2. => Gen a
  3. -> String
  4. -> Gen (f a)
  5. -> String
  6. -> Gen (f b)
  7. -> String
  8. -> Gen (a -> b)
  9. -> String
  10. -> Gen (a -> f b)
  11. -> String
  12. -> Gen (b -> f c)
  13. -> String
  14. -> Gen (f (a -> b))
  15. -> String
  16. -> Spec

Standard test spec for properties of Monad instances for values generated by given generators (and names for those generator).

Example usage:

monadSpecOnGens
    @[]
    @Int
    (pure 4)
    "four"
    (genListOf $ pure 5)
    "list of fives"
    (genListOf $ pure 6)
    "list of sixes"
    ((*) <$> genValid)
    "factorisations"
    (pure $ \a -> [a])
    "singletonisation"
    (pure $ \a -> [a])
    "singletonisation"
    (pure $ pure (+ 1))
    "increment in list"