Skip to content

Instantly share code, notes, and snippets.

@DylanLukes
Forked from Saizan/gist:847437
Created February 28, 2011 15:19
Show Gist options
  • Save DylanLukes/847450 to your computer and use it in GitHub Desktop.
Save DylanLukes/847450 to your computer and use it in GitHub Desktop.
{-# 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