Skip to content

Instantly share code, notes, and snippets.

@alanbuxton
Last active February 9, 2018 06:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alanbuxton/5cace0bef354496b6716 to your computer and use it in GitHub Desktop.
Save alanbuxton/5cace0bef354496b6716 to your computer and use it in GitHub Desktop.
cabal vs ghc-mod part 2
alan@alan-haskell01:~/tmp-ghc-mod$ cat tmp-ghc-mod.cabal
-- Initial tmp-ghc-mod.cabal generated by cabal init. For further
-- documentation, see http://haskell.org/cabal/users-guide/
name: tmp-ghc-mod
version: 0.1.0.0
-- synopsis:
-- description:
-- license:
license-file: LICENSE
-- author:
-- maintainer:
-- copyright:
-- category:
build-type: Simple
cabal-version: >=1.10
library
exposed-modules: Test
-- other-modules:
--build-depends: base ==4.6.*
build-depends: base
default-language: Haskell2010
################################################################################
alan@alan-haskell01:~/tmp-ghc-mod$ ghc-mod debug
Root directory: /home/alan/tmp-ghc-mod
Current directory: /home/alan/tmp-ghc-mod
Cabal file: Just "/home/alan/tmp-ghc-mod/tmp-ghc-mod.cabal"
GHC options: -global-package-db -user-package-db -XHaskell2010
Include directories: /home/alan/tmp-ghc-mod /home/alan/tmp-ghc-mod/dist/build /home/alan/tmp-ghc-mod/dist/build/autogen
Dependent packages:
System libraries: /usr/lib/ghc
################################################################################
And here's another example with an obviously incorrect haskell file.
alan@alan-haskell01:~/tmp-ghc-mod$ cat Test.hs
module Test where
broken :: Int -> Int
broken a = a ++ " some text"
With cabal file I get:
alan@alan-haskell01:~/tmp-ghc-mod$ ghc-mod check Test.hs
Test.hs:1:1:Could not find module `Prelude'It is a member of the hidden package `base'.Perhaps you need to add `base' to the build-depends in your .cabal file.It is a member of the hidden package `haskell98-2.0.0.2'.Perhaps you need to add `haskell98' to the build-depends in your .cabal file.It is a member of the hidden package `haskell2010-1.1.1.0'.Perhaps you need to add `haskell2010' to the build-depends in your .cabal file.Use -v to see a list of the files searched for.
Without cabal file I get:
alan@alan-haskell01:~/tmp-ghc-mod$ ghc-mod check Test.hs
Test.hs:4:12:Couldn't match expected type `[GHC.Types.Char]' with actual type `GHC.Types.Int'In the first argument of `(GHC.Base.++)', namely `a'In the expression: a GHC.Base.++ " some text"In an equation for `broken': broken a = a GHC.Base.++ " some text"
Test.hs:4:12:Couldn't match expected type `GHC.Types.Int' with actual type `[GHC.Types.Char]'In the expression: a GHC.Base.++ " some text"In an equation for `broken': broken a = a GHC.Base.++ " some text"
So better... but horribly verbose
###############################################################################################
ghc-mod debug output with cabal file
alan2@alan-haskell01:~/test1$ ghc-mod debug
Root directory: /home/alan2/test1
Current directory: /home/alan2/test1
Cabal file: Just "/home/alan2/test1/test1.cabal"
GHC options: -global-package-db -user-package-db -XHaskell98
Include directories: /home/alan2/test1 /home/alan2/test1/dist/build /home/alan2/test1/dist/build/autogen
Dependent packages:
System libraries: /usr/lib/ghc
without cabal file
alan2@alan-haskell01:~/test1$ ghc-mod debug
Root directory: /home/alan2/test1
Current directory: /home/alan2/test1
Cabal file: Nothing
GHC options:
Include directories:
Dependent packages:
System libraries: /usr/lib/ghc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment