Combinators for Show

Ivan Lazar Miljenovic ivan.miljenovic at
Tue Jan 30 07:06:37 UTC 2018

On 30 January 2018 at 14:48, Li-yao Xia <lysxia at> wrote:
> Hello libraries,
> base contains a small combinator library for Read, but there doesn't seem to
> be a similar thing for Show. Offering a few more convenient helpers to avoid
> dealing with whitespace and especially precedence levels seems
> straightforward enough.
> Is there an API somewhere that I missed? Has there been a
> proposal/discussion about this before? I'm ready to make one otherwise.

Have you looked at the ShowS-based methods? They tend to be a bit more
combinator-y (though they don't cover whitespace).  For example,
here's the Show instance for Data.Graph.Inductive.Tree:

instance (Show a, Show b) => Show (Gr a b) where
  showsPrec d g = showParen (d > 10) $
                    showString "mkGraph "
                    . shows (labNodes g)
                    . showString " "
                    . shows (labEdges g)

> Li-yao
> _______________________________________________
> Libraries mailing list
> Libraries at

Ivan Lazar Miljenovic
Ivan.Miljenovic at

More information about the Libraries mailing list