<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
<font face="Helvetica, Arial, sans-serif">After having played with some
packages that use arrows, and after having read the very nice
"programming with arrows" paper I wanted to build some of my own.<br>
<br>
Strangely my code did not work, even the simplest function got stuck in
an infinite loop or gave a stack overflow.<br>
<br>
I quickly noticed I made a really stupid mistake, I forget to implement
"arr"! However, the compiler did not give a warning on this. So I
wandered how it was possible that the Arrow package had a default
implementation for something so specific as arr?<br>
<br>
The code revealed the following:<br>
<br>
</font>
<pre>        <span class="comment">-- | Lift a function to an arrow: you must define either this</span>
        <span class="comment">--   or 'pure'.</span>
        <span class="varid">arr</span> <span class="keyglyph">::</span> <span
 class="layout">(</span><span class="varid">b</span> <span
 class="keyglyph">-&gt;</span> <span class="varid">c</span><span
 class="layout">)</span> <span class="keyglyph">-&gt;</span> <span
 class="varid">a</span> <span class="varid">b</span> <span class="varid">c</span>
        <span class="varid">arr</span> <span class="keyglyph">=</span> <span
 class="varid">pure</span>

        <span class="comment">-- | A synonym for 'arr': you must define one or other of them.</span>
        <span class="varid">pure</span> <span class="keyglyph">::</span> <span
 class="layout">(</span><span class="varid">b</span> <span
 class="keyglyph">-&gt;</span> <span class="varid">c</span><span
 class="layout">)</span> <span class="keyglyph">-&gt;</span> <span
 class="varid">a</span> <span class="varid">b</span> <span class="varid">c</span>
        <span class="varid">pure</span> <span class="keyglyph">=</span> <span
 class="varid">arr</span></pre>
<font face="Helvetica, Arial, sans-serif">Ah, so the default
implementation of arr is pure... and vice versa...<br>
<br>
This feels like rather incorrect to me, but my feelings are based on
imperative background knowledge, so this might be totally correct
design in Haskell.<br>
</font><font face="Helvetica, Arial, sans-serif"><br>
Why not force people to implement arr and leave just pure as the
synonym? And if pure is really a synonym for arr, what does it do
inside the Arrow type class? Does it ever make sense to have a
different implementation for arr and pure?<br>
<br>
<br>
Thanks for any help,<br>
Peter<br>
<br>
</font>
</body>
</html>