title: Unable to reference a package
body: <p>I'm failing to run (or compile) a simple script due to a reportedly missing <code>Text.Pandoc.JSON</code> dependency. This question is similar to another one: <a href="https://stackoverflow.com/questions/21273070/pandoc-could-not-find-module-for-installed-module">Pandoc &#39;Could not find module ...&#39; for installed module</a></p>
  <p>Here's the script:</p>
  <pre><code>import Text.Pandoc.JSON
  
  pagebreakXml :: String
  pagebreakXml = &quot;&lt;w:p&gt;&lt;w:r&gt;&lt;w:br w:type=\&quot;page\&quot;/&gt;&lt;/w:r&gt;&lt;/w:p&gt;&quot;
  
  pagebreakBlock :: Block
  pagebreakBlock = RawBlock (Format &quot;openxml&quot;) pagebreakXml
  
  blockSwapper :: Block -&gt; Block
  blockSwapper (Para [Str &quot;&lt;div class=\&quot;docxPageBreak\&quot;&gt;&lt;/div&gt;&quot;])  = pagebreakBlock
  blockSwapper blk = blk
  
  main = toJSONFilter blockSwapper
  </code></pre>
  <p>In order to compile it, I installed Haskell as well as <code>pandoc</code> package like this:</p>
  <pre><code>$ curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
  $ cabal install pandoc
  </code></pre>
  <p>Installation took roughly 20 minutes.</p>
  <p>Now, when I try to run it, I get this:</p>
  <pre><code>$ runghc -v docx-page-filter.hs
  Glasgow Haskell Compiler, Version 8.8.3, stage 2 booted by GHC version 8.6.3
  Using binary package database: /Users/eugene/.ghcup/ghc/8.8.3/lib/ghc-8.8.3/package.conf.d/package.cache
  package flags []
  loading package database /Users/eugene/.ghcup/ghc/8.8.3/lib/ghc-8.8.3/package.conf.d
  wired-in package ghc-prim mapped to ghc-prim-0.5.3
  wired-in package integer-wired-in mapped to integer-gmp-1.0.2.0
  wired-in package base mapped to base-4.13.0.0
  wired-in package rts mapped to rts
  wired-in package template-haskell mapped to template-haskell-2.15.0.0
  wired-in package ghc mapped to ghc-8.8.3
  package flags []
  loading package database /Users/eugene/.ghcup/ghc/8.8.3/lib/ghc-8.8.3/package.conf.d
  wired-in package ghc-prim mapped to ghc-prim-0.5.3
  wired-in package integer-wired-in mapped to integer-gmp-1.0.2.0
  wired-in package base mapped to base-4.13.0.0
  wired-in package rts mapped to rts-1.0
  wired-in package template-haskell mapped to template-haskell-2.15.0.0
  wired-in package ghc mapped to ghc-8.8.3
  *** Desugar:
  *** Simplify [expr]:
  !!! Simplify [expr]: finished in 0.18 milliseconds, allocated 0.056 megabytes
  *** CorePrep [expr]:
  !!! CorePrep [expr]: finished in 3.22 milliseconds, allocated 1.706 megabytes
  *** ByteCodeGen [Ghci1]:
  !!! ByteCodeGen [Ghci1]: finished in 0.11 milliseconds, allocated 0.029 megabytes
  Loading package ghc-prim-0.5.3 ... linking ... done.
  Loading package integer-gmp-1.0.2.0 ... linking ... done.
  *** gcc:
  gcc -DTABLES_NEXT_TO_CODE -B/Users/eugene/.ghcup/ghc/8.8.3/lib/ghc-8.8.3/base-4.13.0.0 --print-file-name libiconv.dylib
  *** gcc:
  gcc -DTABLES_NEXT_TO_CODE -B/Users/eugene/.ghcup/ghc/8.8.3/lib/ghc-8.8.3/base-4.13.0.0 --print-file-name liblibiconv.dylib
  *** gcc:
  gcc -DTABLES_NEXT_TO_CODE -B/Users/eugene/.ghcup/ghc/8.8.3/lib/ghc-8.8.3/base-4.13.0.0 --print-file-name iconv.lib
  *** gcc:
  gcc -DTABLES_NEXT_TO_CODE -B/Users/eugene/.ghcup/ghc/8.8.3/lib/ghc-8.8.3/base-4.13.0.0 --print-file-name libiconv.lib
  *** gcc:
  gcc -DTABLES_NEXT_TO_CODE -B/Users/eugene/.ghcup/ghc/8.8.3/lib/ghc-8.8.3/base-4.13.0.0 --print-file-name libiconv.dll.a
  *** gcc:
  gcc -DTABLES_NEXT_TO_CODE -B/Users/eugene/.ghcup/ghc/8.8.3/lib/ghc-8.8.3/base-4.13.0.0 --print-file-name iconv.dll.a
  *** gcc:
  gcc -DTABLES_NEXT_TO_CODE -B/Users/eugene/.ghcup/ghc/8.8.3/lib/ghc-8.8.3/base-4.13.0.0 --print-file-name libiconv.a
  *** gcc:
  gcc -DTABLES_NEXT_TO_CODE -B/Users/eugene/.ghcup/ghc/8.8.3/lib/ghc-8.8.3/base-4.13.0.0 --print-file-name iconv.a
  *** gcc:
  gcc -DTABLES_NEXT_TO_CODE -B/Users/eugene/.ghcup/ghc/8.8.3/lib/ghc-8.8.3/base-4.13.0.0 --print-file-name libiconv
  *** gcc:
  gcc -DTABLES_NEXT_TO_CODE -B/Users/eugene/.ghcup/ghc/8.8.3/lib/ghc-8.8.3/base-4.13.0.0 --print-file-name iconv
  Loading package base-4.13.0.0 ... linking ... done.
  Search directories (user):
  Search directories (gcc):
  *** Desugar:
  *** Simplify [expr]:
  !!! Simplify [expr]: finished in 0.07 milliseconds, allocated 0.044 megabytes
  *** CorePrep [expr]:
  !!! CorePrep [expr]: finished in 0.03 milliseconds, allocated 0.014 megabytes
  *** ByteCodeGen [Ghci1]:
  !!! ByteCodeGen [Ghci1]: finished in 0.05 milliseconds, allocated 0.028 megabytes
  *** Desugar:
  *** Simplify [expr]:
  !!! Simplify [expr]: finished in 0.10 milliseconds, allocated 0.061 megabytes
  *** CorePrep [expr]:
  !!! CorePrep [expr]: finished in 0.04 milliseconds, allocated 0.022 megabytes
  *** ByteCodeGen [Ghci1]:
  !!! ByteCodeGen [Ghci1]: finished in 0.11 milliseconds, allocated 0.065 megabytes
  *** Chasing dependencies:
  Chasing modules from:
  !!! Chasing dependencies: finished in 0.04 milliseconds, allocated 0.021 megabytes
  Stable obj: {}
  Stable BCO: {}
  unload: retaining objs []
  unload: retaining bcos []
  Ready for upsweep []
  Upsweep completely successful.
  *** Deleting temp files:
  Deleting:
  *** Chasing dependencies:
  Chasing modules from: *docx-page-filter.hs
  !!! Chasing dependencies: finished in 0.60 milliseconds, allocated 0.334 megabytes
  Stable obj: {}
  Stable BCO: {}
  unload: retaining objs []
  unload: retaining bcos []
  Ready for upsweep
    [NONREC
        ModSummary {
           ms_hs_date = 2020-07-01 09:51:29.83381948 UTC
           ms_mod = Main,
           ms_textual_imps = [(Nothing, Prelude), (Nothing, Text.Pandoc.JSON)]
           ms_srcimps = []
        }]
  *** Deleting temp files:
  Deleting:
  compile: input file docx-page-filter.hs
  *** Checking old interface for Main (use -ddump-hi-diffs for more details):
  [1 of 1] Compiling Main             ( docx-page-filter.hs, interpreted )
  *** Parser [Main]:
  !!! Parser [Main]: finished in 0.35 milliseconds, allocated 0.332 megabytes
  *** Renamer/typechecker [Main]:
  !!! Renamer/typechecker [Main]: finished in 1.57 milliseconds, allocated 0.021 megabytes
  
  docx-page-filter.hs:1:1: error:
      Could not find module ‘Text.Pandoc.JSON’
      Locations searched:
        Text/Pandoc/JSON.hs
        Text/Pandoc/JSON.lhs
        Text/Pandoc/JSON.hsig
        Text/Pandoc/JSON.lhsig
    |
  1 | import Text.Pandoc.JSON
    | ^^^^^^^^^^^^^^^^^^^^^^^
  Upsweep partially successful.
  *** Deleting temp files:
  Deleting:
  Failed, no modules loaded.
  *** Deleting temp files:
  Deleting:
  *** Deleting temp dirs:
  Deleting:
  $
  </code></pre>
  <p>When I try to compile it via <code>ghc --make -v docx-page-filter.hs</code>, I get a similar output.</p>
  <p>Things I've noticed that might be of help:</p>
  <ul>
  <li><p>the output above contains these lines:</p>
  <pre><code>Search directories (user):
  Search directories (gcc):
  </code></pre>
  <p><strong>Does this mean the installed libraries are not in a compiler's <em>search path</em>?</strong> Is it possible to manually tell the compiler where to look for the packages?</p>
  </li>
  <li><p>The following commands output nothing:</p>
  <pre><code>$ cabal list --installed | grep pandoc
  $
  $ ghc-pkg list | grep pandoc
  $
  </code></pre>
  <p>However, running the following reveals <code>pandoc</code>:</p>
  <pre><code>$ ls -l /Users/eugene/.cabal/store/ghc-8.8.3/ | grep pndc
  drwxr-xr-x    5 eugene  staff   160 Jul  1 15:07 pndc-2.10-1cd05aed
  drwxr-xr-x    5 eugene  staff   160 Jul  1 15:07 pndc-2.10-e61ae373
  drwxr-xr-x    5 eugene  staff   160 Jul  1 14:52 pndc-typs-1.21-39168129
  $
  </code></pre>
  </li>
  <li><p>Attempts to install or re-install <code>pandoc</code> result in a no-op:</p>
  <pre><code>$ cabal install pandoc
  Resolving dependencies...
  Up to date
  Symlinking 'pandoc'
  $
  $ cabal install pandoc --reinstall
  Resolving dependencies...
  Up to date
  Symlinking 'pandoc'
  $
  </code></pre>
  </li>
  </ul>
  <p><strong>Can someone spot what am I doing wrong?</strong> I don't need a <code>cabal.project</code> file or anything, my need is to compile a single file and go with it. But I can try and explore <code>cabal.project</code>.</p>