Skip to content

Instantly share code, notes, and snippets.

@akhileshs
Created February 10, 2016 05:45
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 akhileshs/859974fa49e20447e7a4 to your computer and use it in GitHub Desktop.
Save akhileshs/859974fa49e20447e7a4 to your computer and use it in GitHub Desktop.
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