[Haskell-cafe] Problem on overlapping instances

Stephen Tetley stephen.tetley at gmail.com
Wed Jan 5 09:41:18 CET 2011

You have two choices (other people have enumerated the first while I
was typing):

First choice:

Wrap your Stringlist with a newtype:

newtype StringList = StringList [String]

The downside of this your code gets "polluted" with the newtype.

Second choice:

Write special putStringList and getStringList functions. Hand-code the
binary instances where you are wanting [String] to be special and call
putStringList and getStringList rather than put and get.

Downside - cannot automatically derive Binary. That's if Binary can be
automatically derived anyway?, the times when I need Binary I write
the instances myself anyway.

More information about the Haskell-Cafe mailing list