[Haskell-cafe] Alternative to newtypes or orphan instances

Sean Leather sean.leather at gmail.com
Mon Aug 24 11:50:55 UTC 2015


On Mon, Aug 24, 2015 at 1:37 PM, Clinton Mead wrote:

> I see the problem now Sean. So in your example, is this correct:
>
> "To use the machinery of 'Show', I have to add and instance Show T. But
> that would be an orphan instance. So there is no way for T to use show
> machinery without adding an orphan instance (aside from modifying a module
> not under your control)?"
>

Correct.

Even newtype doesn't seem to help in your example. Show has all this
> machinery, but it seems completely unusable without adding an orphan
> instance or re-writing other people's modules. Is there no other way? This
> situation seems incredibly against re-usability, which I thought was
> Haskell's strength. Am I missing something?
>

Orphan instances are one of unfortunate pain points of Haskell, though they
are sometimes a necessary “evil.” Erik's first response describes a common
technique for publishing and sharing orphan instances. See, for example,
https://hackage.haskell.org/packages/search?terms=instances .

Regards,
Sean
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/haskell-cafe/attachments/20150824/7d2f8e08/attachment.html>


More information about the Haskell-Cafe mailing list