leancheck-0.6.7: Cholesterol-free property-based testing

Copyright(c) 2015-2017 Rudy Matela
License3-Clause BSD (see the file LICENSE)
MaintainerRudy Matela <rudy@matela.com.br>
Safe HaskellNone
LanguageHaskell2010

Test.LeanCheck.Derive

Description

This module is part of LeanCheck, a simple enumerative property-based testing library.

This is an experimental module for deriving Listable instances.

Needs GHC and Template Haskell (tested on GHC 7.4, 7.6, 7.8, 7.10 and 8.0).

If LeanCheck does not compile under later GHCs, this module is probably the culprit.

Synopsis

Documentation

deriveListable :: Name -> DecsQ Source #

Derives a Listable instance for a given type Name.

Consider the following Stack datatype:

data Stack a = Stack a (Stack a) | Empty

Writing

deriveListable ''Stack

will automatically derive the following Listable instance:

instance Listable a => Listable (Stack a) where
  tiers = cons2 Stack \/ cons0 Empty

Needs the TemplateHaskell extension.

deriveListableIfNeeded :: Name -> DecsQ Source #

Same as deriveListable but does not warn when instance already exists (deriveListable is preferable).

deriveListableCascading :: Name -> DecsQ Source #

Derives a Listable instance for a given type Name cascading derivation of type arguments as well.