[commit: ghc] wip/new-flatten-skolems-Oct14: White space only (d91da6a)

git at git.haskell.org git at git.haskell.org
Thu Oct 30 12:54:10 UTC 2014


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/new-flatten-skolems-Oct14
Link       : http://ghc.haskell.org/trac/ghc/changeset/d91da6a7006c098bdbb6b676ae85d63d63bd1fd6/ghc

>---------------------------------------------------------------

commit d91da6a7006c098bdbb6b676ae85d63d63bd1fd6
Author: Simon Peyton Jones <simonpj at microsoft.com>
Date:   Wed Oct 29 16:27:50 2014 +0000

    White space only


>---------------------------------------------------------------

d91da6a7006c098bdbb6b676ae85d63d63bd1fd6
 compiler/main/PprTyThing.hs       |  2 +-
 compiler/typecheck/Inst.lhs       | 96 +++++++++++++++++++++------------------
 compiler/typecheck/TcDeriv.lhs    |  6 +--
 compiler/typecheck/TcGenDeriv.lhs |  2 +-
 compiler/types/InstEnv.lhs        |  4 +-
 5 files changed, 59 insertions(+), 51 deletions(-)

diff --git a/compiler/main/PprTyThing.hs b/compiler/main/PprTyThing.hs
index eed4671..240e63b 100644
--- a/compiler/main/PprTyThing.hs
+++ b/compiler/main/PprTyThing.hs
@@ -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
diff --git a/compiler/typecheck/Inst.lhs b/compiler/typecheck/Inst.lhs
index 3405fd4..89955bf 100644
--- a/compiler/typecheck/Inst.lhs
+++ b/compiler/typecheck/Inst.lhs
@@ -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))
diff --git a/compiler/typecheck/TcDeriv.lhs b/compiler/typecheck/TcDeriv.lhs
index 1ef3ab4..b39739d 100644
--- a/compiler/typecheck/TcDeriv.lhs
+++ b/compiler/typecheck/TcDeriv.lhs
@@ -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:"))
@@ -2041,7 +2041,7 @@ genDerivStuff loc clas dfun_name tycon comaux_maybe
         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
diff --git a/compiler/typecheck/TcGenDeriv.lhs b/compiler/typecheck/TcGenDeriv.lhs
index e416aaf..31e31ed 100644
--- a/compiler/typecheck/TcGenDeriv.lhs
+++ b/compiler/typecheck/TcGenDeriv.lhs
@@ -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
diff --git a/compiler/types/InstEnv.lhs b/compiler/types/InstEnv.lhs
index 1e7e023..6d03fbe 100644
--- a/compiler/types/InstEnv.lhs
+++ b/compiler/types/InstEnv.lhs
@@ -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



More information about the ghc-commits mailing list