haskellator-0.1.0.0: SI-Units supporting calculator
Safe HaskellSafe-Inferred
LanguageHaskell2010

Math.Haskellator.Internal.TH.OperGeneration

Description

Generate the operator type.

Synopsis

Documentation

data OperatorDef Source #

Definition of a operator

Constructors

OperDef

Operator definition

Fields

generateOperators :: [OperatorDef] -> Q [Dec] Source #

Generate the operator type. Imagine the following call: generateOperators [OperDef Plus "+", OperDef Minus "-"]. This function will then generate the following code:

  • A data type with all the operators
data Op = Plus | Minus
  • An instance of Show for the data type
instance Show Op where
  show Plus = "+"
  show Minus = "-"