X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FhsSyn%2FHsPat.lhs;h=aa1568d27fe1066cb8dd5ffe1699b471e779cbd4;hb=8053aac536c96dabdc06e9f068852f5481474a29;hp=5bb443b8e37c29f660335c884b4a871f66b84980;hpb=108361d05dfb0aa37871c2c6a4ddec45a1b68010;p=ghc-hetmet.git diff --git a/compiler/hsSyn/HsPat.lhs b/compiler/hsSyn/HsPat.lhs index 5bb443b..aa1568d 100644 --- a/compiler/hsSyn/HsPat.lhs +++ b/compiler/hsSyn/HsPat.lhs @@ -22,7 +22,8 @@ module HsPat ( import {-# SOURCE #-} HsExpr ( SyntaxExpr ) -- friends: -import HsBinds ( DictBinds, HsBind(..), ExprCoFn, isIdCoercion, emptyLHsBinds, pprLHsBinds ) +import HsBinds ( DictBinds, HsBind(..), ExprCoFn, isIdCoercion, pprCoFn, + emptyLHsBinds, pprLHsBinds ) import HsLit ( HsLit(HsCharPrim), HsOverLit ) import HsTypes ( LHsType, PostTcType ) import BasicTypes ( Boxity, tupleParens ) @@ -121,14 +122,16 @@ data Pat id ------------ Dictionary patterns (translation only) --------------- | DictPat -- Used when destructing Dictionaries with an explicit case - [id] -- superclass dicts - [id] -- methods + [id] -- Superclass dicts + [id] -- Methods ------------ Pattern coercions (translation only) --------------- | CoPat ExprCoFn -- If co::t1 -> t2, p::t2, -- then (CoPat co p) :: t1 - (Pat id) -- No nested location reqd - Type + (Pat id) -- Why not LPat? Ans: existing locn will do + Type + -- During desugaring a (CoPat co pat) turns into a cast with 'co' on + -- the scrutinee, followed by a match on 'pat' \end{code} HsConDetails is use both for patterns and for data type declarations @@ -192,7 +195,7 @@ pprPat (NPat l Nothing _ _) = ppr l pprPat (NPat l (Just _) _ _) = char '-' <> ppr l pprPat (NPlusKPat n k _ _) = hcat [ppr n, char '+', ppr k] pprPat (TypePat ty) = ptext SLIT("{|") <> ppr ty <> ptext SLIT("|}") -pprPat (CoPat co pat _) = parens (ppr co) <+> ptext SLIT("`cast`") <+> ppr pat +pprPat (CoPat co pat _) = parens (pprCoFn (ppr pat) co) pprPat (SigPatIn pat ty) = ppr pat <+> dcolon <+> ppr ty pprPat (SigPatOut pat ty) = ppr pat <+> dcolon <+> ppr ty pprPat (DictPat ds ms) = parens (sep [ptext SLIT("{-dict-}"),