Created
December 14, 2018 06:13
-
-
Save coco98/f32105caadb768c481f13647d8cb791a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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