Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Generate the operator type.
Synopsis
- data OperatorDef = OperDef String String
- generateOperators :: [OperatorDef] -> Q [Dec]
Documentation
data OperatorDef Source #
Definition of a operator
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 = "-"