Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Accept instances on import lists.

  • Loading branch information...
commit 0dcaaa60cf3df3d954add6517b5bd4a94da22b55 1 parent 0186673
Marco Túlio Gontijo authored
1  src/Language/Haskell/Exts/Annotated/ExactPrint.hs
View
@@ -357,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
1  src/Language/Haskell/Exts/Annotated/Simplify.hs
View
@@ -186,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
4 src/Language/Haskell/Exts/Annotated/Syntax.hs
View
@@ -295,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
@@ -1189,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)
@@ -1655,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
1  src/Language/Haskell/Exts/InternalParser.ly
View
@@ -450,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) }
1  src/Language/Haskell/Exts/Pretty.hs
View
@@ -321,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
1  src/Language/Haskell/Exts/Syntax.hs
View
@@ -258,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
Please sign in to comment.
Something went wrong with that request. Please try again.