<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: MaybeArrow?</title>
	<atom:link href="http://blog.downstairspeople.org/2009/01/04/maybearrow/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.downstairspeople.org/2009/01/04/maybearrow/</link>
	<description>Roguestar, Haskell, and Fun</description>
	<lastBuildDate>Mon, 30 Nov 2009 21:37:00 -0500</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.3</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Lane</title>
		<link>http://blog.downstairspeople.org/2009/01/04/maybearrow/comment-page-1/#comment-383</link>
		<dc:creator>Lane</dc:creator>
		<pubDate>Sun, 01 Feb 2009 14:02:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.downstairspeople.org/?p=53#comment-383</guid>
		<description>Oh, that&#039;s really annoying.  I had to change a little bit of formatting with the new theme, and it got relisted on the planets.</description>
		<content:encoded><![CDATA[<p>Oh, that&#8217;s really annoying.  I had to change a little bit of formatting with the new theme, and it got relisted on the planets.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: coeus</title>
		<link>http://blog.downstairspeople.org/2009/01/04/maybearrow/comment-page-1/#comment-381</link>
		<dc:creator>coeus</dc:creator>
		<pubDate>Tue, 20 Jan 2009 04:26:26 +0000</pubDate>
		<guid isPermaLink="false">http://blog.downstairspeople.org/?p=53#comment-381</guid>
		<description>hm, k.
different getA/B/C, same monad.
as long as the example is short, this should work:


fmap (uncurry $ uncurry $ liftM3 foo) ((getA &amp;&amp;&amp; getB) &amp;&amp;&amp; getC) -&lt; ()



i didn&#039;t compile it, it&#039;s 5:25 at night in germany.
goodn8.
- marc</description>
		<content:encoded><![CDATA[<p>hm, k.<br />
different getA/B/C, same monad.<br />
as long as the example is short, this should work:</p>
<p>fmap (uncurry $ uncurry $ liftM3 foo) ((getA &amp;&amp;&amp; getB) &amp;&amp;&amp; getC) -&lt; ()</p>
<p>i didn&#8217;t compile it, it&#8217;s 5:25 at night in germany.<br />
goodn8.<br />
- marc</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lane</title>
		<link>http://blog.downstairspeople.org/2009/01/04/maybearrow/comment-page-1/#comment-380</link>
		<dc:creator>Lane</dc:creator>
		<pubDate>Tue, 20 Jan 2009 04:00:41 +0000</pubDate>
		<guid isPermaLink="false">http://blog.downstairspeople.org/?p=53#comment-380</guid>
		<description>Heterogenous parameters, in other words, what I really want is something like:

&lt;pre&gt;
proc _ -&gt;
    do m_a &lt;- getA -&lt; ()
       m_b &lt;- getB -&lt; ()
       m_c &lt;- getC -&lt; ()
       returnA -&lt;
           do a &lt;- m_a
              b &lt;- m_b
              c &lt;- m_c
              return $ foo a b c
&lt;/pre&gt;

And for some reason, I didn&#039;t think clearly about that when I did the original example.</description>
		<content:encoded><![CDATA[<p>Heterogenous parameters, in other words, what I really want is something like:</p>
<pre>
proc _ ->
    do m_a < - getA -< ()
       m_b <- getB -< ()
       m_c <- getC -< ()
       returnA -<
           do a <- m_a
              b <- m_b
              c <- m_c
              return $ foo a b c
</pre>
<p>And for some reason, I didn't think clearly about that when I did the original example.</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: coeus</title>
		<link>http://blog.downstairspeople.org/2009/01/04/maybearrow/comment-page-1/#comment-379</link>
		<dc:creator>coeus</dc:creator>
		<pubDate>Tue, 20 Jan 2009 03:11:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.downstairspeople.org/?p=53#comment-379</guid>
		<description>argh!
in words:

(_,bs) 
&quot;arrow-left&quot;
( foldr (
&quot;GTGTGT&quot;
) (arr id) $ replicate (length as) (chainlink f) ) -&lt; (as,[])</description>
		<content:encoded><![CDATA[<p>argh!<br />
in words:</p>
<p>(_,bs)<br />
&#8220;arrow-left&#8221;<br />
( foldr (<br />
&#8220;GTGTGT&#8221;<br />
) (arr id) $ replicate (length as) (chainlink f) ) -&lt; (as,[])</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: coeus</title>
		<link>http://blog.downstairspeople.org/2009/01/04/maybearrow/comment-page-1/#comment-378</link>
		<dc:creator>coeus</dc:creator>
		<pubDate>Tue, 20 Jan 2009 03:10:10 +0000</pubDate>
		<guid isPermaLink="false">http://blog.downstairspeople.org/?p=53#comment-378</guid>
		<description>the three &#039;&gt;&#039; are the problem.
----
amap :: (Arrow (~&gt;)) =&gt; (a ~&gt; b) -&gt; [a] -&gt; (() ~&gt; [b])
amap f as = proc x -&gt; do
    (_,bs) ,&gt;,&gt;) (arr id) $ replicate (length as) (chainlink f) ) -&lt; (as,[])
    returnA -&lt; reverse bs</description>
		<content:encoded><![CDATA[<p>the three &#8216;&gt;&#8217; are the problem.<br />
&#8212;-<br />
amap :: (Arrow (~&gt;)) =&gt; (a ~&gt; b) -&gt; [a] -&gt; (() ~&gt; [b])<br />
amap f as = proc x -&gt; do<br />
    (_,bs) ,&gt;,&gt;) (arr id) $ replicate (length as) (chainlink f) ) -&lt; (as,[])<br />
    returnA -&lt; reverse bs</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: coeus</title>
		<link>http://blog.downstairspeople.org/2009/01/04/maybearrow/comment-page-1/#comment-377</link>
		<dc:creator>coeus</dc:creator>
		<pubDate>Tue, 20 Jan 2009 03:06:08 +0000</pubDate>
		<guid isPermaLink="false">http://blog.downstairspeople.org/?p=53#comment-377</guid>
		<description>amap :: (Arrow (~&gt;)) =&gt; (a ~&gt; b) -&gt; [a] -&gt; (() ~&gt; [b])
amap f as = proc x -&gt; do
    (_,bs)  &gt; &gt; ) (arr id) $ replicate (length as) (chainlink f) ) -&lt; (as,[])
    returnA -&lt; reverse bs</description>
		<content:encoded><![CDATA[<p>amap :: (Arrow (~&gt;)) =&gt; (a ~&gt; b) -&gt; [a] -&gt; (() ~&gt; [b])<br />
amap f as = proc x -&gt; do<br />
    (_,bs)  &gt; &gt; ) (arr id) $ replicate (length as) (chainlink f) ) -&lt; (as,[])<br />
    returnA -&lt; reverse bs</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: coeus</title>
		<link>http://blog.downstairspeople.org/2009/01/04/maybearrow/comment-page-1/#comment-376</link>
		<dc:creator>coeus</dc:creator>
		<pubDate>Tue, 20 Jan 2009 03:05:04 +0000</pubDate>
		<guid isPermaLink="false">http://blog.downstairspeople.org/?p=53#comment-376</guid>
		<description>hm... i don&#039;t know how to submit code properly.
hey, you are online :)

what do you mean with heterogeneous parameters?

-----
chainlink :: Arrow (~&gt;) =&gt; (a ~&gt; b) -&gt; (([a],[b])~&gt;([a],[b]))
chainlink f = proc (a:ar,br) -&gt; do
    b &lt;- f -&lt; a
    returnA -&lt; (ar,b:br)</description>
		<content:encoded><![CDATA[<p>hm&#8230; i don&#8217;t know how to submit code properly.<br />
hey, you are online <img src='http://blog.downstairspeople.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>what do you mean with heterogeneous parameters?</p>
<p>&#8212;&#8211;<br />
chainlink :: Arrow (~&gt;) =&gt; (a ~&gt; b) -&gt; (([a],[b])~&gt;([a],[b]))<br />
chainlink f = proc (a:ar,br) -&gt; do<br />
    b &lt;- f -&lt; a<br />
    returnA -&lt; (ar,b:br)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: coeus</title>
		<link>http://blog.downstairspeople.org/2009/01/04/maybearrow/comment-page-1/#comment-375</link>
		<dc:creator>coeus</dc:creator>
		<pubDate>Tue, 20 Jan 2009 02:58:13 +0000</pubDate>
		<guid isPermaLink="false">http://blog.downstairspeople.org/?p=53#comment-375</guid>
		<description>hm... @moderator: please remove the code above. this is my 2nd try.

[code]

{-# LANGUAGE Arrows,TypeOperators,EmptyDataDecls #-}
module MaybeArrow where
--import Control.Category hiding ((.),id)
import Control.Arrow
data Thing
data FooThing
data SomeArrow b c
--instance Control.Category.Category SomeArrow where
instance Arrow SomeArrow where
get :: SomeArrow String (Maybe Thing)
get = undefined
foo :: [Thing] -&gt; FooThing
foo = undefined


-- chainlink :: ... -&gt; ((a:ar,br) ~&gt; (ar,b:br))
chainlink :: Arrow (~&gt;) =&gt; (a ~&gt; b) -&gt; (([a],[b])~&gt;([a],[b]))
chainlink f = proc (a:ar,br) -&gt; do
    b &lt;- f -&lt; a
    returnA -)) =&gt; (a ~&gt; b) -&gt; [a] -&gt; (() ~&gt; [b])
amap f as = proc x -&gt; do
    (_,bs) &gt;&gt;) (arr id) $ replicate (length as) (chainlink f) ) -&lt; (as,[])
    returnA -&lt; reverse bs


getAToZ :: SomeArrow () (Maybe FooThing)
getAToZ = amap get [[s]&#124;s&gt;&gt; arr (fmap foo . sequence)

[/code]</description>
		<content:encoded><![CDATA[<p>hm&#8230; @moderator: please remove the code above. this is my 2nd try.</p>
<p>[code]</p>
<p>{-# LANGUAGE Arrows,TypeOperators,EmptyDataDecls #-}<br />
module MaybeArrow where<br />
--import Control.Category hiding ((.),id)<br />
import Control.Arrow<br />
data Thing<br />
data FooThing<br />
data SomeArrow b c<br />
--instance Control.Category.Category SomeArrow where<br />
instance Arrow SomeArrow where<br />
get :: SomeArrow String (Maybe Thing)<br />
get = undefined<br />
foo :: [Thing] -&gt; FooThing<br />
foo = undefined</p>
<p>-- chainlink :: ... -&gt; ((a:ar,br) ~&gt; (ar,b:br))<br />
chainlink :: Arrow (~&gt;) =&gt; (a ~&gt; b) -&gt; (([a],[b])~&gt;([a],[b]))<br />
chainlink f = proc (a:ar,br) -&gt; do<br />
    b &lt;- f -&lt; a<br />
    returnA -)) =&gt; (a ~&gt; b) -&gt; [a] -&gt; (() ~&gt; [b])<br />
amap f as = proc x -&gt; do<br />
    (_,bs) &gt;&gt;) (arr id) $ replicate (length as) (chainlink f) ) -&lt; (as,[])<br />
    returnA -&lt; reverse bs</p>
<p>getAToZ :: SomeArrow () (Maybe FooThing)<br />
getAToZ = amap get [[s]|s&gt;&gt; arr (fmap foo . sequence)</p>
<p>[/code]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lane</title>
		<link>http://blog.downstairspeople.org/2009/01/04/maybearrow/comment-page-1/#comment-374</link>
		<dc:creator>Lane</dc:creator>
		<pubDate>Tue, 20 Jan 2009 02:57:21 +0000</pubDate>
		<guid isPermaLink="false">http://blog.downstairspeople.org/?p=53#comment-374</guid>
		<description>Ah, I see what you’re driving at. But I think there is a deficiency in the example, rather than the solution. The example ought to show a foo that takes some heterogeneous parameters.</description>
		<content:encoded><![CDATA[<p>Ah, I see what you’re driving at. But I think there is a deficiency in the example, rather than the solution. The example ought to show a foo that takes some heterogeneous parameters.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: coeus</title>
		<link>http://blog.downstairspeople.org/2009/01/04/maybearrow/comment-page-1/#comment-371</link>
		<dc:creator>coeus</dc:creator>
		<pubDate>Tue, 20 Jan 2009 02:45:54 +0000</pubDate>
		<guid isPermaLink="false">http://blog.downstairspeople.org/?p=53#comment-371</guid>
		<description>hm, nice puzzle.
because of the missing ArrowChoice class, 
you need sth like (&quot;a&quot;,(&quot;b&quot;,(&quot;c&quot;,(...))) inside the arrow. that means: a fixed length list.

but you need the fixed length only &#039;inside&#039; the arrow, not in your sourcecode. so build it!

the idea is to build a chain of equal arrows, which can be simply combined... using lists instead of tuples. each link in that chain is a double list-/stream-transformer. each takes one item from the input list/stream and applies the computed output to the output list/stream. (chainlink)

that chain should process the list of inputs and should generate the list of outputs. (amap)

then on those outputs we have to test wether they all are Just cases... you use the Monad property, which is quite handy, but only if you know some library functions like sequence.

[my next reply shows the code]

well, reading your code above, i guess you still think a tiny bit &#039;the imperative way&#039;(tm) ...so i advise to read Data.List and half of the paper &quot;Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire (1991)&quot; (http://en.wikipedia.org/wiki/Catamorphism), that will blow most of that tedious imperative style away. ;) it&#039;s about foldr and friends.

regards
- marc

(i&#039;ve just read HWN-100, so this didn&#039;t take 2 weeks.)</description>
		<content:encoded><![CDATA[<p>hm, nice puzzle.<br />
because of the missing ArrowChoice class,<br />
you need sth like (&#8221;a&#8221;,(&#8221;b&#8221;,(&#8221;c&#8221;,(&#8230;))) inside the arrow. that means: a fixed length list.</p>
<p>but you need the fixed length only &#8216;inside&#8217; the arrow, not in your sourcecode. so build it!</p>
<p>the idea is to build a chain of equal arrows, which can be simply combined&#8230; using lists instead of tuples. each link in that chain is a double list-/stream-transformer. each takes one item from the input list/stream and applies the computed output to the output list/stream. (chainlink)</p>
<p>that chain should process the list of inputs and should generate the list of outputs. (amap)</p>
<p>then on those outputs we have to test wether they all are Just cases&#8230; you use the Monad property, which is quite handy, but only if you know some library functions like sequence.</p>
<p>[my next reply shows the code]</p>
<p>well, reading your code above, i guess you still think a tiny bit &#8216;the imperative way&#8217;(tm) &#8230;so i advise to read Data.List and half of the paper &#8220;Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire (1991)&#8221; (<a href="http://en.wikipedia.org/wiki/Catamorphism)" rel="nofollow">http://en.wikipedia.org/wiki/Catamorphism)</a>, that will blow most of that tedious imperative style away. <img src='http://blog.downstairspeople.org/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  it&#8217;s about foldr and friends.</p>
<p>regards<br />
- marc</p>
<p>(i&#8217;ve just read HWN-100, so this didn&#8217;t take 2 weeks.)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
