ekmett / pointed

pointed and copointed data
Other
23 stars 9 forks source link

Generic Pointed and Copointed #12

Closed RyanGlScott closed 9 years ago

RyanGlScott commented 9 years ago

This adds two modules allowing for Generic implementations of Pointed and Copointed instances. The algorithms for each are as follows:

These seem like reasonable assumptions to me, but let me know if you'd prefer it be implemented in a different way.

ekmett commented 9 years ago

This strikes me as fairly ad hoc.

ekmett commented 9 years ago

Note that e.g.

data Stream a = Stream a (Stream a)

actually does want the direct recursion for its pointed instance.

RyanGlScott commented 9 years ago

It is ad hoc, admittedly. I was trying to avoid scenarios like:

data Tree a = Node (Tree a) a (Tree a) | Leaf a

from never returning, and disallowing direct recursion was the most straightforward way. Of course, this won't work for certain things (list and streams being prime examples).

If this is unpalatable, I can easily remove it. Or, if you don't like the idea of generically creating Pointed instances at all, let me know—you won't hurt my feelings :)

ekmett commented 9 years ago

I think I'm going to decline the pull request for now.

It is rather gratuitous and unmotivated and encourages a "bad style" of going "point first" and not thinking about what is the point for your particular operation.