<div dir="ltr">It should be free instead of tree:<br><div><br></div><div><a href="http://pointfree.io/">http://pointfree.io/</a><br></div><div><br></div><div>Regards,</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 28, 2017 at 4:27 PM, Jeffrey Brown <span dir="ltr"><<a href="mailto:jeffbrown.the@gmail.com" target="_blank">jeffbrown.the@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span class=""><span style="font-size:12.8px">> or, equivalently:</span><br style="font-size:12.8px">><br style="font-size:12.8px"><span style="font-size:12.8px">> a `andthen` b = (>>) <$> a <*> b</span><br style="font-size:12.8px">><br style="font-size:12.8px"><span style="font-size:12.8px">> for which </span><a href="http://pointree.io/" rel="noreferrer" style="font-size:12.8px" target="_blank">http://pointree.io</a><span style="font-size:12.8px"> <wbr>dutifully gives me:</span><br style="font-size:12.8px">><br style="font-size:12.8px"><span style="font-size:12.8px">> andthen = (<*>) . ((>>) <$>)</span><div><br></div></span><div>That link is not working for me, and Google isn't finding it, and it sounds like a useful thing.<br style="font-size:12.8px"></div><div><br></div></div><div class="gmail_extra"><div><div class="h5"><br><div class="gmail_quote">On Thu, Sep 28, 2017 at 1:55 AM, Viktor Dukhovni <span dir="ltr"><<a href="mailto:ietf-dane@dukhovni.org" target="_blank">ietf-dane@dukhovni.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
When generating a report file from a database I found it much more<br>
efficient (significantly shorter runtime) to represent each row<br>
by an I/O action that prints the row, rather than to construct a<br>
Row object that to print and throw away.<br>
<br>
But the naive way to construct the I/O action can be tedious to<br>
maintain once the column count gets appreciably high:<br>
<br>
newtype Foo = Foo { _foo :: IO () }<br>
instance FromRow Foo where<br>
fromRow = Foo <$> (rowPrinter <$> field <*> field <*> field <*> ... <*> field)<br>
where<br>
rowPrinter :: Type1 -> Type2 -> Type3 -> ... -> TypeN -> IO ()<br>
rowPrinter p1 p2 p3 ... pN = do<br>
printP1<br>
printP2<br>
printP3<br>
...<br>
printPN<br>
<br>
So I decided to applicatively decompose the rowPrinter function<br>
(with the actual name of "andthen" to be determined later) as:<br>
<br>
rowPrinter = (printP1 <$> field) `andthen`<br>
(printP2 <$> field) `andthen`<br>
(printP3 <$> field) `andthen`<br>
...<br>
(printPN <$> field)<br>
<br>
which avoids the need to package the column printers explicitly into<br>
a single function, and may be somewhat more efficient a well.<br>
<br>
What was not immediately obvious to me was whether there's an "off the<br>
shelf" implementation of "andthen" I could just reuse. The necessary<br>
operator satisfies:<br>
<br>
andthen (f (m a)) (f (m b)) = f (ma >> mb)<br>
<br>
or, equivalently:<br>
<br>
a `andthen` b = (>>) <$> a <*> b<br>
<br>
for which <a href="http://pointree.io" rel="noreferrer" target="_blank">http://pointree.io</a> dutifully gives me:<br>
<br>
andthen = (<*>) . ((>>) <$>)<br>
<br>
Its type signature is:<br>
<br>
Prelude> :set prompt "l> "<br>
l> :m + Control.Applicative<br>
l> :m + Control.Monad<br>
l> :t ((<*>) . ((>>) <$>))<br>
((<*>) . ((>>) <$>))<br>
:: (Monad m, Applicative f) => f (m a) -> f (m b) -> f (m b)<br>
l><br>
<br>
It seems to me that this would have been done before, and the operator<br>
would already be present in some package, but I'm having trouble finding<br>
it.<br>
<br>
(Due to the hidden constructors of FromRow defining a Semigroup does not<br>
work out here, so I can't use (<>), which also inconveniently conflicts<br>
with Monoid (<>)).<br>
<br>
So my question is whether the operator in question is already available,<br>
under some name in some package, or else suggested names for it if new.<br>
<span class="m_-7215856569656059092HOEnZb"><font color="#888888"><br>
--<br>
Viktor.<br>
<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-bi<wbr>n/mailman/listinfo/haskell-caf<wbr>e</a><br>
Only members subscribed via the mailman list are allowed to post.</font></span></blockquote></div><br><br clear="all"><div><br></div></div></div><span class="HOEnZb"><font color="#888888">-- <br><div class="m_-7215856569656059092gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Jeff Brown | Jeffrey Benjamin Brown</div><div dir="ltr"><a href="https://msu.edu/~brown202/" style="font-size:12.8px" target="_blank">Website</a> | <a href="https://www.facebook.com/mejeff.younotjeff" style="font-size:12.8px" target="_blank">Facebook</a> | <a href="https://www.linkedin.com/in/jeffreybenjaminbrown" style="font-size:12.8px" target="_blank">LinkedIn</a><span style="font-size:12.8px">(spammy, so I often miss messages here) </span><span style="font-size:12.8px">|</span><span style="font-size:12.8px"> </span><a href="https://github.com/jeffreybenjaminbrown" style="font-size:12.8px" target="_blank">Github</a><span style="font-size:12.8px"> </span></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div></div>
</font></span></div>
<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.<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>Sibi, <a href="mailto:sibi@psibi.in" target="_blank">sibi@psibi.in</a><br>WWW: <a href="http://www.psibi.in" target="_blank">psibi.in</a><br>Twitter/github/<a href="http://identi.ca" target="_blank">identi.ca</a>: psibi<br>GPG Fingerpint: A241 B3D6 F4FD D40D D7DE B1C6 D19E 3E0E BB55 7613<br>Registered Linux User ID: 534664</div></div></div></div></div></div></div>
</div>