packages feed

core 0.1 → 0.2

raw patch · 4 files changed

+26/−28 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Language.Core.Syntax: type Vdef = (Bool, Qual Var, Ty, Exp)
+ Language.Core.Syntax: Vdef :: Bool -> Qual Var -> Ty -> Exp -> Vdef
+ Language.Core.Syntax: data Vdef
+ Language.Core.Syntax: instance Eq Alt
+ Language.Core.Syntax: instance Eq Bind
+ Language.Core.Syntax: instance Eq Cdef
+ Language.Core.Syntax: instance Eq Exp
+ Language.Core.Syntax: instance Eq Kind
+ Language.Core.Syntax: instance Eq Lit
+ Language.Core.Syntax: instance Eq Module
+ Language.Core.Syntax: instance Eq Tdef
+ Language.Core.Syntax: instance Eq Ty
+ Language.Core.Syntax: instance Eq Vdef
+ Language.Core.Syntax: instance Eq Vdefg
+ Language.Core.Syntax: instance Show Vdef
+ Language.Core.Syntax: vdefExp :: Vdef -> Exp
+ Language.Core.Syntax: vdefLocal :: Vdef -> Bool
+ Language.Core.Syntax: vdefName :: Vdef -> Qual Var
+ Language.Core.Syntax: vdefType :: Vdef -> Ty
- Language.Core.Syntax: type Vbind = (Var, Ty)
+ Language.Core.Syntax: type Vbind = (Qual Var, Ty)

Files

core.cabal view
@@ -1,5 +1,5 @@ name:                core-version:             0.1+version:             0.2 synopsis:            External core parser and pretty printer. description:         External core parser and pretty printer. category:            Language
src/Language/Core/Parser.hs view
@@ -139,15 +139,6 @@           , (L.pack "%", Percent)           ] -main :: IO ()-main = do inp <- L.readFile --"./hcr/Tuple.hcr"-                          --"./src/ExternalCore.hcr"-                          "../base.hcr"-          --print (length (lexer inp))-          --mapM_ print (lexer inp)-          parseTest (many1 moduleP >>= \m -> notFollowedBy anyToken >> return (map ppModule m) >> return ()) (lexer inp)-- parseModule :: SourceName -> L.ByteString -> Either ParseError Module parseModule src inp = runParser moduleP () src (lexer inp) @@ -156,7 +147,7 @@              pkg <- pkgname              matchToken Colon              modName <- mident-             trace (L.unpack modName) $ return ()+             --trace (L.unpack modName) $ return ()              tdefs <- tdef `endBy` (matchToken SColon)              vdefgs <- vdefg `endBy` (matchToken SColon)              return $ Module (pkg,modName) tdefs vdefgs@@ -174,7 +165,10 @@           t <- ty           matchToken Equal           e <- expP-          return (False, name, t, e)+          return $ Vdef { vdefLocal = False+                        , vdefName  = name+                        , vdefType  = t+                        , vdefExp   = e }        <?> "vdef"  expP = choice@@ -357,7 +351,7 @@ vbind = parens $ do v <- lname                     matchToken DColon                     t <- ty-                    return (v,t)+                    return ((L.empty,L.empty,v),t)   akind = choice [ matchToken Star >> return Klifted
src/Language/Core/Pretty.hs view
@@ -21,8 +21,8 @@ ppVdefg (Nonrec def)     = ppVdef def -ppVdef (_local, name, ty, expr)-    = ppQual name <+> text "::" <+> ppTy ty <+> equals $$ indent (ppExp expr)+ppVdef vdef -- (_local, name, ty, expr)+    = ppQual (vdefName vdef) <+> text "::" <+> ppTy (vdefType vdef) <+> equals $$ indent (ppExp (vdefExp vdef))  ppAexp, pfexp, ppExp :: Exp -> Doc ppAexp (Var x) = ppQual x@@ -63,7 +63,7 @@ ppExp e = pfexp e  pvbind :: Vbind -> Doc-pvbind (x,t) = parens(text (L.unpack x) <> text "::" <> ppTy t)+pvbind (x,t) = parens(ppQual x <> text "::" <> ppTy t)  palt :: Alt -> Doc palt (Acon c tbs vbs e) =
src/Language/Core/Syntax.lhs view
@@ -8,26 +8,30 @@  data Module  = Module (Pkgname, Mname) [Tdef] [Vdefg]-   deriving (Show)+   deriving (Show,Eq)  data Tdef    = Data (Qual Tcon) [Tbind] [Cdef]   | Newtype (Qual Tcon) (Qual Tcon) [Tbind] Ty-   deriving (Show)+   deriving (Show,Eq)  data Cdef    = Constr (Qual Dcon) [Tbind] [Ty]   | GadtConstr (Qual Dcon) Ty-   deriving (Show)+   deriving (Show,Eq)  data Vdefg    = Rec [Vdef]   | Nonrec Vdef-   deriving (Show)+   deriving (Show,Eq)  -- Top-level bindings are qualified, so that the printer doesn't have to pass -- around the module name.-type Vdef = (Bool,Qual Var,Ty,Exp)+data Vdef = Vdef { vdefLocal :: Bool+                 , vdefName  :: Qual Var+                 , vdefType  :: Ty+                 , vdefExp   :: Exp }+    deriving (Show,Eq)  data Exp    = Var (Qual Var)@@ -43,20 +47,20 @@   | External String String Ty {- target name, convention, and type -}    | DynExternal String Ty {- convention and type (incl. Addr# of target as first arg) -}    | Label String-   deriving (Show)+   deriving (Show,Eq)  data Bind    = Vb Vbind   | Tb Tbind-   deriving (Show)+   deriving (Show,Eq)  data Alt    = Acon (Qual Dcon) [Tbind] [Vbind] Exp   | Alit Lit Exp   | Adefault Exp-   deriving (Show)+   deriving (Show,Eq) -type Vbind = (Var,Ty)+type Vbind = (Qual Var,Ty) type Tbind = (Tvar,Kind)  data Ty @@ -74,7 +78,7 @@   | InstCoercion Ty Ty   | LeftCoercion Ty   | RightCoercion Ty-   deriving (Show)+   deriving (Show,Eq)  data Kind    = Klifted@@ -83,14 +87,14 @@   | Kopen   | Karrow Kind Kind   | Keq Ty Ty-   deriving (Show)+   deriving (Show,Eq)  data Lit    = Lint Integer Ty   | Lrational Rational Ty   | Lchar Char Ty   | Lstring String Ty-   deriving (Show)+   deriving (Show,Eq)     type Pkgname = Id