Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: marcotmarcot/haskell-src-exts-scoped-instances
base: 31d062a462
...
head fork: marcotmarcot/haskell-src-exts-scoped-instances
compare: master
  • 2 commits
  • 6 files changed
  • 0 commit comments
  • 1 contributor
2  src/Language/Haskell/Exts/Annotated/ExactPrint.hs
View
@@ -331,6 +331,7 @@ instance ExactP ExportSpec where
let k = length (srcInfoPoints l)
in exactP qn >> printInterleaved (zip (srcInfoPoints l) $ "(":replicate (k-2) "," ++ [")"]) cns
EModuleContents l mn -> printString "module" >> exactPC mn
+ EInstance l c t -> printString "instance" >> exactP c >> exactP t
instance ExactP ExportSpecList where
exactP (ExportSpecList l ess) =
@@ -356,6 +357,7 @@ instance ExactP ImportSpec where
IThingWith l n cns ->
let k = length (srcInfoPoints l)
in exactP n >> printInterleaved (zip (srcInfoPoints l) $ "(":replicate (k-2) "," ++ [")"]) cns
+ IInstance l c t -> printString "instance" >> exactP c >> exactP t
instance ExactP ImportDecl where
exactP (ImportDecl l mn qf src mpkg mas mispecs) = do
2  src/Language/Haskell/Exts/Annotated/Simplify.hs
View
@@ -171,6 +171,7 @@ sExportSpec es = case es of
EThingAll _ qn -> S.EThingAll (sQName qn)
EThingWith _ qn cns -> S.EThingWith (sQName qn) (map sCName cns)
EModuleContents _ mn -> S.EModuleContents (sModuleName mn)
+ EInstance _ c t -> S.EInstance (sQName c) (sQName t)
sImportDecl :: SrcInfo loc => ImportDecl loc -> S.ImportDecl
sImportDecl (ImportDecl l mn qu src mpkg as misl) =
@@ -185,6 +186,7 @@ sImportSpec is = case is of
IAbs _ n -> S.IAbs (sName n)
IThingAll _ n -> S.IThingAll (sName n)
IThingWith _ n cns -> S.IThingWith (sName n) (map sCName cns)
+ IInstance _ c t -> S.IInstance (sName c) (sName t)
sAssoc :: Assoc l -> S.Assoc
sAssoc a = case a of
8 src/Language/Haskell/Exts/Annotated/Syntax.hs
View
@@ -247,6 +247,7 @@ data ExportSpec l
-- a datatype exported with some of its constructors.
| EModuleContents l (ModuleName l) -- ^ @module M@:
-- re-export a module.
+ | EInstance l (QName l) (QName l)
#ifdef __GLASGOW_HASKELL__
deriving (Eq,Ord,Show,Typeable,Data)
#else
@@ -294,6 +295,7 @@ data ImportSpec l
| IThingWith l (Name l) [CName l] -- ^ @T(C_1,...,C_n)@:
-- a class imported with some of its methods, or
-- a datatype imported with some of its constructors.
+ | IInstance l (Name l) (Name l)
#ifdef __GLASGOW_HASKELL__
deriving (Eq,Ord,Show,Typeable,Data)
#else
@@ -1173,6 +1175,7 @@ instance Functor ExportSpec where
EThingAll l qn -> EThingAll (f l) (fmap f qn)
EThingWith l qn cns -> EThingWith (f l) (fmap f qn) (map (fmap f) cns)
EModuleContents l mn -> EModuleContents (f l) (fmap f mn)
+ EInstance l c t -> EInstance (f l) (fmap f c) (fmap f t)
instance Functor ImportDecl where
fmap f (ImportDecl l mn qual src pkg mmn mis) =
@@ -1187,6 +1190,7 @@ instance Functor ImportSpec where
IAbs l n -> IAbs (f l) (fmap f n)
IThingAll l n -> IThingAll (f l) (fmap f n)
IThingWith l n cns -> IThingWith (f l) (fmap f n) (map (fmap f) cns)
+ IInstance l c t -> IInstance (f l) (fmap f c) (fmap f t)
instance Functor Assoc where
fmap f (AssocNone l) = AssocNone (f l)
@@ -1629,12 +1633,14 @@ instance Annotated ExportSpec where
EThingAll l qn -> l
EThingWith l qn cns -> l
EModuleContents l mn -> l
+ EInstance l c t -> l
amap f es = case es of
EVar l qn -> EVar (f l) qn
EAbs l qn -> EAbs (f l) qn
EThingAll l qn -> EThingAll (f l) qn
EThingWith l qn cns -> EThingWith (f l) qn cns
EModuleContents l mn -> EModuleContents (f l) mn
+ EInstance l c t -> EInstance (f l) c t
instance Annotated ImportDecl where
ann (ImportDecl l mn qual src pkg mmn mis) = l
@@ -1651,11 +1657,13 @@ instance Annotated ImportSpec where
IAbs l n -> l
IThingAll l n -> l
IThingWith l n cns -> l
+ IInstance l c t -> l
amap f is = case is of
IVar l n -> IVar (f l) n
IAbs l n -> IAbs (f l) n
IThingAll l n -> IThingAll (f l) n
IThingWith l n cns -> IThingWith (f l) n cns
+ IInstance l c t -> IInstance (f l) c t
instance Annotated Assoc where
ann (AssocNone l) = l
2  src/Language/Haskell/Exts/InternalParser.ly
View
@@ -390,6 +390,7 @@ The Export List
> | qtyconorcls '(' ')' { EThingWith (ann $1 <++> nIS $3 <** [$2,$3]) $1 [] }
> | qtyconorcls '(' cnames ')' { EThingWith (ann $1 <++> nIS $4 <** ($2:reverse (snd $3) ++ [$4])) $1 (reverse (fst $3)) }
> | 'module' modid { EModuleContents (nIS $1 <++> ann $2 <** [$1]) $2 }
+> | 'instance' qtyconorcls qtyconorcls { EInstance (ann $2) $2 $3 }
-----------------------------------------------------------------------------
Import Declarations
@@ -449,6 +450,7 @@ Requires the PackageImports extension enabled.
> | tyconorcls '(' '..' ')' { IThingAll (ann $1 <++> nIS $4 <** [$2,$3,$4]) $1 }
> | tyconorcls '(' ')' { IThingWith (ann $1 <++> nIS $3 <** [$2,$3]) $1 [] }
> | tyconorcls '(' cnames ')' { IThingWith (ann $1 <++> nIS $4 <** ($2:reverse (snd $3) ++ [$4])) $1 (reverse (fst $3)) }
+> | 'instance' tyconorcls tyconorcls { IInstance (ann $2) $2 $3 }
> cnames :: { ([CName L],[S]) }
> : cnames ',' cname { ($3 : fst $1, $2 : snd $1) }
3  src/Language/Haskell/Exts/Pretty.hs
View
@@ -297,6 +297,8 @@ instance Pretty ExportSpec where
pretty (EThingWith name nameList) =
pretty name <> (parenList . map pretty $ nameList)
pretty (EModuleContents m) = text "module" <+> pretty m
+ pretty (EInstance c t)
+ = text "instance" <+> pretty c <+> pretty t
instance Pretty ImportDecl where
pretty (ImportDecl pos m qual src mbPkg mbName mbSpecs) =
@@ -319,6 +321,7 @@ instance Pretty ImportSpec where
pretty (IThingAll name) = pretty name <> text "(..)"
pretty (IThingWith name nameList) =
pretty name <> (parenList . map pretty $ nameList)
+ pretty (IInstance c t) = text "instance" <+> pretty c <+> pretty t
------------------------- Declarations ------------------------------
instance Pretty Decl where
2  src/Language/Haskell/Exts/Syntax.hs
View
@@ -220,6 +220,7 @@ data ExportSpec
-- a datatype exported with some of its constructors.
| EModuleContents ModuleName -- ^ @module M@:
-- re-export a module.
+ | EInstance QName QName
#ifdef __GLASGOW_HASKELL__
deriving (Eq,Ord,Show,Typeable,Data)
#else
@@ -257,6 +258,7 @@ data ImportSpec
| IThingWith Name [CName] -- ^ @T(C_1,...,C_n)@:
-- a class imported with some of its methods, or
-- a datatype imported with some of its constructors.
+ | IInstance Name Name
#ifdef __GLASGOW_HASKELL__
deriving (Eq,Ord,Show,Typeable,Data)
#else

No commit comments for this range

Something went wrong with that request. Please try again.