Is there already a list class?
David Roundy
droundy at darcs.net
Tue Jan 9 21:35:03 EST 2007
On Tue, Jan 09, 2007 at 05:54:11PM -0800, David Roundy wrote:
> I think you'd want a higher-kinded list type rather than a MPTC:
>
> class List l where
> cons :: e -> l e -> l e -- you can't make a constructor a member of a class
> head :: l e -> e
> null :: l e -> Bool
> empty :: l e
> ...
Okay, this was stupid of me. As Spencer points out, we wouldn't actually
want a list type with kind * -> *, because we'd want to support specialized
lists like Data.Bytestring. So we'd want something more like
> class List l e, l -> e where
> cons :: e -> l -> l
> head :: l -> e
> null :: l -> Bool
> empty :: l
> ...
(But I don't like functional dependencies, because they confuse me, and
hope that associated types end up making it into Haskell'...)
--
David Roundy
http://www.darcs.net
More information about the Libraries
mailing list