<p dir="ltr">I have no comment on your higher-order version (because I don't understand it yet), but the type you give for hmap looks unlikely. Did you mean</p>
<p dir="ltr">hmap :: (g :-> h) -> f g :-> f h ?</p>
<div class="gmail_quote">On Mar 24, 2015 10:58 AM, "Erik Hesselink" <<a href="mailto:hesselink@gmail.com">hesselink@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Tue, Mar 24, 2015 at 7:23 AM, M Farkas-Dyck <<a href="mailto:strake888@gmail.com">strake888@gmail.com</a>> wrote:<br>
> On 22/03/2015 at 23:01:47 -0400, David Feuer wrote:<br>
>> There are a good number of different packages that define either<br>
>><br>
>> newtype Fix f = Fix (f (Fix f))<br>
>><br>
>> or something equivalent except for naming. Most of the name variation<br>
>> is in the name of the data constructor and/or record selector. This<br>
>> does not look like an ideal situation to me. Most problematically, the<br>
>> only way to convert one to another is with unsafeCoerce.<br>
>><br>
>> I think it would be rather nice to choose one canonical place for this<br>
>> definition, and let everyone else use it.<br>
><br>
> +1<br>
><br>
> I propose<br>
><br>
> module Data.Fix where<br>
><br>
> newtype Fix f = Fix { unFix :: f (Fix f) }<br>
<br>
I'm used to<br>
<br>
    newtype Fix f = In { out : f (Fix f) }<br>
<br>
But all the other suggestions look fine to me, too.<br>
<br>
I've also often used this variation:<br>
<br>
    newtype HFix f a = In { out :: f (HFix f) a }<br>
<br>
This allows you to take the fixed point of e.g. monad stacks and<br>
indexed types. The function you propose below can then be a type class<br>
function of an indexed Functor class:<br>
<br>
    type f :-> g = forall a. f a -> g a<br>
<br>
    class HFunctor f where<br>
      hmap :: (a :-> b) -> f a :-> g a<br>
<br>
Does this deserve a place somewhere as well? Or is it too specialized?<br>
<br>
> Perhaps too we ought to name and define _ :: (∀ a . f a -> g a) -> Fix f -> Fix g there.<br>
<br>
Some variation of 'map' seems sensible, like 'hmap' (but see above) or 'mapFix'.<br>
<br>
Erik<br>
</blockquote></div>