[Haskell-cafe] Restricted type classes

Ivan Lazar Miljenovic ivan.miljenovic at gmail.com
Fri Sep 3 08:29:29 EDT 2010


On 3 September 2010 22:23, John Lato <jwlato at gmail.com> wrote:
>> 1) How should I name the kind * versions?  For example, the kind *
>> version of Functor is currently called Mappable with a class method of
>> rigidMap.  What should I call the kind * version of Foldable and its
>> corresponding methods?  Is there a valid system I can use for these?
>
> You could prefix (or postfix) classes with an 'R' similar to RMonad, but
> that would conflict with the rmonad package.  For just Foldable, maybe
> Reduceable?

Well, I wanted the kind * -> * versions to have the same names as the
ones in base so that they're kinda drop-in.

> Do you have a kind * implementation of Foldable?  I'd be interested in
> seeing it, because I was unable to create a usable implementation (based
> upon the RMonad scheme) on my last attempt.

I was going to make it a subset of Foldable: fold, foldr, foldl, etc.

>> 2) How far should I go?  Should I restrict myself to the
>> "data-oriented" classes such as Functor, Traversable, etc. or should I
>> try to make restricted versions of Applicative and Monad?  Assuming I
>> should:
>
> I don't have a strong opinion either way, but could you re-use RMonad and
> RFunctor from the rmonad package?

Well, I could except that I didn't want the `R' prefix.  Also, if I
end up putting in the Applicative constraint, etc. for Monad then I
obviously can't re-use RMonad.

>> 2c) Should I keep the classes as-is, or should I explicitly put in the
>> constraints mentioned in the Typeclassopedia (e.g. make Applicative an
>> explicit superclass of Monad, and define return = pure for
>> compatability reasons)?  If so, should I bring over Pointed, etc. from
>> category-extras to round out the set or just stick with classes that
>> are already in base?
>
> +1 for using the proper constraints, and especially for bringing over
> Pointed (and anything else that applies).

That's one vote for...

>> 3) Am I wasting my time with this?
>
>
> I would find it useful, and I appreciate all the care you're putting into
> the design.

Oh, good, so I'm not going to be the only user of this library...

-- 
Ivan Lazar Miljenovic
Ivan.Miljenovic at gmail.com
IvanMiljenovic.wordpress.com


More information about the Haskell-Cafe mailing list