<div>Given fmap id = id, fmap (f . g) = fmap f . fmap g follows from the free theorem for fmap.</div>
<div> </div>
<div>This was published as an aside in a paper a long time back, but I forget where.<br></div>
<div>-Edward Kmett</div>
<div> </div>
<div class="gmail_quote">On Mon, Jan 4, 2010 at 5:14 PM, Paul Brauner <span dir="ltr">&lt;<a href="mailto:paul.brauner@loria.fr">paul.brauner@loria.fr</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Hi,<br><br>I&#39;m trying to get a deep feeling of Functors (and then pointed Functors,<br>Applicative Functors, etc.). To this end, I try to find lawless<br>
instances of Functor that satisfy one law but not the other.<br><br>I&#39;ve found one instance that satisfies fmap (f.g) = fmap f . fmap g<br>but not fmap id = id:<br><br>data Foo a = A | B<br><br>instance Functor Foo where<br>
 fmap f A = B<br> fmap f B = B<br><br>-- violates law 1<br>fmap id A = B<br><br>-- respects law 2<br>fmap (f . g) A = (fmap f . fmap g) A = B<br>fmap (f . g) B = (fmap f . fmap g) B = B<br><br>But I can&#39;t come up with an example that satifies law 1 and not law 2.<br>
I&#39;m beginning to think this isn&#39;t possible but I didn&#39;t read anything<br>saying so, neither do I manage to prove it.<br><br>I&#39;m sure someone knows :)<br><font color="#888888"><br>Paul<br></font>
<div>
<div></div>
<div class="h5">_______________________________________________<br>Haskell-Cafe mailing list<br><a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br><a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</div></div></blockquote></div><br>