title: How to install and import a library in haskell?
body: <p>In official tutorial <a href="https://wiki.haskell.org/Haskell_in_5_steps" rel="nofollow noreferrer">Haskell in 5 steps</a>, an example imports a library:</p>
  
  <pre><code>import Control.Parallel
  </code></pre>
  
  <p>Then I use ghc to compile:</p>
  
  <pre><code>ghc parallel.hs -o parallel -O2 --make -threaded -rtsopts
  </code></pre>
  
  <p>just as the tutorial tells me to do. (My filename is parallel.hs) But I got:</p>
  
  <pre><code>parallel.hs:1:1: error:
  Could not find module ‘Control.Parallel’
  Use -v to see a list of the files searched for.
    |
  1 | import Control.Parallel
    | ^^^^^^^^^^^^^^^^^^^^^^^
  </code></pre>
  
  <p>Then I stackoverflowed it and find <a href="https://stackoverflow.com/questions/9575886/control-parallel-compile-issue-in-haskell">this question</a>. So I:</p>
  
  <pre><code>cabal new-install parallel --lib
  </code></pre>
  
  <p>And get:</p>
  
  <pre><code>Resolving dependencies...
  Up to date 
  </code></pre>
  
  <p>Then I compiled it again, but got the same error.
  How to solve this? Did I miss any command line arguments?</p>
  
  <hr>
  
  <p>Well, after <code>cabal install parallel</code>, the library is imported, the program is compiled successfully, and runs as expected.</p>
  
  <p>I'll refer to documentations of cabal about the difference between <code>install</code> and <code>new-install</code></p>