[Haskell-cafe] Re: The Proliferation of List-Like Types

John Goerzen jgoerzen at complete.org
Wed Feb 20 13:43:48 EST 2008

On 2008-02-20, Jules Bean <jules at jellybean.co.uk> wrote:
> Not directly, no.
> The point about Foldable, Functor, and Monad, is that they enforce the 
> connection between container and contents. If the contents is of type 
> "a", the container is of type "f a" for a fixed type constructor 'f'. 
> This works for [], Seq, and so on, but fails for ByteString.

Right.  In a pure abstract sense, we humans know there is a
relationship between container and contents: a ByteString always
contains a Word8 (or a Char8 if we choose the alternative

But that is not expressed in the type of ByteString.

> However, passing around dictionaries is certainly a solution which works 
> in haskell98. I haven't thought it through enough to see if it would be 
> unpleasantly verbose in practice.

I'm not sure precisely what you mean here.  If you mean to use
dictionaries instead of typeclasses entirely, yes of course that would
work, but it would mean that the functions could not operate on the
underlying types unmodified, and once again compatibility issues may

On the other hand, if you mean using a dictionary to "wrap" just the
ByteString types (or other similar ones), I am currently thinking of
something along those lines.  I'll post here if I come up with
something clever (or not).

More information about the Haskell-Cafe mailing list