[commit: ghc] wip/T8584: Show foralls (when requested) in pattern synonym types (597f3cc)

git at git.haskell.org git at git.haskell.org
Thu Oct 16 14:24:21 UTC 2014


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

On branch  : wip/T8584
Link       : http://ghc.haskell.org/trac/ghc/changeset/597f3cc21ad5f29d76b74ef10c3625b748e67595/ghc

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

commit 597f3cc21ad5f29d76b74ef10c3625b748e67595
Author: Dr. ERDI Gergo <gergo at erdi.hu>
Date:   Sun Aug 3 15:26:13 2014 +0200

    Show foralls (when requested) in pattern synonym types


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

597f3cc21ad5f29d76b74ef10c3625b748e67595
 compiler/hsSyn/HsBinds.lhs  | 21 ++++++---------------
 compiler/iface/IfaceSyn.lhs |  9 +++++----
 2 files changed, 11 insertions(+), 19 deletions(-)

diff --git a/compiler/hsSyn/HsBinds.lhs b/compiler/hsSyn/HsBinds.lhs
index 673a269..74b5187 100644
--- a/compiler/hsSyn/HsBinds.lhs
+++ b/compiler/hsSyn/HsBinds.lhs
@@ -710,24 +710,18 @@ ppr_sig (SpecSig var ty inl)      = pragBrackets (pprSpec (unLoc var) (ppr ty) i
 ppr_sig (InlineSig var inl)       = pragBrackets (ppr inl <+> pprPrefixOcc (unLoc var))
 ppr_sig (SpecInstSig ty)          = pragBrackets (ptext (sLit "SPECIALIZE instance") <+> ppr ty)
 ppr_sig (MinimalSig bf)           = pragBrackets (pprMinimalSig bf)
-ppr_sig (PatSynSig name arg_tys ty (_, _, prov) (_, _, req))
+ppr_sig (PatSynSig name arg_tys ty prov req)
   = pprPatSynSig (unLoc name) False args (ppr ty) (pprCtx prov) (pprCtx req)
   where
     args = fmap ppr arg_tys
 
-    pprCtx lctx = case unLoc lctx of
-        [] -> Nothing
-        ctx -> Just (pprHsContextNoArrow ctx)
+    pprCtx (flag, tvs, lctx) = pprHsForAll flag tvs lctx
 
 pprPatSynSig :: (OutputableBndr a)
-             => a -> Bool -> HsPatSynDetails SDoc -> SDoc -> Maybe SDoc -> Maybe SDoc -> SDoc
-pprPatSynSig ident is_bidir args rhs_ty prov_theta req_theta
-  = sep [ ptext (sLit "pattern")
-        , ptext (sLit "type")
-        , thetaOpt prov_theta, name_and_args
-        , colon
-        , thetaOpt req_theta, rhs_ty
-        ]
+             => a -> Bool -> HsPatSynDetails SDoc -> SDoc -> SDoc -> SDoc -> SDoc
+pprPatSynSig ident is_bidir args rhs_ty prov req
+  = ptext (sLit "pattern type") <+>
+    prov <+> name_and_args <+> colon <+> req <+> rhs_ty
   where
     name_and_args = case args of
         PrefixPatSyn arg_tys ->
@@ -735,9 +729,6 @@ pprPatSynSig ident is_bidir args rhs_ty prov_theta req_theta
         InfixPatSyn left_ty right_ty ->
             left_ty <+> pprInfixOcc ident <+> right_ty
 
-    -- TODO: support explicit foralls
-    thetaOpt = maybe empty (<+> darrow)
-
     colon = if is_bidir then dcolon else dcolon -- TODO
 
 instance OutputableBndr name => Outputable (FixitySig name) where
diff --git a/compiler/iface/IfaceSyn.lhs b/compiler/iface/IfaceSyn.lhs
index 935b8ed..e595266 100644
--- a/compiler/iface/IfaceSyn.lhs
+++ b/compiler/iface/IfaceSyn.lhs
@@ -771,11 +771,13 @@ pprIfaceDecl ss (IfaceSyn { ifName = tycon, ifTyVars = tyvars
 
 pprIfaceDecl _ (IfacePatSyn { ifName = name, ifPatWrapper = wrapper,
                               ifPatIsInfix = is_infix,
-                              ifPatUnivTvs = _univ_tvs, ifPatExTvs = _ex_tvs,
+                              ifPatUnivTvs = univ_tvs, ifPatExTvs = ex_tvs,
                               ifPatProvCtxt = prov_ctxt, ifPatReqCtxt = req_ctxt,
                               ifPatArgs = args,
                               ifPatTy = ty })
-  = pprPatSynSig name has_wrap args' ty' (pprCtxt prov_ctxt) (pprCtxt req_ctxt)
+  = pprPatSynSig name has_wrap args' ty'
+                 (pprCtxt ex_tvs prov_ctxt)
+                 (pprCtxt univ_tvs req_ctxt)
   where
     has_wrap = isJust wrapper
     args' = case (is_infix, args) of
@@ -786,8 +788,7 @@ pprIfaceDecl _ (IfacePatSyn { ifName = name, ifPatWrapper = wrapper,
 
     ty' = pprParendIfaceType ty
 
-    pprCtxt [] = Nothing
-    pprCtxt ctxt = Just $ pprIfaceContext ctxt
+    pprCtxt tvs ctxt = pprIfaceForAllPart tvs ctxt empty
 
 pprIfaceDecl ss (IfaceId { ifName = var, ifType = ty,
                               ifIdDetails = details, ifIdInfo = info })



More information about the ghc-commits mailing list