<p dir="ltr">I'm not saying that we need to find the One True Way, and none of it needs to go in base (at least for now). I just think it would be better to have several different versions in one place (transformers, or some special package just for this, or whatever) than to have things like XML libraries defining their own.</p>
<div class="gmail_quote">On Mar 24, 2015 2:59 PM, "Edward Kmett" <<a href="mailto:ekmett@gmail.com">ekmett@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"><div dir="ltr">For that version.<div><br></div><div>There are two viable definitions for Show</div><div><br></div><div>instance Show1 f => Show (Fix f)</div><div><br></div><div>instance Show (f (Fix f)) => Show (Fix f)</div><div><br></div><div>Similarly for Eq, Ord, Read.</div><div><br></div><div>The former is the style used in transformers 0.4+ adapted from what I did in prelude-extras.</div><div><br></div><div>The latter is the style we had to use before, but which relies on UndecidableInstances and FlexibleContexts.</div><div><br></div><div>-Edward</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 24, 2015 at 2:41 PM, David Feuer <span dir="ltr"><<a href="mailto:david.feuer@gmail.com" target="_blank">david.feuer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">I don't understand what you're getting at, Edward. The specific type I mentioned, newtype Fix f = Fix (f (Fix f)), seems to be defined and used in various places. Are there important differences in the instances *for that type*? Or are you concerned about the higher-order versions?</p>
<p dir="ltr">I'm also not at all committed to putting this in base, per se. I just don't like the fact that various unrelated packages with very different purposes are all doing the same thing, and that these identical types cannot be used together.</p><div><div>
<div class="gmail_quote">On Mar 24, 2015 2:25 PM, "Edward Kmett" <<a href="mailto:ekmett@gmail.com" target="_blank">ekmett@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"><div dir="ltr"><div><div>History of indexed: </div><div><br></div><div>The version of indexed on hackage was split out of my old category-extras package by Reiner Pope. I asked a couple of years back if I could replace it with a new version, and he said yes.</div></div><div><br></div><div>The version on my github is my exploration of that design space. It was stalled because of issues with GHC circa 7.6. Notably: Any inhabiting every kind meant that it wasn't sound to assume that the only inhabitants of the product kind (i,j) are of the form '(a, b) for a :: i, and b :: j. We've fixed most of those issues in GHC 7.10, so in theory i could pick up my indexed package and finish it. There are other issues still outstanding, but that was the big one.<div><br></div><div>I think there are enough points in this design space that I'm much much happier to have this sort of thing in libraries that are removed from base than having it in base itself. As an example: Making useful instances for it requires either UndecidableInstances or switching to something like Data.Functor.Classes or the machinery prelude-extras. I'm not terribly comfortable with base making a bet on one such horse at the expense of the others, and I'm even less comfortable moving the data type up where any such instances would perforce be orphans if we didn't supply them.</div><div><br></div><div><b>tl;dr</b> -1</div><div><br></div><div>-Edward</div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 24, 2015 at 1:00 PM, Oliver Charles <span dir="ltr"><<a href="mailto:ollie@ocharles.org.uk" target="_blank">ollie@ocharles.org.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Oh, I see your confusion - you're looking at `indexed` on Hackage, but I meant the unreleased library on Github. That uses the slice category presentation of higher-order monads/functors, which is what you're talking about:<div><br></div><div><a href="https://github.com/ekmett/indexed/blob/master/src/Indexed/Functor.hs#L53" target="_blank">https://github.com/ekmett/indexed/blob/master/src/Indexed/Functor.hs#L53</a><br></div><div><br></div><div>Though HFix isn't there, but I feel it would be a suitable addition to the library.</div><div><br></div><div>It is unfortunate that there is a name conflict.</div></div><div><div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 24, 2015 at 4:28 PM, Erik Hesselink <span dir="ltr"><<a href="mailto:hesselink@gmail.com" target="_blank">hesselink@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">That seems slightly different, more related to indexed monads with<br>
pre- and postconditions. They have many more type variables...<br>
<span><font color="#888888"><br>
Erik<br>
</font></span><div><div><br>
On Tue, Mar 24, 2015 at 5:20 PM, Oliver Charles <<a href="mailto:ollie@ocharles.org.uk" target="_blank">ollie@ocharles.org.uk</a>> wrote:<br>
> Higher order stuff is very useful, but I don't think it needs to belong in<br>
> the same place as Data.Functor.Fix. Edward Kmett's 'indexed' library will<br>
> probably deal with this, when we have a GHC that's smart enough to<br>
> understand it ;)<br>
><br>
> - Ollie<br>
><br>
> On Tue, Mar 24, 2015 at 3:40 PM, Erik Hesselink <<a href="mailto:hesselink@gmail.com" target="_blank">hesselink@gmail.com</a>> wrote:<br>
>><br>
>> Ugh, you're right, I renamed the variables and made a mistake. The<br>
>> outer variable should stay the same of course, your signature is<br>
>> correct.<br>
>><br>
>> For a use site of HFix, see the multirec package [0], although that<br>
>> might not really clarify things :) We also have a use internally, but<br>
>> I just realized we can probably simplify that away.<br>
>><br>
>> Regards,<br>
>><br>
>> Erik<br>
>><br>
>> [0]<br>
>> <a href="http://hackage.haskell.org/package/multirec-0.7.5/docs/Generics-MultiRec-HFix.html" target="_blank">http://hackage.haskell.org/package/multirec-0.7.5/docs/Generics-MultiRec-HFix.html</a><br>
>><br>
>> On Tue, Mar 24, 2015 at 4:25 PM, David Feuer <<a href="mailto:david.feuer@gmail.com" target="_blank">david.feuer@gmail.com</a>><br>
>> wrote:<br>
>> > I have no comment on your higher-order version (because I don't<br>
>> > understand<br>
>> > it yet), but the type you give for hmap looks unlikely. Did you mean<br>
>> ><br>
>> > hmap :: (g :-> h) -> f g :-> f h ?<br>
>> ><br>
>> > On Mar 24, 2015 10:58 AM, "Erik Hesselink" <<a href="mailto:hesselink@gmail.com" target="_blank">hesselink@gmail.com</a>> wrote:<br>
>> >><br>
>> >> On Tue, Mar 24, 2015 at 7:23 AM, M Farkas-Dyck <<a href="mailto:strake888@gmail.com" target="_blank">strake888@gmail.com</a>><br>
>> >> 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<br>
>> >> >> 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,<br>
>> >> >> 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<br>
>> >> >> 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) -><br>
>> >> > Fix f<br>
>> >> > -> Fix g there.<br>
>> >><br>
>> >> Some variation of 'map' seems sensible, like 'hmap' (but see above) or<br>
>> >> 'mapFix'.<br>
>> >><br>
>> >> Erik<br>
>> _______________________________________________<br>
>> Libraries mailing list<br>
>> <a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
>> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
><br>
><br>
</div></div></blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
<br></blockquote></div><br></div>
<br>_______________________________________________<br>
Libraries mailing list<br>
<a href="mailto:Libraries@haskell.org" target="_blank">Libraries@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries</a><br>
<br></blockquote></div>
</div></div></blockquote></div><br></div>
</blockquote></div>