def and List

This commit is contained in:
aarne
2005-10-02 19:50:19 +00:00
parent 74e7f84e0f
commit df4027f798
5 changed files with 58 additions and 26 deletions

View File

@@ -5,9 +5,9 @@
-- Stability : (stable)
-- Portability : (portable)
--
-- > CVS $Date: 2005/05/30 21:08:15 $
-- > CVS $Date: 2005/10/02 20:50:19 $
-- > CVS $Author: aarne $
-- > CVS $Revision: 1.26 $
-- > CVS $Revision: 1.27 $
--
-- based on the skeleton Haskell module generated by the BNF converter
-----------------------------------------------------------------------------
@@ -251,15 +251,20 @@ transCatDef x = case x of
cont <- liftM concat $ mapM transDDecl ddecls
return (i, G.AbsCat (yes cont) nope)
listCat id ddecls size = do
let li = mkListId id
catd <- cat li ddecls
let cd = M.mkDecl (G.Vr id)
lc = G.Vr li
niltyp = M.mkProdSimple (genericReplicate size cd) lc
nilfund = (mkBaseId id, G.AbsFun (yes niltyp) nope)
constyp = M.mkProdSimple [cd, M.mkDecl lc] lc
consfund = (mkConsId id, G.AbsFun (yes constyp) nope)
return [catd,nilfund,consfund]
let
li = mkListId id
catd@(_,G.AbsCat (Yes cont0) _) <- cat li ddecls
let
cont = [(mkId x i,ty) | (i,(x,ty)) <- zip [0..] cont0]
xs = map (G.Vr . fst) cont
cd = M.mkDecl (M.mkApp (G.Vr id) xs)
lc = M.mkApp (G.Vr li) xs
niltyp = M.mkProdSimple (cont ++ genericReplicate size cd) lc
nilfund = (mkBaseId id, G.AbsFun (yes niltyp) nope)
constyp = M.mkProdSimple (cont ++ [cd, M.mkDecl lc]) lc
consfund = (mkConsId id, G.AbsFun (yes constyp) nope)
return [catd,nilfund,consfund]
mkId x i = if isWildIdent x then (mkIdent "x" i) else x
transFunDef :: FunDef -> Err ([Ident], G.Type)
transFunDef x = case x of