Skip to content

Instantly share code, notes, and snippets.

@coco98
Created December 14, 2018 06:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coco98/f32105caadb768c481f13647d8cb791a to your computer and use it in GitHub Desktop.
Save coco98/f32105caadb768c481f13647d8cb791a to your computer and use it in GitHub Desktop.
-- AST1
data ColExpression = ColE ColName [OperationExpression]
data BoolExpression = BECol ColExpression
data BoolExpression
= BEAnd [BoolExpression]
| BEOr [BoolExpression]
| BENot BoolExpression
| BECol ColExpression
-- AST2
data ColExpressionAnnotated = ColEA ColInfo ColExpression
data BoolExpressionAnnotated
= BEAnd [BoolExpressionAnnotated]
| BEOr [BoolExpressionAnnotated]
| BENot (BoolExpressionAnnotated)
| BECol ColExpressionAnnotated
addAnnotation :: BoolExpression -> BoolExpressionAnnotated
-- Parametrised
data BoolExpressionG a
= BEAnd [BoolExpression a]
| BEOr [BoolExpression a]
| BENot (BoolExpression a)
| BECol a
type BoolExpression = BoolExpressionG ColExpression
type BoolExpressionAnnotated = BoolExpressionG ColExpressionAnnotated
-- Traversable
data BoolExpressionG a
= BEAnd [BoolExpression a]
| BEOr [BoolExpression a]
| BENot (BoolExpression a)
| BECol a
derive (Traversable)
type BoolExpression = BoolExpressionG ColExpression
type BoolExpressionAnnotated = BoolExpressionG ColExpressionAnnotated
traverse
:: (Applicative f, Traversable t) => (a -> f b) -> t a -> f (t b)
addAnnotationToCol :: ColExpression -> Either Error ColExpressionAnnotated
addAnnotationToCol :: (Applicative f) => a -> f b
addAnnotation = traverse addAnnotationToCol
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment