<div dir="ltr"><div>Hi Brent,<br></div><div><br></div>Many thanks for taking the time to have a look! Hope you might be able to cope with some more amateurish fumbling as I try and expand my understanding...<div><br></div>
<div class="gmail_extra"><div class="gmail_quote">On 14 November 2013 13:59, Brent Yorgey <span dir="ltr"><<a href="mailto:byorgey@seas.upenn.edu" target="_blank">byorgey@seas.upenn.edu</a>></span> wrote:<br><div> </div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">In general one must consider what are called<br>
*di*natural transformations.  (I ought to write a blog post about<br>
this.)...but I thought I would mention it in case you want to look it up later.</blockquote><div><br></div><div>Thanks -- dinatural transformations are probably a bit beyond my comfort zone right now, but I'll add it to my list of things to look at. </div>
<div><br></div><div>Interesting to discover that not all polymorphic functions are natural transformations. "fix" seems rather exotic -- are there any less unusual examples?</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Note that you can't always characterize a type class by a single<br>
function like this.  For example, consider class Foo ... There is no way to pick functors f and g such that a Foo dictionary is<br>
equivalent to  f a -> g a.<br></blockquote><div><br></div><div><span style="font-size:13px;font-family:arial,sans-serif">I was wondering why the following wouldn't do the trick?</span><div><span style="font-family:arial,sans-serif;font-size:13px"><br>
</span></div><div><font face="courier new, monospace">sig :: Foo a => Either Int a -> Either a Int<br></font></div><div><div><font face="courier new, monospace">sig (Left n) = Left (bar n)</font></div><div><font face="courier new, monospace">sig (Right a) = Right (baz a)</font></div>
</div></div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">This doesn't really make sense.  If a natural transformation<br>

consists of a family of arrows which all live in Hask_T, </blockquote><div><br></div><div>In this case, I think the family of arrows lives in Hask -- we can reinterpret our Hask endofunctors as instead being functors from Hask_T -> Hask. Then there's no requirement on our constrained polymorphic functions to commute with sig.</div>
<div><br></div><div>In your example function f, the two functors would be the identify functor "Id" and a constant functor "K Foo", and naturality is just saying that, for any function g: A -> B that satisfies show == show . f, then:</div>
<div><br></div><div><span style="font-family:'courier new',monospace">f = f . g</span><br></div><div><br></div><div>Which is clearly true for f.</div><div><br></div><div><br></div><div>Am I still barking up the wrong tree? Apologies if so, but it *feels* like there should be something here, with the intuition that:</div>
<div><br></div><div>Functions that don't "inspect" their values ==> you can substitute values without fundamentally affecting the action of the function ==> natural transformations between Hask endofunctors.</div>
<div><br></div><div>Functions that don't inspect their values other than through a particular interface T ==> you can substitute values without fundamentally affecting the action of the function, providing your substitution is invisible through the interface T ==> Natural transformations between functors Hask_T -> Hask.</div>
<div><br></div><div>-- Matt</div></div></div></div>