diff options
Diffstat (limited to 'compiler/basicTypes/BasicTypes.hs')
-rw-r--r-- | compiler/basicTypes/BasicTypes.hs | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/compiler/basicTypes/BasicTypes.hs b/compiler/basicTypes/BasicTypes.hs index 7fe4cb9c54..9711edb75a 100644 --- a/compiler/basicTypes/BasicTypes.hs +++ b/compiler/basicTypes/BasicTypes.hs @@ -19,7 +19,7 @@ types that module BasicTypes( Version, bumpVersion, initialVersion, - ConTag, fIRST_TAG, + ConTag, ConTagZ, fIRST_TAG, Arity, RepArity, @@ -49,6 +49,8 @@ module BasicTypes( TupleSort(..), tupleSortBoxity, boxityTupleSort, tupleParens, + sumParens, pprAlternative, + -- ** The OneShotInfo type OneShotInfo(..), noOneShotInfo, hasNoOneShotInfo, isOneShotInfo, @@ -132,6 +134,9 @@ type RepArity = Int -- or superclass selector type ConTag = Int +-- | A *zero-indexed* constructor tag +type ConTagZ = Int + fIRST_TAG :: ConTag -- ^ Tags are allocated from here for real constructors -- or for superclass selectors @@ -619,6 +624,27 @@ tupleParens ConstraintTuple p -- In debug-style write (% Eq a, Ord b %) {- ************************************************************************ * * + Sums +* * +************************************************************************ +-} + +sumParens :: SDoc -> SDoc +sumParens p = ptext (sLit "(#") <+> p <+> ptext (sLit "#)") + +-- | Pretty print an alternative in an unboxed sum e.g. "| a | |". +pprAlternative :: (a -> SDoc) -- ^ The pretty printing function to use + -> a -- ^ The things to be pretty printed + -> ConTag -- ^ Alternative (one-based) + -> Arity -- ^ Arity + -> SDoc -- ^ 'SDoc' where the alternative havs been pretty + -- printed and finally packed into a paragraph. +pprAlternative pp x alt arity = + fsep (replicate (alt - 1) vbar ++ [pp x] ++ replicate (arity - alt - 1) vbar) + +{- +************************************************************************ +* * \subsection[Generic]{Generic flag} * * ************************************************************************ |