title: run haskell operations in parallel or multithreaded
body: <p>I have just started learning functional programming and Haskell and am I not even close to understanding the syntax and how it works because it is very different from what I have been used to before (ruby, php, C# or node for instance, which are OOP languages - more or less).</p>
  
  <p>I am am trying to put together a small program that checks for solutions for <a href="http://en.wikipedia.org/wiki/Brocard&#39;s_problem" rel="nofollow noreferrer">Brocard's Problem</a> or so called <strong>Brown Numbers</strong> and I first created a draft in ruby, but I discovered that Haskell is much more appropriate for doing mathematical expressions. I've asked a <a href="https://stackoverflow.com/questions/24862938/ruby-while-loop-translated-to-haskell">question</a> previously and I got an answer pretty quick on how to translate my ruby code to Haskell:</p>
  
  <pre><code>results :: [(Integer, Integer)] --Use instead of `Int` to fix overflow issue
  results =  [(x,y) | x &lt;- [1..1000], y &lt;- [1..1000] , 1 + fac x == y*y]
      where fac n = product [1..n]
  </code></pre>
  
  <p>I changed that slightly so I can run the same operation from and up to whatever number I want, because the above will do it from <code>1</code> up to <code>1000</code> or any hardcoded number but I would like to be able to decide the interval it should go through, ergo:</p>
  
  <pre><code>pairs :: (Integer, Integer) -&gt; [(Integer, Integer)]
  pairs (lower, upper) =  [(m, n) | m &lt;- [lower..upper], n &lt;- [lower..upper], 1 + factorial n == m*m] where factorial n = product [1..n]
  </code></pre>
  
  <p>The reason I ask this questions is that I was thinking if I could run this operations in parallel (and/or on multiple threads and/or cores) and append the results to the same variable.</p>
  
  <p>I have not yet understood the parallel processing in Haskell or the threading model, but in ruby a good example of how the threading model works is something like <a href="http://www.tutorialspoint.com/ruby/ruby_multithreading.htm" rel="nofollow noreferrer">this</a>:</p>
  
  <pre><code>def func1
    i=0
    while i&lt;=2
      puts "func1 at: #{Time.now}"
      sleep(2)
      i=i+1
    end
  end
  
  def func2
    j=0
    while j&lt;=2
      puts "func2 at: #{Time.now}"
      sleep(1)
      j=j+1
    end
  end
  
  puts "Started At #{Time.now}"
  t1=Thread.new{func1()}
  t2=Thread.new{func2()}
  t1.join
  t2.join
  puts "End at #{Time.now}"
  </code></pre>
  
  <p>And in my case, the <code>func1</code> and <code>func2</code> would be the same function <code>results</code> computed on different intervals (<code>[1..1000] -&gt; [i..j]</code>).</p>
  
  <p>I would appreciate some help with this as I am not capable of doing it myself at this point :)</p>