packages feed

core 0.3 → 0.4

raw patch · 4 files changed

+21/−22 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Language.Core.Syntax: Tb :: Tbind -> Bind
- Language.Core.Syntax: Vb :: Vbind -> Bind
- Language.Core.Syntax: data Bind
- Language.Core.Syntax: instance Eq Bind
- Language.Core.Syntax: instance Read Bind
- Language.Core.Syntax: instance Show Bind
+ Language.Core.Syntax: Lamt :: Tbind -> Exp -> Exp
+ Language.Core.Syntax: Tarrow :: Ty -> Ty -> Ty
- Language.Core.Syntax: Lam :: Bind -> Exp -> Exp
+ Language.Core.Syntax: Lam :: Vbind -> Exp -> Exp

Files

core.cabal view
@@ -1,5 +1,5 @@ name:                core-version:             0.3+version:             0.4 synopsis:            External core parser and pretty printer. description:         External core parser and pretty printer. category:            Language
src/Language/Core/Parser.hs view
@@ -158,7 +158,7 @@  vdefg = choice         [ do keyword "rec"-             braces $ liftM Rec (vdef `sepBy1` (matchToken SColon))+             braces $ liftM Rec (vdef `sepBy` (matchToken SColon))         , do v <- vdef              return $ Nonrec v         ] <?> "vdefg"@@ -184,7 +184,9 @@             binds <- many1 binder             matchToken Arrow             e <- expP-            return $ foldr Lam e binds+            let lam (Left t) e = Lamt t e+                lam (Right a) e = Lam a e+            return $ foldr lam e binds        , do keyword "case"             t <- aty             e <- expP@@ -237,8 +239,8 @@  binder = choice          [ do matchToken At-              liftM Tb tbind-         , liftM Vb vbind+              liftM Left tbind+         , liftM Right vbind          ] <?> "binder"  arg = choice@@ -336,7 +338,7 @@      , try $ do a <- bty                 matchToken Arrow                 b <- ty-                return (Tapp (Tapp (Tcon tcArrow) a) b)+                return (Tarrow a b)      , bty      ] 
src/Language/Core/Pretty.hs view
@@ -30,14 +30,15 @@ ppAexp (Lit l) = plit l ppAexp e = parens(ppExp e) -plamexp :: [Bind] -> Exp -> Doc-plamexp bs (Lam b e) = plamexp (bs ++ [b]) e+plamexp :: [Either Tbind Vbind] -> Exp -> Doc+plamexp bs (Lam b e) = plamexp (bs ++ [Right b]) e+plamexp bs (Lamt b e) = plamexp (bs ++ [Left b]) e plamexp bs e = sep [sep (map pbind bs) <+> text "->",                     indent (ppExp e)] -pbind :: Bind -> Doc-pbind (Tb tb) = char '@' <+> ppTbind tb-pbind (Vb vb) = pvbind vb+pbind :: Either Tbind Vbind -> Doc+pbind (Left tb) = char '@' <+> ppTbind tb+pbind (Right vb) = pvbind vb  pfexp (App e1 e2) = pappexp e1 [Left e2] pfexp (Appt e t) = pappexp e [Right t]@@ -50,7 +51,8 @@            where pa (Left e) = ppAexp e                  pa (Right t) = char '@' <+> ppAty t -ppExp (Lam b e) = char '\\' <+> plamexp [b] e+ppExp (Lam b e) = char '\\' <+> plamexp [Right b] e+ppExp (Lamt t e) = char '\\' <+> plamexp [Left t] e ppExp (Let vd e) = (text "%let" <+> ppVdefg vd) $$ (text "%in" <+> ppExp e) ppExp (Case e vb ty alts) = sep [text "%case" <+> ppAty ty <+> ppAexp e,                              text "%of" <+> pvbind vb]@@ -137,11 +139,11 @@ ppAty (Tcon c) = ppQual c ppAty t = parens (ppTy t) -ppBty (Tapp(Tapp(Tcon tc) t1) t2) | tc == tcArrow = parens(fsep [ppBty t1, text "->",ppTy t2])+ppBty (Tarrow t1 t2) = parens(fsep [ppBty t1, text "->",ppTy t2]) ppBty (Tapp t1 t2) = parens $ ppAppty t1 [t2]  ppBty t = ppAty t -ppTy (Tapp(Tapp(Tcon tc) t1) t2) | tc == tcArrow = fsep [ppBty t1, text "->",ppTy t2]+ppTy (Tarrow t1 t2) = fsep [ppBty t1, text "->",ppTy t2] ppTy (Tforall tb t) = text "%forall" <+> ppForall [tb] t ppTy (TransCoercion t1 t2) =   sep [text "%trans", ppAty t1, ppAty t2]
src/Language/Core/Syntax.lhs view
@@ -39,7 +39,8 @@   | Lit Lit   | App Exp Exp   | Appt Exp Ty-  | Lam Bind Exp 	  +  | Lam Vbind Exp+  | Lamt Tbind Exp   | Let Vdefg Exp   | Case Exp Vbind Ty [Alt] {- non-empty list -}   | Cast Exp Ty@@ -49,11 +50,6 @@   | Label String    deriving (Show,Read,Eq) -data Bind -  = Vb Vbind-  | Tb Tbind-   deriving (Show,Read,Eq)- data Alt    = Acon (Qual Dcon) [Tbind] [Vbind] Exp   | Alit Lit Exp@@ -67,6 +63,7 @@   = Tvar Tvar   | Tcon (Qual Tcon)   | Tapp Ty Ty+  | Tarrow Ty Ty   | Tforall Tbind Ty  -- We distinguish primitive coercions -- (represented in GHC by wired-in names), because@@ -107,8 +104,6 @@ type Qual t = (Pkgname, Mname,t)  type Id = L.ByteString--tcArrow = (L.pack "lhc",L.pack "Lhc.Arrow",L.pack "(->)")   \end{code}