code-conjure-0.6.8: synthesize Haskell functions out of partial definitions
Copyright(c) 2019-2025 Rudy Matela
License3-Clause BSD (see the file LICENSE)
MaintainerRudy Matela <rudy@matela.com.br>
Safe HaskellSafe-Inferred
LanguageHaskell2010

Conjure.Conjurable.Derive

Description

Allows automatic derivation of Conjurable typeclass instances.

Synopsis

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).