Search code examples
haskellubuntu-14.04stack-tracecabalcabal-install

Haskell cannot import GHC.SrcLoc


I can't get module "GHC.SrcLoc" in package "srcloc" on Ubuntu Haskell ...

-- "import" works on Windows, but not on Ubuntu 14.04

Could not find GHC.SrcLoc

-- Module name is "GHC.SrcLoc"

GHC.SrcLoc documentation

-- Cabal build error below

enter image description here

Take 2: tried adding package "srcloc" to Cabal dependencies

enter image description here

^ Adding "srcloc" to dependencies causes "cabal configuration failed". ^

GHCI version...

$ ghci --version
The Glorious Glasgow Haskell Compilation System, version 7.6.3

Please help

https://hackage.haskell.org/package/base-4.8.2.0/docs/GHC-SrcLoc.html

My Haskell Code...

https://github.com/JohnReedLOL/HaskellPrintDebugger

* Attempt #1 *

:~/IdeaProjects/IntelliJHaskellPrintDebugger$ cabal install srcloc
Resolving dependencies...
All the requested packages are already installed:
srcloc-0.5.1.0
Use --reinstall if you want to reinstall anyway.

* Attempt #2 *

-- Tried replacing "import GHC.SrcLoc" with "import Data.Loc", but failed.

enter image description here

-- Tried adding "srcLock" to "build-depends" in .cabal, but failed.

enter image description here

^ Hopeless


Solution

  • Since Data.SrcLoc is a part of the GHC distribution and it wasn't added until (I believe) GHC 7.10.1, it will not exist in GHC 7.6.3. If you install the latest version of GHC, this should work fine.

    The package you are seeing that is called srcloc appears to be unrelated to what you want, and does not provide the GHC.SrcLoc module. The GHC.SrcLoc module is instead provided by the GHC base standard library, which is included in (and requires) a newer version of GHC.

    Newer versions of GHC also include a lot of other nice features that 7.6.3 (which was released more than 2 years ago) doesn't have.

    You also mentioned stack traces, so you might be interested in this.