[Haskell-cafe] The difficulty of designing a sequence class
zednenem at psualum.com
Mon Jul 31 19:21:33 EDT 2006
Brian Hulley writes:
> 1) Did Edison choose MonadPlus just because this fitted in with the
> lack of multi-parameter typeclasses in H98?
Instances of Monoid (and your ISeq) have kind *. Instances of MonadPlus
(and Edison's Sequence) have kind * -> *.
Functions like map, zip, and their variants are best defined in terms of
With Sequence, you have
zipWith :: (Sequence s) => (a -> b -> c) -> s a -> s b -> s c
With ISeq, you'd have to do something like
zipWith :: (ISeq s1 a, ISeq s2 b, ISeq s3 c) =>
(a -> b -> c) -> s1 -> s2 -> s3
which isn't able to make any assumptions about s1, s2, and s3 having the
> 3) Is it worth bothering to derive ISeq from Monoid (with the
> possible extra inefficiency of the indirection through the
> definitions for append = mappend etc or does the compiler completely
> optimize this out)?
I would expect the compiler to inline append.
> 4) Would it be worth reconsidering the rules for top level names so
> that class methods could always be local to their class (ditto for
> value constructors and field names being local to their type
Qualified module imports are the way to go, here. Do you really want to
start writing "if x Eq/== y Num/+ 1 then ... "?
David Menendez <zednenem at psualum.com> | "In this house, we obey the laws
<http://www.eyrie.org/~zednenem> | of thermodynamics!"
More information about the Haskell-Cafe