<div dir="ltr">I was under the impression most programmers avoid Arrows because they've seen HXT. >.> Which really wants to be Applicative, not Arrow, so it's not the best example of Arrows out there.</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Feb 27, 2018 at 5:52 AM, Tom Ellis <span dir="ltr"><<a href="mailto:tom-lists-haskell-cafe-2013@jaguarpaw.co.uk" target="_blank">tom-lists-haskell-cafe-2013@jaguarpaw.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On Mon, Feb 26, 2018 at 06:36:27PM +0100, MarLinn wrote:<br>
> >I've got some type X which is almost an Arrow, except that I cannot lift<br>
> >any function a -> b to my type (of course I can for some a and b), so I<br>
> >cannot give a sensible implementation for arr. I can however give<br>
> >sensible implementations for the other methods in the Arrow class, and<br>
> >I'd like to use them (and possibly derived combinators) in other places.<br>
><br>
</span>[...]<br>
> ... I've seen this exact problem mentioned several times.<br>
<span class="">> Many nice things are almost arrows without an arr. But the arrow<br>
> machinery pre-dates our current hierarchies and understanding, and<br>
> it's never really been revised.<br>
<br>
</span>There's a myth floating around that "Arrow is much less useful because it<br>
forces you to implement arr". In fact, Arrow without arr would be as<br>
useless as Applicative without fmap. In almost all situations where you are<br>
stymied by arr a small redesign will solve the whole problem. In fact, you<br>
need to get into the realm of linear-types-like things before arr is too<br>
much (and even then a *linear* arr would be fine).<br>
<br>
I designed a library for constructing Postgres queries and it uses an Arrow<br>
interface.<br>
<br>
<a href="https://hackage.haskell.org/package/opaleye-0.5.3.0/docs/Opaleye-Internal-QueryArr.html" rel="noreferrer" target="_blank">https://hackage.haskell.org/<wbr>package/opaleye-0.5.3.0/docs/<wbr>Opaleye-Internal-QueryArr.html</a><br>
<br>
Naturally there is no way to run an arbitrary Haskell function "in the<br>
database". This is not an impediment because everything that the database<br>
acts on inside the arrow type (QueryArr) is wrapped in an abstract type<br>
(Column). This means the only way that arbitrary Haskell functions can be<br>
used inside the arrow is as a sort of "partial compilation". There is, in<br>
effect, a staging restriction. Haskell functions a -> b run at "query<br>
compile time" and Postgres functions run at "query run time".<br>
<br>
This observation was made in an ICFP '13 paper in the context of our beloved<br>
monads so nothing that I'm saying here is particular to those inscrutable<br>
arrows.<br>
<br>
<a href="http://www.cse.chalmers.se/~joels/writing/bb.pdf" rel="noreferrer" target="_blank">http://www.cse.chalmers.se/~<wbr>joels/writing/bb.pdf</a><br>
<br>
I would be sad to think that Haskell programmers are avoiding using Arrow<br>
because of this myth[1]. If Jeroen Bransen or anyone else would like more<br>
details about this approach please get in touch either via this list or<br>
personally. I'm happy to help out.<br>
<br>
Tom<br>
<br>
<br>
<br>
[1] On the other hand, avoiding using Arrow because the type in question is<br>
actually a Monad is a perfectly good reason.<br>
<div class="HOEnZb"><div class="h5"><br>
______________________________<wbr>_________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-<wbr>bin/mailman/listinfo/haskell-<wbr>cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>brandon s allbery kf8nh sine nomine associates</div><div><a href="mailto:allbery.b@gmail.com" target="_blank">allbery.b@gmail.com</a> <a href="mailto:ballbery@sinenomine.net" target="_blank">ballbery@sinenomine.net</a></div><div>unix, openafs, kerberos, infrastructure, xmonad <a href="http://sinenomine.net" target="_blank">http://sinenomine.net</a></div></div></div>
</div>