Copyright | (c) 2019-2025 Rudy Matela |
---|---|
License | 3-Clause BSD (see the file LICENSE) |
Maintainer | Rudy Matela <rudy@matela.com.br> |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Conjure.Conjurable.Derive
Description
Allows automatic derivation of Conjurable
typeclass instances.
Synopsis
- deriveConjurable :: Name -> DecsQ
- deriveConjurableCascading :: Name -> DecsQ
- deriveConjurableIfNeeded :: Name -> DecsQ
Documentation
deriveConjurable :: Name -> DecsQ Source #
Derives an Conjurable
instance for the given type Name
.
If not already present,
this also derives Listable
, Express
and Name
instances.
If the Data.Express' type binding operators
(-:
,
->:
or
->>:
)
are not in scope,
this derives them as well.
This function needs the TemplateHaskell
extension.
You can place the following at the top of the file:
{-# LANGUAGE TemplateHaskell #-} import Conjure import Test.LeanCheck
Then just call deriveConjurable
after your data type declaration:
data Peano = Z | S Peano deriving (Show, Eq) deriveConjurable ''Peano
deriveConjurable
expects the argument type to be
an instance of Show
and Eq
.
deriveConjurableCascading :: Name -> DecsQ Source #
Derives a Conjurable
instance for a given type Name
cascading derivation of type arguments as well.
deriveConjurableIfNeeded :: Name -> DecsQ Source #
Same as deriveConjurable
but does not warn when instance already exists
(deriveConjurable
is preferable).