Copyright | (c) 2015-2017 Rudy Matela |
---|---|
License | 3-Clause BSD (see the file LICENSE) |
Maintainer | Rudy Matela <rudy@matela.com.br> |
Safe Haskell | None |
Language | Haskell2010 |
Experimental module for deriving Mutable
and ShowMutable
instances
Needs GHC and Template Haskell (tested on GHC 7.4, 7.6, 7.8, 7.10 and 8.0)
Despite Mutable
instances being actually very simple to write manually,
this module can be used to derive those instances automatically.
However, it will not work on all cases:
when that happens, you should write your instances manually.
If FitSpec does not compile under later GHCs, this module is probably the culprit.
Synopsis
- deriveMutable :: Name -> DecsQ
- deriveMutableE :: [Name] -> Name -> DecsQ
- deriveMutableCascading :: Name -> DecsQ
- deriveMutableCascadingE :: [Name] -> Name -> DecsQ
- module Test.FitSpec.Mutable
- module Test.FitSpec.ShowMutable
- module Test.LeanCheck
Documentation
deriveMutable :: Name -> DecsQ Source #
Derives Mutable
, ShowMutable
and (optionally) Listable
instances
for a given type Name
.
Consider the following Stack
datatype:
data Stack a = Stack a (Stack a) | Empty
Writing
deriveMutable ''Stack
will automatically derive the following
Listable
, Mutable
and ShowMutable
instances:
instance Listable a => Listable (Stack a) where tiers = cons2 Stack \/ cons0 Empty instance (Eq a, Listable a) => Mutable a where mutiers = mutiersEq instance (Eq a, Show a) => ShowMutable a where mutantS = mutantSEq
If a Listable
instance already exists, it is not derived.
(cf.: deriveListable
)
Needs the TemplateHaskell
extension.
deriveMutableE :: [Name] -> Name -> DecsQ Source #
Derives a Mutable instance for a given type Name
using a given context for all type variables.
deriveMutableCascading :: Name -> DecsQ Source #
module Test.FitSpec.Mutable
module Test.FitSpec.ShowMutable
module Test.LeanCheck