-
-
Save DylanLukes/847450 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
{-# LANGUAGE GADTs, EmptyDataDecls#-} | |
module Calculator where | |
type Stack = [Double] | |
-- Empty data declarations to use as 'tags' | |
data Unary | |
data Binary | |
data Left | |
data Right | |
data Operator a b | |
data Paren a | |
-- Just for fun, encode EVERYTHING into the type | |
data Expr a where | |
Add :: Expr (Operator Binary Left) | |
Sub :: Expr (Operator Binary Left) | |
Mul :: Expr (Operator Binary Left) | |
Div :: Expr (Operator Binary Left) | |
Exp :: Expr (Operator Binary Right) | |
Lpr :: Expr (Paren Left) | |
Rpr :: Expr (Paren Right) | |
Val :: Expr (Double) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment