Skip to content

Instantly share code, notes, and snippets.

@philipnilsson
Created November 19, 2014 01:29
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 philipnilsson/7b0974e4a8094c04efb3 to your computer and use it in GitHub Desktop.
Save philipnilsson/7b0974e4a8094c04efb3 to your computer and use it in GitHub Desktop.
data Pair a = Pair a a
data Exp typ where
Vec :: Exp a -> Exp a -> Exp (Pair a)
Const :: Int -> Exp Int
-- with type
type RHS typ = String
data Statement typ =
RHS typ := Exp typ
vec :: RHS (Pair Int)
vec = "test"
x = vec := Const 3
-- with data
data RHS' typ = RHS String
data Statement' typ =
RHS' typ ::= Exp typ
vec' :: RHS' (Pair Int)
vec' = RHS "test"
-- will produce expected compile error:
-- Couldn't match type `Int' with `Pair Int'
-- x' = vec' ::= Const 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment