Commit 4f153095 authored by matthew-eads's avatar matthew-eads
Browse files

support for maybe types

parent ed85b0b7
...@@ -10,7 +10,7 @@ data Exp = SET ID Exp ...@@ -10,7 +10,7 @@ data Exp = SET ID Exp
| IF SimpleExp Exp Exp | IF SimpleExp Exp Exp
| WHILE SimpleExp Exp | WHILE SimpleExp Exp
| BEGIN (List1 Exp) | BEGIN (List1 Exp)
| TUPY (Exp, Exp) | TUPY (Exp, Exp) (Maybe Potato)
| LET [(String, Exp)] | LET [(String, Exp)]
data BinOp = Plus SimpleExp SimpleExp data BinOp = Plus SimpleExp SimpleExp
......
...@@ -59,9 +59,18 @@ stypeToString :: StrictType -> (String, String) ...@@ -59,9 +59,18 @@ stypeToString :: StrictType -> (String, String)
stypeToString (_, (ConT n)) = (showName n, "") stypeToString (_, (ConT n)) = (showName n, "")
stypeToString (_, (AppT ListT t)) = let (s, rs) = (stypeToString (IsStrict, t)) stypeToString (_, (AppT ListT t)) = let (s, rs) = (stypeToString (IsStrict, t))
in (s ++ "*", (rs ++ "\n\n" ++ makeMultiRules (AppT (ConT list0) t) s)) in (s ++ "*", (rs ++ "\n\n" ++ makeMultiRules (AppT (ConT list0) t) s))
stypeToString (_, (AppT (ConT n) t)) = let (s, rs) = (stypeToString (IsStrict, t)) stypeToString (_, (AppT (ConT n) t)) =
c = if n == list0 then "*" else "+" if n == list0 || n == list1 then
in (s ++ c, (rs ++ "\n\n" ++ makeMultiRules (AppT (ConT n) t) s)) let (s, rs) = (stypeToString (IsStrict, t))
c = if n == list0 then "*" else "+"
in (s ++ c, (rs ++ "\n\n" ++ makeMultiRules (AppT (ConT n) t) s))
else if n == (mkName "Maybe") then
let (s, rs) = (stypeToString (IsStrict, t))
in (("Maybe" ++ s),
rs ++ ("\n\nMaybe" ++ s ++ ": " ++ s ++ "\t{Just $1}\n" ++
(makeTab ("maybe" ++ s)) ++ "| \t{Nothing}"))
else ("", "")
stypeToString (_, (AppT t1 t2)) = let ts = flattenTuple t1 t2 stypeToString (_, (AppT t1 t2)) = let ts = flattenTuple t1 t2
ts' = map (stypeToString . (\x -> (IsStrict, x))) ts ts' = map (stypeToString . (\x -> (IsStrict, x))) ts
(s, rs) = ((foldr (\(x, y) a -> (fixMultis x) ++ "\\" ++ a) "" ts'), (s, rs) = ((foldr (\(x, y) a -> (fixMultis x) ++ "\\" ++ a) "" ts'),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment