-1

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

Michael Lafayette
  • 2,972
  • 3
  • 20
  • 54
  • `GHC.SrcLoc` is a module in the *base* package which only appears in recent versions of GHC. To use it, you will have to upgrade GHC. The import likely works on Windows and not Ubuntu because you probably got a recent version of GHC on windows, whereas the "official" Ubuntu version lags far behind. If you want to use the *srcloc* pacakge, you must import [`Data.Loc`](http://hackage.haskell.org/package/srcloc), *not* `GHC.SrcLoc`. – user2407038 Feb 12 '16 at 03:58
  • @user2407038 I tried that (Attemp #2) and it says "Could not find module 'Data.Loc'". This is such a pain because Java has had stack traces forever and I have to go through all this hassle just to get IDE friendly trace traces. – Michael Lafayette Feb 12 '16 at 04:21
  • @MichaelLafayette: While those screenshots make your question colorful, they don't provide the necessary information. Which GHC do you use on Windows? Which version of srcloc is installed on either? Which version of cabal do you use? – Zeta Feb 12 '16 at 06:39
  • I should point out that, because Haskell is lazy, it doesn't really *have* a call stack at run-time. (At least, not one with a useful shape.) So being able to have stack traces *at all* is something of an achievement. But that doesn't really address your question... – MathematicalOrchid Feb 12 '16 at 09:05
  • @MathematicalOrchid - I'm actually just using an implicit call stack - the "-prof" option isn't being used. That being said, in order to be used in industry, Haskell can't be the whiteboard language that it was. Something as simple as " http://i.imgur.com/KCXYHNk.png " can be a real convenience to humans, even if it isn't "pure". – Michael Lafayette Feb 12 '16 at 15:56

2 Answers2

3

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.

David Young
  • 10,713
  • 2
  • 33
  • 47
0

You must install the srcloc package; in the simple case where you are not using sandboxes, this is done by running cabal install srcloc at the command line.

Daniel Wagner
  • 145,880
  • 9
  • 220
  • 380
  • I tried that, both from my home directory and the IntelliJ plugin project directory. Still getting "Error:(11, 8) ghc: Could not find module `GHC.SrcLoc' Use -v to see a list of the files searched for." on "import GHC.SrcLoc" – Michael Lafayette Feb 12 '16 at 03:41
  • :-( I worked so hard on this little tool to make my print statements appear as hyperlinks in the IDE and it won't even work. – Michael Lafayette Feb 12 '16 at 03:45