
Jason Dagit
On Thu, Aug 19, 2010 at 6:26 AM, Ivan Lazar Miljenovic < ivan.miljenovic@gmail.com> wrote:
I'm trying to update container-classes to duplicate the pre-existing classes defined in the Prelude (Functor, etc.) and am trying to get my approach on how to have functions/classes that work on types of kind * (e.g. Bytestring) as well as kind * -> * (e.g. lists), as my previous approach didn't work.
This is exactly why the iteratee library provides a newtype wrapper around ByteString that adds a phantom type.
If I recall correctly, it looks like this (and probably adds some derived instances): newtype WrappedByteString a = WBS ByteString
Haskell isn't friendly when it comes to kind polymorphism and I've never really seen a "solution" for it that I like.
And the above is actually something that may provide a nice addition to ByteString. You could track the encoding in the phantom type, potentially.
Except then the value that it contains is expected to be what that phantom type is, rather than a Word8. As such, the Foldable instance will be wrong, etc. -- Ivan Lazar Miljenovic Ivan.Miljenovic@gmail.com IvanMiljenovic.wordpress.com