<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="11465" data-post-id="11465">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Onor.io" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Onor.io/120/960_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Onor.io
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>You may find this series worthwhile <a href="http://www.ibm.com/developerworks/library/j-ft1/" rel="noopener nofollow ugc">http://www.ibm.com/developerworks/library/j-ft1/</a></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="11465" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/thinking-functional/1771/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-11465" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="11465"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="11471" data-post-id="11471">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="kostonstyle" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  kostonstyle
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="peerreynders" data-post="3" data-topic="1771">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/peerreynders/48/5826_2.png" class="avatar"> peerreynders:</div>
<blockquote>
<p>purely functional</p>
</blockquote>
</aside>
<p>Why elixir is not purely functional? Please explain with an example.</p>
<p>Thanks</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="11471" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/thinking-functional/1771/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-11471" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="11471"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #12"></div>
  </section>
</div>
    <div class="postbit" id="11472" data-post-id="11472">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="g4143" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  g4143
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>In my programming evolution I went from knowing it all in C/ASM and then proceeded to C++ and other OOP and languages and thought I knew it all. I’m now trying to learn functional programming with a new and correct attitude that I know very little to nothing and I find that attitude helps with the preconceived notions and arrogant feelings of - I already know that. I found once I took the advise of most intro functional books - forget everything you know about imperative/OOP programming before beginning functional programming - I was able to grasp the many, many simple concepts encouraged in functional programming…</p>
<p>Its true. If you can drop all your preconceived notions and proceed with a bare slate then you can move at a steady place in functional programming. If you drag your imperative/OOP practices into functional programming then you can expect a rough ride that will only confuse you.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="11472" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/thinking-functional/1771/14">Post #13</a>
	                </div>
	            </div>
              <div id="likers-container-11472" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="11472"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #13"></div>
  </section>
</div>
    <div class="postbit" id="11475" data-post-id="11475">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="vasspilka" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/vasspilka/120/2026_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  vasspilka
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="kostonstyle" data-post="13" data-topic="1771">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/letter_avatar_proxy/v4/letter/k/5f9b8f/48.png" class="avatar"> kostonstyle:</div>
<blockquote>
<p>Why elixir is not purely functional? Please explain with an example.</p>
</blockquote>
</aside>
<p>For a funcion to be considerate pure two requirements MUST apply.</p>
<ol>
<li>there must be absolutely no side-effects.</li>
<li><code>F(x)=y</code> must always be true for any x. (will explain further down)</li>
</ol>
<p>The first one is probably the easiest to grasp what it simply means is that a function must get some input do calculations and produce an output without interfering with anything else. If this was always true for Elixir/Erlang we would have to say goodbye to messages. As any message is essentially a side-effect.</p>
<p><code>F(x)=y</code> means that the function with these specific arguments is essentially equal to its resulted output. Lets say you have the following function<br>
<code>def hello(name), do: "Hello #{name}"</code><br>
You can replace <code>hello("John")</code> with the string <code>"Hello John"</code> and the program would be working perfectly. However consider the next example.</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">def greeting(name) do
  cond do
    Time.now.hours &gt; 18 -&gt; "Good evening #{name}"
    Time.now.hours &gt; 12 -&gt; "Good afternoon #{name}"
    Time.now.hours &lt; 6  -&gt; "Good night #{name}"
    true                -&gt; "Good morning #{name}"
  end
end  
## Time.now.hours does not exist and in fact is the exact oposite of a pure function, 
## we can see how using impure function can spread the impurity along
</code></pre>
<p>We can easily see that everytime we call <code>greeting("John")</code> there is a big change we get a different output, we <strong>cannot</strong> simply replace it with any of the strings in the function and be sure its going to work as intended. To make this function pure we would have to supply the date as an argument, like so <code>greeting("John", "20:45")</code> now we could safely replace this call with <code>"Good evening John"</code> and everything would be fine.<br>
Finally consider a function that takes an input sends a message and then returns a tuple.<br>
Considering the function was pure we could replace the function call with the tuple, if we do that however the message would never be sent therefore the function call and its output are not equal.</p>
<p>For a language to be considerate purely functional, it must not only allow the above two requirements but it must enforce them.<br>
While in Elixir/Erlang one can write purely functional programs it is the norm to allow some side-effects for effectiveness.</p>
<p>Other languages like Haskell use monads to address these issues and retain their purity, but you should ask someone else about this since I have only the slightest idea of how it works.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="11475" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/thinking-functional/1771/15">Post #14</a>
	                </div>
	            </div>
              <div id="likers-container-11475" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="11475"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #14"></div>
  </section>
</div>
    <div class="postbit" id="11485" data-post-id="11485">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="OvermindDL1" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/OvermindDL1/120/2677_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  OvermindDL1
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Monads are actually a very simple concept (as the 50000 tutorials state but are still being made, that shows how easy they are! /s), let me try a simple description without using code.  It is just a container for carrying state around in an immutable way.  Think of an implicit hidden argument being passed around function (in an elixir’ish way or a global ‘this’ in OOP languages) that things can return new versions of.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="11485" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/thinking-functional/1771/16">Post #15</a>
	                </div>
	            </div>
              <div id="likers-container-11485" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="11485"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #15"></div>
  </section>
</div>
    <div class="postbit" id="11497" data-post-id="11497">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="g4143" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  g4143
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>So much hype has grown up around monads that they have become mythical in nature. Monads just bury state in a shallow grave.</p>
<p>This probably the best description of them…</p>
<aside class="onebox allowlistedgeneric" data-onebox-src="https://www.adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html">
  <header class="source">

      <a href="https://www.adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html" target="_blank" rel="noopener nofollow ugc">adit.io</a>
  </header>

  <article class="onebox-body">
    

<h3><a href="https://www.adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html" target="_blank" rel="noopener nofollow ugc">Functors, Applicatives, And Monads In Pictures - adit.io</a></h3>

  <p>Aditya Bhargava's personal blog.</p>


  </article>

  <div class="onebox-metadata">
    
    
  </div>

  <div style="clear: both"></div>
</aside>
 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="11497" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/thinking-functional/1771/17">Post #16</a>
	                </div>
	            </div>
              <div id="likers-container-11497" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="11497"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #16"></div>
  </section>
</div>
    <div class="postbit" id="11514" data-post-id="11514">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="peerreynders" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/peerreynders/120/5826_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  peerreynders
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>José Valim: <a href="http://blog.plataformatec.com.br/2016/05/beyond-functional-programming-with-elixir-and-erlang/" rel="noopener nofollow ugc">Beyond Functional Programming with Elixir and Erlang</a></p>
<blockquote>
<p>functional programming is not a goal in the Erlang VM. It is a means to an end.</p>
</blockquote>
<p>Erlang (and Elixir) are practical languages and there is nothing wrong with that. If you are interested in the History of Erlang - Joe Armstrong: <em>26 years with Erlang or How I got my grey hairs</em>:</p><div class="youtube-onebox lazy-video-container" data-video-id="HCwRGHj5jOE" data-video-title="26 years with Erlang or How I got my grey hairs" data-video-start-time="" data-provider-name="youtube">
  <a href="https://www.youtube.com/watch?v=HCwRGHj5jOE" target="_blank" class="video-thumbnail" rel="noopener nofollow ugc">
    <img class="youtube-thumbnail" src="https://i.ytimg.com/vi/HCwRGHj5jOE/hqdefault.jpg" title="26 years with Erlang or How I got my grey hairs" width="480" height="360">
  </a>
</div>

<p>Here it becomes clear that some of Erlang’s roots actually come from <a href="https://en.wikipedia.org/wiki/Prolog" rel="noopener nofollow ugc">Prolog</a> (that is where all the emphasis on pattern-matching comes from), a declarative, logic programming language that doesn’t even support functions. But the issue of this topic is “Thinking Functional”.</p>
<p>It is often asserted that it is possible to apply “functional practices” in traditional imperative languages but in my personal experience that is not an efficient way towards adopting “functional thinking” because the imperative escape hatch is always so close by. Even in Haskell it is possible to write in an <a href="https://en.wikibooks.org/wiki/Haskell/do_notation" rel="noopener nofollow ugc">imperative style</a> - the difference is that it typically sticks out like a sore thumb (so you better have a good excuse ready <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20">) - Haskell is functional by default since it is based on lambda calculus. Learning Haskell is a bit like going to the (functional) <a href="https://en.wikipedia.org/wiki/Language_immersion" rel="noopener nofollow ugc">language immersion</a> school - everybody gives you dirty looks when you revert to your familiar imperative ways.</p>
<p>That being said Haskell is probably too much of a “full frontal assault” if one has had very little exposure to “thinking functionally”. In my personal case Clojure (a Lisp dialect) was the first successful wrecking ball to chip away at my imperative mindset - if one has no Java development background then it may make sense to look <a href="https://forum.elixirforum.com/t/new-to-programming-how-should-i-proceed-in-learning-elixir/875/18" rel="nofollow">elsewhere</a> (however I think it is important not to get <em>too enchanted</em> with Lisp just because on the surface “it does everything I need to do” but one should certainly learn to appreciate and wield it (certainly come in handy with emacs)).</p>
<p>Now I’m no static typing bigot - but in my personal assessment dynamically typed languages like Clojure, Erlang, and Elixir may not push the programmer/designer enough to actively “reason about types” (and their “compositionality”) in the same way strong static typing in Haskell tends to. Of course ultimately this leads down the path to <a href="https://bartoszmilewski.com/2014/10/28/category-theory-for-programmers-the-preface/" rel="noopener nofollow ugc">Category Theory for Programmers</a>.</p>
<p>At the very least there seems to be one repeating theme for “things I wish I was told before I started” - “Dialyzer”, e.g. Bernard Duggan: <em>Erlang in production: “I wish I’d known that when I started”</em></p><div class="youtube-onebox lazy-video-container" data-video-id="G0eBDWigORY" data-video-title="Erlang in production: &quot;I wish I'd known that when I started&quot; - Bernard Duggan" data-video-start-time="590" data-provider-name="youtube">
  <a href="https://www.youtube.com/watch?v=G0eBDWigORY&amp;t=590" target="_blank" class="video-thumbnail" rel="noopener nofollow ugc">
    <img class="youtube-thumbnail" src="https://i.ytimg.com/vi/G0eBDWigORY/hqdefault.jpg" title="Erlang in production: &quot;I wish I'd known that when I started&quot; - Bernard Duggan" width="480" height="360">
  </a>
</div>

<p>For the time being I simply view concepts like semi-group, monoid, functor, applicative, monad, etc. as “design patterns on steroids”. Actually design patterns  from the OO realm (as helpful as they can be) are more like “sloppy laundry lists” compared to these concepts. Basically design a type that strictly observes the identified “laws” (constraints) and enjoy all the other guarantees that go with it <em>by default</em>. Often people get too hung up on one particular instance (e.g. the IO monad) and a particular use case (e.g. dealing with side-effects) and never stick around long enough to understand the full scope of power that these abstractions can yield (on the flip-side dwelling too much on them probably will end in “type” analysis paralysis - but balance is key, as always).</p>
<p>When it comes to “thinking functionally” it may also make sense not get too fixated on one particular language (it’s always handy to have a <a href="http://prog21.dadgum.com/215.html" rel="noopener nofollow ugc">secondary</a>) but to also have a look at those languages that hang out in the same <em>neighborhood</em> - but are just a little bit different.</p>
<p>Garrett Smith: <em>Why The Cool Kids Don’t Use Erlang</em></p><div class="youtube-onebox lazy-video-container" data-video-id="3MvKLOecT1I" data-video-title="Garrett Smith - Why The Cool Kids Don't Use Erlang" data-video-start-time="171" data-provider-name="youtube">
  <a href="https://www.youtube.com/watch?v=3MvKLOecT1I&amp;t=171" target="_blank" class="video-thumbnail" rel="noopener nofollow ugc">
    <img class="youtube-thumbnail" src="https://img.youtube.com/vi/3MvKLOecT1I/maxresdefault.jpg" title="Garrett Smith - Why The Cool Kids Don't Use Erlang" width="690" height="388">
  </a>
</div>

<p>In the case of Elixir you could work with Phoenix on the back end but use something like <a href="http://elm-lang.org/" rel="noopener nofollow ugc">Elm</a>, <a href="http://www.purescript.org/" rel="noopener nofollow ugc">PureScript</a> or <a href="https://bloomberg.github.io/bucklescript/" rel="noopener nofollow ugc">BuckleScript</a> to further push the envelope of the “functional programming experience” on the front end.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="11514" data-batch-url="/posts/batch_likers">
                        5
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/thinking-functional/1771/18">Post #17</a>
	                </div>
	            </div>
              <div id="likers-container-11514" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="11514"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #17"></div>
  </section>
</div>
    <div class="postbit" id="11531" data-post-id="11531">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="StefanHoutzager" src="/assets/icons/user-9f439610.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  StefanHoutzager
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Just on the incorporation of functional programming in languages like java and c#: <a href="http://queue.acm.org/detail.cfm?id=2611829" rel="noopener nofollow ugc">http://queue.acm.org/detail.cfm?id=2611829</a>  (Erik Meijer: “Mostly functional” programming does not work)</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="11531" data-batch-url="/posts/batch_likers">
                        1
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/thinking-functional/1771/19">Post #18</a>
	                </div>
	            </div>
              <div id="likers-container-11531" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="11531"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #18"></div>
  </section>
</div>
    <div class="postbit" id="11533" data-post-id="11533">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="mkunikow" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/mkunikow/120/235_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  mkunikow
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>There is no 100% pure functional language. You will always need to deal with state and side effects.<br>
But there should be clear separation in code: pure functions vs rest.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="11533" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/thinking-functional/1771/20">Post #19</a>
	                </div>
	            </div>
              <div id="likers-container-11533" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="11533"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #19"></div>
  </section>
</div>
    <div class="postbit" id="11535" data-post-id="11535">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Qqwy" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Qqwy/120/1349_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Qqwy
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>TypeCheck Core Team</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p><a class="mention" href="/u/mkunikow" rel="nofollow">@mkunikow</a>: It depends a little on your definition of ‘functional purity’. There are some implementations, most notably <a href="http://urbit.org/about/overview/" rel="noopener nofollow ugc">Nock/Urbit</a> comes to mind, that simply says ‘as far as code on our platform is concerned, there is nothing outside of the platform. Therefore, all function calls can be considered pure, and data structures can be made persistent.’</p>
<p>Other languages, like Haskell, that are basically syntactic sugar around the mathematical lambda calculus (which is pure by definition) preserve purity when dealing with side-effects by returning an object that represents a changed state of the world (It’s basically a reminder stating ‘Look! This was the second time I did a change!’). These values, which are of type IO in Haskell, can be used to chain multiple side-effectful operations together in a fixed order. This is necessary because there otherwise is no way to know in what order the functions are called, as this happens lazily. <a href="https://wiki.haskell.org/IO_inside" rel="noopener nofollow ugc">(more information on the Haskell wiki)</a></p>
<p>Can this be considered pure? Most people think yes, but of course this is subjective.</p>
<p>It is an interesting fact that the operations used for ‘passing the IO baton’ around together form a Monad, but you do not need to know how monads work in order to use side effects in Haskell.</p>
<hr>
<p>If people want I can write a little introduction to how Monads work. Of course, it is very easy to fall for the <a href="http://byorgey.wordpress.com/2009/01/12/abstraction-intuition-and-the-monad-tutorial-fallacy/" rel="noopener nofollow ugc">‘Monads are like Tacos’ fallacy</a>: It is a very abstract concept, and an explanation that worked for me might not work for you.</p>
<p>Nevertheless, I think I can make a stab at it, using some great analogies with Fruit Salads and cooking that have their origins in the <a href="https://github.com/Qqwy/elixir_fun_land" rel="noopener nofollow ugc">fun_land</a> package. <img src="https://forum.elixirforum.com/images/emoji/apple/slight_smile.png?v=15" title=":slight_smile:" class="emoji" alt=":slight_smile:" loading="lazy" width="20" height="20"></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="11535" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/thinking-functional/1771/21">Post #20</a>
	                </div>
	            </div>
              <div id="likers-container-11535" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="11535"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #20"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <a class="load-more-button" data-turbo-stream="true" href="/topics/1771/load_more?page=3">Load more posts (9 remaining)</a>
</div></template></turbo-stream>