diff options
author | Iavor S. Diatchki <iavor.diatchki@gmail.com> | 2014-07-27 13:02:37 -0700 |
---|---|---|
committer | Iavor S. Diatchki <iavor.diatchki@gmail.com> | 2014-07-27 13:03:05 -0700 |
commit | 97f499b56c5888740ddb147fb198c28a3c06bac7 (patch) | |
tree | 98a1dc54c41d79b0ecd5ec9f3c3ae2ee6bdfaa86 /compiler/hsSyn/HsDecls.lhs | |
parent | 9487305393307d5eb34069c5821c11bb98b5ec90 (diff) | |
download | haskell-97f499b56c5888740ddb147fb198c28a3c06bac7.tar.gz |
Implement OVERLAPPING and OVERLAPPABLE pragmas (see #9242)
This also removes the short-lived NO_OVERLAP pragama, and renames
OVERLAP to OVERLAPS.
An instance may be annotated with one of 4 pragams, to control its
interaction with other overlapping instances:
* OVERLAPPABLE:
this instance is ignored if a more specific candidate exists
* OVERLAPPING:
this instance is preferred over more general candidates
* OVERLAPS:
both OVERLAPPING and OVERLAPPABLE (i.e., the previous GHC behavior).
When compiling with -XOverlappingInstances, all instance are OVERLAPS.
* INCOHERENT:
same as before (see manual for details).
When compiling with -XIncoherentInstances, all instances are INCOHERENT.
Diffstat (limited to 'compiler/hsSyn/HsDecls.lhs')
-rw-r--r-- | compiler/hsSyn/HsDecls.lhs | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/compiler/hsSyn/HsDecls.lhs b/compiler/hsSyn/HsDecls.lhs index 845c05296c..313dccccd5 100644 --- a/compiler/hsSyn/HsDecls.lhs +++ b/compiler/hsSyn/HsDecls.lhs @@ -1055,16 +1055,18 @@ instance (OutputableBndr name) => Outputable (ClsInstDecl name) where map (pprDataFamInstDecl NotTopLevel . unLoc) adts ++ pprLHsBindsForUser binds sigs ] where - top_matter = ptext (sLit "instance") <+> ppOveralapPragma mbOverlap + top_matter = ptext (sLit "instance") <+> ppOverlapPragma mbOverlap <+> ppr inst_ty -ppOveralapPragma :: Maybe OverlapMode -> SDoc -ppOveralapPragma mb = +ppOverlapPragma :: Maybe OverlapMode -> SDoc +ppOverlapPragma mb = case mb of - Nothing -> empty - Just NoOverlap -> ptext (sLit "{-# NO_OVERLAP #-}") - Just OverlapOk -> ptext (sLit "{-# OVERLAP #-}") - Just Incoherent -> ptext (sLit "{-# INCOHERENT #-}") + Nothing -> empty + Just NoOverlap -> ptext (sLit "{-# NO_OVERLAP #-}") + Just Overlappable -> ptext (sLit "{-# OVERLAPPABLE #-}") + Just Overlapping -> ptext (sLit "{-# OVERLAPPING #-}") + Just Overlaps -> ptext (sLit "{-# OVERLAPS #-}") + Just Incoherent -> ptext (sLit "{-# INCOHERENT #-}") @@ -1102,7 +1104,7 @@ data DerivDecl name = DerivDecl { deriv_type :: LHsType name instance (OutputableBndr name) => Outputable (DerivDecl name) where ppr (DerivDecl ty o) - = hsep [ptext (sLit "deriving instance"), ppOveralapPragma o, ppr ty] + = hsep [ptext (sLit "deriving instance"), ppOverlapPragma o, ppr ty] \end{code} %************************************************************************ |