On Mon, Apr 6, 2009 at 7:39 PM, Manuel M T Chakravarty <span dir="ltr">&lt;<a href="mailto:chak@cse.unsw.edu.au">chak@cse.unsw.edu.au</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Peter Berry:<div><div class="h5"><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
3) we apply appl to x, so Memo d1 a = Memo d a. unify d = d1<br>
<br>
But for some reason, step 3 fails.<br>
</blockquote>
<br></div></div>
Step 3 is invalid - cf, &lt;<a href="http://www.haskell.org/pipermail/haskell-cafe/2009-April/059196.html" target="_blank">http://www.haskell.org/pipermail/haskell-cafe/2009-April/059196.html</a>&gt;.<br>
<br>More generally, the signature of memo_fmap is ambiguous, and hence,
correctly rejected.  We need to improve the error message, though.
 Here is a previous discussion of the subject:<br>
<br>
  <a href="http://www.mail-archive.com/haskell-cafe@haskell.org/msg39673.html" target="_blank">http://www.mail-archive.com/haskell-cafe@haskell.org/msg39673.html</a><br><font color="#888888">
<br>
Manuel</font></blockquote></div><br>The thing that confuses me about this case is how, if the type sig on memo_fmap is omitted, ghci has no problem with it, and even gives it the type that it rejected:<br><br>------------------------------------------------<br>
<br>{-# LANGUAGE TypeFamilies #-}<br><br>class Fun d where<br>  type Memo d :: * -&gt; *<br>  abst :: (d -&gt; a) -&gt; Memo d a<br>  appl :: Memo d a -&gt; (d -&gt; a)<br><br>memo_fmap f x = abst (f . appl x)<br><br>-- [m@monire a]$ ghci -ignore-dot-ghci<br>
-- GHCi, version 6.10.1: <a href="http://www.haskell.org/ghc/">http://www.haskell.org/ghc/</a>  :? for help<br>--<br>-- Prelude&gt; :l ./Memo.hs<br>-- [1 of 1] Compiling Main             ( Memo.hs, interpreted )<br>-- Ok, modules loaded: Main.<br>
--<br>-- *Main&gt; :t memo_fmap<br>-- memo_fmap :: (Fun d) =&gt; (a -&gt; c) -&gt; Memo d a -&gt; Memo d c<br><br>-- copy/paste the :t sig<br><br>memo_fmap_sig :: (Fun d) =&gt; (a -&gt; c) -&gt; Memo d a -&gt; Memo d c<br>
memo_fmap_sig f x = abst (f . appl x)<br><br>-- and,<br><br>-- *Main&gt; :r<br>-- [1 of 1] Compiling Main             ( Memo.hs, interpreted )<br>--<br>-- Memo.hs:26:35:<br>--     Couldn&#39;t match expected type `Memo d&#39;<br>
--            against inferred type `Memo d1&#39;<br>--     In the first argument of `appl&#39;, namely `x&#39;<br>--     In the second argument of `(.)&#39;, namely `appl x&#39;<br>--     In the first argument of `abst&#39;, namely `(f . appl x)&#39;<br>
-- Failed, modules loaded: none.<br><br>------------------------------------------------<br><br>Matt<br>