derive-topdown-0.1.0.0: Derive type class instances
Copyright(c) Song Zhang
LicenseBSD-style (see the LICENSE file)
Maintainerhaskell.zhang.song `at` hotmail.com
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Data.Derive.TopDown.Standalone

Description

 
Synopsis

Documentation

deriving_ Source #

Arguments

:: Name

class name

-> Name

type name

-> Q [Dec] 

deriving_with_breaks Source #

Arguments

:: Name

class name

-> Name

type name

-> [Name]

type names that stop the deriving process

-> Q [Dec] 

This is particularly useful with Generic class.

For the types like Int, Char,Ratio or other types which are not Generic, there must be a way to stop the generation process on those types. However, the deriving topdown function will only stop generating Generic instances on primitive types and Integer by default, so you do not need to break on them manually. Another circumtances might be deriving for Typeable class. Since there is a bug in GHC, isInstance function in TH library is not working on Typeable, you can manually give the types which are already instances of Typeable to stop the generation process. For others cases, there no need to use this function, bacause for a data type A which is composited by another type, when you manually write an instance declaration for A, the process will stop on A automatically since it is already an instance of the type class.

derivings Source #

Arguments

:: [Name]

class names

-> Name

type name

-> Q [Dec] 

derivingss Source #

Arguments

:: [Name]

class names

-> [Name]

type names

-> Q [Dec] 

deriving_with Source #

Arguments

:: ClassName 
-> TypeName 
-> Maybe DerivStrategy

deriving strategy

-> [TypeName]

a list of types that breaks the generation process

-> ContextGenderator

a context generator, genInferredContext, genHoleContext or genAllFieldsContext

-> Q [Dec] 

Context generator ca be the following 3 1. genHoleContext: It requires PartialTypeSignatures to make the context of deriving context a hole e.g. _ => Cls (D a b). This case cannot handle type family since GHC cannot handle it 2. genInferredContext: It will try to infer the context including cases with type families. 3. genAllFieldsContext: It will put all fields into the context. It may generate like the followings data List a = Nil | Cons a (List a) deriving instance (Show a, Show (List a)) => Show (List a)