On 9/6/10 2:35 AM, Ivan Lazar Miljenovic wrote:
Well, if we consider what this does, pure is equivalent to singleton
for container types.  The actual definition of pure (or any other
aspect of Pointed) doesn't require Functor; however there are
properties for types that are instances of Functor and Pointed.

Right, that's what I was meaning to highlight. If we were doing this in Coq, for example, then not having Functor as a superclass of Pointed would mean that we'd need a third class PointedFunctor which has both as superclasses. In Haskell, since we don't have proofs, PointedFunctor wouldn't have any methods and would therefore just be unnecessary complication. Though this raises the question of which one makes more sense to keep around: Pointed (with no superclass), or PointedFunctor.


So, from a proof/testing POV having Functor as a superclass is nice;
from an implementation POV it doesn't seem to be needed.

Though, again, I wonder what the use case would be. Your example of singleton collections doesn't seem quite right. I'd expect the singleton functions to obey various "spatial" laws (i.e., module-like or vector space-like laws). For example,

    union (singleton a) x = insert a x

This isn't exactly like Applicative because 'a' is an element instead of a function. And it's not quite like Alternative either, since it only requires union to be a semigroup instead of a monoid.

However, I can see some pointed functors that don't have this law, either because insert or union don't make sense or because the obvious implementations don't fit the pattern. Consider, for instance, the ZipList applicative functor which has pure=repeat. It satisfies the pointed law just fine, but it's not clear what insert or union should mean (interleaving, perhaps? It still wouldn't be an Alternative though).

Perhaps this just means that union/insert should be part of some other class. Of course, I'd expect singleton to obey the pointed law as well, so that other class would (most likely) be a subclass of pointed functors. In any case, it does mean there's something of a mismatch between singleton vs return/pure/point/unit.

--
Live well,
~wren
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to