Commit bdbb595c authored by Simon Peyton Jones's avatar Simon Peyton Jones
Browse files

White space only

parent d153e402
......@@ -128,7 +128,7 @@ pprTyThingInContextLoc tyThing
------------------------
ppr_ty_thing :: Bool -> [OccName] -> TyThing -> SDoc
-- We pretty-print 'TyThing' via 'IfaceDecl'
-- See Note [Pretty-pringint TyThings]
-- See Note [Pretty-printing TyThings]
ppr_ty_thing hdr_only path ty_thing
= pprIfaceDecl ss (tyThingToIfaceDecl ty_thing)
where
......
......@@ -473,52 +473,60 @@ addLocalInst (home_ie, my_insts) ispec
dupInstErr ispec (head dups)
; return (extendInstEnv home_ie' ispec, ispec:my_insts') }
\end{code}
Note [Signature files and type class instances]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Instances in signature files do not have an effect when compiling:
when you compile a signature against an implementation, you will
see the instances WHETHER OR NOT the instance is declared in
the file (this is because the signatures go in the EPS and we
can't filter them out easily.) This is also why we cannot
place the instance in the hi file: it would show up as a duplicate,
and we don't have instance reexports anyway.
However, you might find them useful when typechecking against
a signature: the instance is a way of indicating to GHC that
some instance exists, in case downstream code uses it.
Implementing this is a little tricky. Consider the following
situation (sigof03):
module A where
instance C T where ...
module ASig where
instance C T
When compiling ASig, A.hi is loaded, which brings its instances
into the EPS. When we process the instance declaration in ASig,
we should ignore it for the purpose of doing a duplicate check,
since it's not actually a duplicate. But don't skip the check
entirely, we still want this to fail (tcfail221):
module ASig where
instance C T
instance C T
-- Note [Signature files and type class instances]
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- Instances in signature files do not have an effect when compiling:
-- when you compile a signature against an implementation, you will
-- see the instances WHETHER OR NOT the instance is declared in
-- the file (this is because the signatures go in the EPS and we
-- can't filter them out easily.) This is also why we cannot
-- place the instance in the hi file: it would show up as a duplicate,
-- and we don't have instance reexports anyway.
--
-- However, you might find them useful when typechecking against
-- a signature: the instance is a way of indicating to GHC that
-- some instance exists, in case downstream code uses it.
--
-- Implementing this is a little tricky. Consider the following
-- situation (sigof03):
--
-- module A where
-- instance C T where ...
--
-- module ASig where
-- instance C T
--
-- When compiling ASig, A.hi is loaded, which brings its instances
-- into the EPS. When we process the instance declaration in ASig,
-- we should ignore it for the purpose of doing a duplicate check,
-- since it's not actually a duplicate. But don't skip the check
-- entirely, we still want this to fail (tcfail221):
--
-- module ASig where
-- instance C T
-- instance C T
--
-- Note that in some situations, the interface containing the type
-- class instances may not have been loaded yet at all. The usual
-- situation when A imports another module which provides the
-- instances (sigof02m):
--
-- module A(module B) where
-- import B
--
-- See also Note [Signature lazy interface loading]. We can't
-- rely on this, however, since sometimes we'll have spurious
-- type class instances in the EPS, see #9422 (sigof02dm)
Note that in some situations, the interface containing the type
class instances may not have been loaded yet at all. The usual
situation when A imports another module which provides the
instances (sigof02m):
module A(module B) where
import B
See also Note [Signature lazy interface loading]. We can't
rely on this, however, since sometimes we'll have spurious
type class instances in the EPS, see #9422 (sigof02dm)
%************************************************************************
%* *
Errors and tracing
%* *
%************************************************************************
\begin{code}
traceDFuns :: [ClsInst] -> TcRn ()
traceDFuns ispecs
= traceTc "Adding instances:" (vcat (map pp ispecs))
......
......@@ -402,8 +402,8 @@ tcDeriving tycl_decls inst_decls deriv_decls
; return (addTcgDUs gbl_env all_dus, inst_info, rn_binds) }
where
ddump_deriving :: Bag (InstInfo Name) -> HsValBinds Name
-> Bag TyCon -- ^ Empty data constructors
-> Bag (FamInst) -- ^ Rep type family instances
-> Bag TyCon -- ^ Empty data constructors
-> Bag FamInst -- ^ Rep type family instances
-> SDoc
ddump_deriving inst_infos extra_binds repMetaTys repFamInsts
= hang (ptext (sLit "Derived instances:"))
......@@ -2036,12 +2036,12 @@ genDerivStuff :: SrcSpan -> Class -> Name -> TyCon
genDerivStuff loc clas dfun_name tycon comaux_maybe
| let ck = classKey clas
, ck `elem` [genClassKey, gen1ClassKey] -- Special case because monadic
= let gk = if ck == genClassKey then Gen0 else Gen1
= let gk = if ck == genClassKey then Gen0 else Gen1
-- TODO NSF: correctly identify when we're building Both instead of One
Just metaTyCons = comaux_maybe -- well-guarded by commonAuxiliaries and genInst
in do
(binds, faminst) <- gen_Generic_binds gk tycon metaTyCons (nameModule dfun_name)
return (binds, DerivFamInst faminst `consBag` emptyBag)
return (binds, unitBag (DerivFamInst faminst))
| otherwise -- Non-monadic generators
= do dflags <- getDynFlags
......
......@@ -85,7 +85,7 @@ data DerivStuff -- Please add this auxiliary stuff
-- Generics
| DerivTyCon TyCon -- New data types
| DerivFamInst (FamInst) -- New type family instances
| DerivFamInst FamInst -- New type family instances
-- New top-level auxiliary bindings
| DerivHsBind (LHsBind RdrName, LSig RdrName) -- Also used for SYB
......
......@@ -161,8 +161,8 @@ pprInstance :: ClsInst -> SDoc
-- Prints the ClsInst as an instance declaration
pprInstance ispec
= hang (pprInstanceHdr ispec)
2 (vcat [ ptext (sLit "--") <+> pprDefinedAt (getName ispec)
, ifPprDebug (ppr (is_dfun ispec)) ])
2 (vcat [ ptext (sLit "--") <+> pprDefinedAt (getName ispec)
, ifPprDebug (ppr (is_dfun ispec)) ])
-- * pprInstanceHdr is used in VStudio to populate the ClassView tree
pprInstanceHdr :: ClsInst -> SDoc
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment