<?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/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	
	>
<channel>
	<title>
	Comments on: The Vector Monad in C++, Without the Ugly Stuff	</title>
	<atom:link href="https://www.fluentcpp.com/2017/07/14/the-vector-monad-in-c-without-the-ugly-stuff/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.fluentcpp.com/2017/07/14/the-vector-monad-in-c-without-the-ugly-stuff/</link>
	<description>Jonathan Boccara&#039;s blog</description>
	<lastBuildDate>Fri, 14 Jul 2017 13:27:00 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.5.3</generator>
	<item>
		<title>
		By: Quentin Duval		</title>
		<link>https://www.fluentcpp.com/2017/07/14/the-vector-monad-in-c-without-the-ugly-stuff/#comment-405</link>

		<dc:creator><![CDATA[Quentin Duval]]></dc:creator>
		<pubDate>Fri, 14 Jul 2017 13:27:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=1593#comment-405</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2017/07/14/the-vector-monad-in-c-without-the-ugly-stuff/#comment-404&quot;&gt;Jonathan Boccara&lt;/a&gt;.

To me, what you are trying to achieve is a kind of list comprehension. Using you example, with the same function names, here is the corresponding code in Haskell:

[code]
[ f3 x &#124; a &#060;- map f1 [1, 2, 3]
         , b &#060;- map f1 [3, 4, 5]
         , x &#060;- f2 a b]
[/code]

If you now look at the post from Eric Niebler I linked in my previous comment (http://ericniebler.com/2014/04/27/range-comprehensions/), you will see how to translate such a comprehension from Haskell in C++. It is a really good read, and it will answer your question.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2017/07/14/the-vector-monad-in-c-without-the-ugly-stuff/#comment-404">Jonathan Boccara</a>.</p>
<p>To me, what you are trying to achieve is a kind of list comprehension. Using you example, with the same function names, here is the corresponding code in Haskell:</p>
<p>[code]<br />
[ f3 x | a &lt;- map f1 [1, 2, 3]<br />
         , b &lt;- map f1 [3, 4, 5]<br />
         , x &lt;- f2 a b]<br />
[/code]</p>
<p>If you now look at the post from Eric Niebler I linked in my previous comment (<a href="http://ericniebler.com/2014/04/27/range-comprehensions/" rel="nofollow ugc">http://ericniebler.com/2014/04/27/range-comprehensions/</a>), you will see how to translate such a comprehension from Haskell in C++. It is a really good read, and it will answer your question.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jonathan Boccara		</title>
		<link>https://www.fluentcpp.com/2017/07/14/the-vector-monad-in-c-without-the-ugly-stuff/#comment-404</link>

		<dc:creator><![CDATA[Jonathan Boccara]]></dc:creator>
		<pubDate>Fri, 14 Jul 2017 12:54:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=1593#comment-404</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2017/07/14/the-vector-monad-in-c-without-the-ugly-stuff/#comment-403&quot;&gt;Quentin Duval&lt;/a&gt;.

Ok, thanks Quentin for giving your feedback, it&#039;s really helpful. I&#039;d like to benefit from your experience in functional programming as I&#039;ve done quite a few times in the past :)

I&#039;ve replaced flatten with join in the post as you suggested. I had missed this adaptor in the range library and it&#039;s exactly what I was looking for, so that&#039;s cool.

In our case, we&#039;d need a functor for functions taking 1 argument, and applicatives for several arguments right? In which case it&#039;s applicative for the general case as you say, and I&#039;ll update the legal note :)

I&#039;m not sure how to write make_multiple with just transform and join, as you suggest. Would you have a snippet to illustrate?

Taking a step back over the post, here are its three components:
1) Drawing ideas from FP
2) Implementing them with ranges
3) And the goal is to provide an interface to adapt a plain function to multiple parameters contexts.
You&#039;ve given you&#039;re detailled feedback on 1) and 2), for which I&#039;m grateful. Do you have an opinion on 3)? I&#039;d be interested to hear it.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2017/07/14/the-vector-monad-in-c-without-the-ugly-stuff/#comment-403">Quentin Duval</a>.</p>
<p>Ok, thanks Quentin for giving your feedback, it&#8217;s really helpful. I&#8217;d like to benefit from your experience in functional programming as I&#8217;ve done quite a few times in the past 🙂</p>
<p>I&#8217;ve replaced flatten with join in the post as you suggested. I had missed this adaptor in the range library and it&#8217;s exactly what I was looking for, so that&#8217;s cool.</p>
<p>In our case, we&#8217;d need a functor for functions taking 1 argument, and applicatives for several arguments right? In which case it&#8217;s applicative for the general case as you say, and I&#8217;ll update the legal note 🙂</p>
<p>I&#8217;m not sure how to write make_multiple with just transform and join, as you suggest. Would you have a snippet to illustrate?</p>
<p>Taking a step back over the post, here are its three components:<br />
1) Drawing ideas from FP<br />
2) Implementing them with ranges<br />
3) And the goal is to provide an interface to adapt a plain function to multiple parameters contexts.<br />
You&#8217;ve given you&#8217;re detailled feedback on 1) and 2), for which I&#8217;m grateful. Do you have an opinion on 3)? I&#8217;d be interested to hear it.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Quentin Duval		</title>
		<link>https://www.fluentcpp.com/2017/07/14/the-vector-monad-in-c-without-the-ugly-stuff/#comment-403</link>

		<dc:creator><![CDATA[Quentin Duval]]></dc:creator>
		<pubDate>Fri, 14 Jul 2017 09:06:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=1593#comment-403</guid>

					<description><![CDATA[There are many things to say regarding this series on Monads. I will just point out things that really feels plain wrong.

First, you do not need flatten. There is a view::join which, given a range of range, flattens them into one range. You should check https://ericniebler.github.io/range-v3/index.html#range-views. It is well written, and there are not that many views anyway.

Second (and since you mentioned functional aficionados and playing with functional terms), you are mixing functional concepts: applying a function to all combinations of elements does not require a Monad and not a Function either, it requires an Applicative.

Now, to get a Monad, you need to have either (&#062;&#062;=) or join (preferably join in this case). And so range-v3 library is already designed to be a Monad. To get back (&#062;&#062;=), you just need view::transform and view::join chained together.

So there is no need for the cartesian_product either.

Finally, it seems to me all these posts are about building a « vector comprehension », but doing it wrong (flatten is not lazy and there are plenty of accidental complexity), because of a lack of understanding of Monads and knowledge of range-v3.

For an example of doing « range comprehension » right instead, I encourage the reader to refer to this article of Eric Niebler: http://ericniebler.com/2014/04/27/range-comprehensions/.]]></description>
			<content:encoded><![CDATA[<p>There are many things to say regarding this series on Monads. I will just point out things that really feels plain wrong.</p>
<p>First, you do not need flatten. There is a view::join which, given a range of range, flattens them into one range. You should check <a href="https://ericniebler.github.io/range-v3/index.html#range-views" rel="nofollow ugc">https://ericniebler.github.io/range-v3/index.html#range-views</a>. It is well written, and there are not that many views anyway.</p>
<p>Second (and since you mentioned functional aficionados and playing with functional terms), you are mixing functional concepts: applying a function to all combinations of elements does not require a Monad and not a Function either, it requires an Applicative.</p>
<p>Now, to get a Monad, you need to have either (&gt;&gt;=) or join (preferably join in this case). And so range-v3 library is already designed to be a Monad. To get back (&gt;&gt;=), you just need view::transform and view::join chained together.</p>
<p>So there is no need for the cartesian_product either.</p>
<p>Finally, it seems to me all these posts are about building a « vector comprehension », but doing it wrong (flatten is not lazy and there are plenty of accidental complexity), because of a lack of understanding of Monads and knowledge of range-v3.</p>
<p>For an example of doing « range comprehension » right instead, I encourage the reader to refer to this article of Eric Niebler: <a href="http://ericniebler.com/2014/04/27/range-comprehensions/" rel="nofollow ugc">http://ericniebler.com/2014/04/27/range-comprehensions/</a>.</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
