Added list patterns. Added som simple prelude functions.

This commit is contained in:
bringert
2005-12-01 17:27:06 +00:00
parent 8de44f741e
commit 396cc63cfc
12 changed files with 890 additions and 705 deletions

View File

@@ -381,6 +381,8 @@ desugar = return . map f
where
f :: Tree a -> Tree a
f x = case x of
PListCons p1 p2 -> pListCons <| p1 <| p2
PList xs -> pList (map f [p | PListElem p <- xs])
EIf exp0 exp1 exp2 -> ifBool <| exp0 <| exp1 <| exp2
EDo bs e -> mkDo (map f bs) (f e)
BindNoVar exp0 -> BindVar VWild <| exp0
@@ -406,6 +408,16 @@ desugar = return . map f
_ -> composOp f x
where g <| x = g (f x)
--
-- * List patterns
--
pListCons :: Pattern -> Pattern -> Pattern
pListCons p1 p2 = PCons (Ident "Cons") [PWild,p1,p2]
pList :: [Pattern] -> Pattern
pList = foldr pListCons (PCons (Ident "Nil") [PWild])
--
-- * Use an overloaded function.
--