From 396cc63cfc3658a11bbc76c9b5c4bf32e21cef6a Mon Sep 17 00:00:00 2001 From: bringert Date: Thu, 1 Dec 2005 17:27:06 +0000 Subject: Added list patterns. Added som simple prelude functions. --- src/Transfer/SyntaxToCore.hs | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/Transfer/SyntaxToCore.hs') diff --git a/src/Transfer/SyntaxToCore.hs b/src/Transfer/SyntaxToCore.hs index 586160ebe..b13579293 100644 --- a/src/Transfer/SyntaxToCore.hs +++ b/src/Transfer/SyntaxToCore.hs @@ -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. -- -- cgit v1.2.3