| Copyright | (c) 2017-2019 Rudy Matela |
|---|---|
| License | 3-Clause BSD (see the file LICENSE) |
| Maintainer | Rudy Matela <rudy@matela.com.br> |
| Safe Haskell | None |
| Language | Haskell2010 |
Test.Extrapolate.Generalizable.Derive
Description
This module is part of Extrapolate, a library for generalization of counter-examples.
This is a module for deriving Generalizable instances.
Needs GHC and Template Haskell (tested on GHC 8.0).
If Extrapolate does not compile under later GHCs, this module is the probable culprit.
Synopsis
Documentation
deriveGeneralizable :: Name -> DecsQ Source #
Derives a Generalizable instance for a given type Name.
If needed, this function also automatically derivates
Listable, Express and Name instances using respectively
deriveListable, deriveExpress and deriveName.
Consider the following Stack datatype:
data Stack a = Stack a (Stack a) | Empty
Writing
deriveGeneralizable ''Stack
will automatically derive the following Generalizable instance:
instance Generalizable a => Generalizable (Stack a) where
instances s = this "s" s
$ let Stack x y = Stack undefined undefined `asTypeOf` s
in instances x
. instances yThis function needs the TemplateHaskell extension.
deriveGeneralizableIfNeeded :: Name -> DecsQ Source #
Same as deriveGeneralizable but does not warn when instance already exists
(deriveGeneralizable is preferable).
deriveGeneralizableCascading :: Name -> DecsQ Source #
Derives a Generalizable instance for a given type Name
cascading derivation of type arguments as well.