first-class-instances-0.1.0.0: First class typeclass instances

Safe HaskellNone
LanguageHaskell2010

FCI.Internal.TH

Description

TH for dictionary representation generation. This module is internal and provides no guarantees about stability and safety of it's interface.

Synopsis

Documentation

mkInst :: Name -> Q [Dec] Source #

Creates first class instance representation from based on class. Generated representation is record of class members following simple format:

  • name of record constructor is name of original class
  • superclass constraints are transformed into fields containing their representation, names of fields are generated this way:

    • Prefix names (Show, Applicative) are prefixed with _
    • Operators (('~')) are prefixed with ||
    • Tuples are converted into prefix names _Tuple
    • Additional occurencies of same prefix name get postfix index starting from 1
    • Additional occurencies of same operator are postfixed with increasing number of |s
  • methods get their own fields, names of fields are names of methods prefixed with _

To avoid possibly breaking assumptions author of class may have made about it's instances, you can only create representation for class in current module.

unsafeMkInst :: Name -> Q [Dec] Source #

Version of mkInst without any checks. You shouldn't use it unless you're working on this library.

getClassDictInfo :: Name -> Q ClassDictInfo Source #

Constructs info about class dictionary represenation being created.

dictInst :: ClassDictInfo -> [Dec] Source #

Creates Dict instance from info about class dictionary representation.