Created
February 10, 2016 05:45
-
-
Save akhileshs/859974fa49e20447e7a4 to your computer and use it in GitHub Desktop.
This file contains 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
data PrimExpr = | |
BinExpr BinOp PrimExpr PrimExpr | |
| UnExpr UnOp PrimExpr | |
| ConstExpr String | |
| IntExpr Int | |
| BoolExpr Bool | |
data BinOp = | |
OpEq | |
| OpAnd | |
| OpPlus | |
data UnOp | |
-- phantom types for well-formedness | |
data Expr a = Expr PrimExpr | |
(.==.) :: Eq a => Expr a -> Expr a -> Expr Bool | |
(.==.) x y = Expr (BoolExpr True) -- at least at the type-level. | |
createExprInt :: Int -> Expr Int | |
createExprInt x = Expr (IntExpr x) | |
createExprString :: String -> Expr String | |
createExprString s = Expr (ConstExpr s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment