cabal build for my project fails linking llvm-general package - haskell

I have a cabal project, when I issue cabal build I get this :
Building phjava-0.1.0.0...
Preprocessing executable 'phjava' for phjava-0.1.0.0...
[2 of 3] Compiling CodeGen ( src/CodeGen.hs, dist/build/phjava/phjava-tmp/CodeGen.o )
<no location info>: error:
<command line>: can't load .so/.DLL for: /usr/lib/libcurses.so (-lncursesw: cannot open shared object file: No such file or directory)
This is the output with --verbose=3 : verbose output
This is my cabal file :
name: phjava
version: 0.1.0.0
synopsis:
-- description:
-- license:
-- license-file:
homepage:
author: abnud1
maintainer: ahmad13932013#hotmail.com
category: Language
-- copyright:
build-type: Simple
-- extra-source-files:
cabal-version: >=1.10
executable phjava
main-is: Main.hs
-- other-modules:
-- other-extensions:
build-depends: base >= 4.7 && < 5 , parsec < 4, containers < 1 , regex-pcre < 1 , parsec-permutation < 1 , transformers < 1 , logfloat < 0.14, llvm-general-pure < 4, llvm-general, mtl < 3
hs-source-dirs: src
default-language: Haskell2010
ghc-options: -Wall
I have ghc 8.0.1, cabal 1.24, llvm-3.8.1 . I installed llvm-general by cloning the llvm-3.8 branch and running cabal install with -fshared-llvm.
I assure you I have ncurses installed, also libcurses.so file is a symlink to /usr/lib/libncurses.so, I also have /usr/lib/libncursesw.so (which is also a symlink to /usr/lib/libncursesw.so.6).
Last my OS is Arch Linux 64 bit and I also have ncurses5-compat-libs installed from AUR(and uninstalling it didn't help).

Related

Cannot install stack-run

Per instructions on page https://marketplace.visualstudio.com/items?itemName=UCL.haskelly , I'm trying:
% stack build stack-run
stack-run-0.1.1.4: configure
stack-run-0.1.1.4: build
-- While building custom Setup.hs for package stack-run-0.1.1.4 using:
/home/mark/.stack/setup-exe-cache/x86_64-linux/Cabal-simple_mPHDZzAJ_2.2.0.1_ghc-8.4.3 --builddir=.stack-work/dist/x86_64-linux/Cabal-2.2.0.1 build --ghc-options " -ddump-hi -ddump-to-file -fdiagnostics-color=always"
Process exited with code: ExitFailure 1
Logs have been written to: /home/mark/haskell/hl1/.stack-work/logs/stack-run-0.1.1.4.log
Configuring stack-run-0.1.1.4...
Preprocessing executable 'stack-run' for stack-run-0.1.1.4..
Building executable 'stack-run' for stack-run-0.1.1.4..
/tmp/stack2483/stack-run-0.1.1.4/unix/System/Console/Questioner.hs:4:14: warning:
-XOverlappingInstances is deprecated: instead use per-instance pragmas OVERLAPPING/OVERLAPPABLE/OVERLAPS
|
4 | {-# LANGUAGE OverlappingInstances #-}
| ^^^^^^^^^^^^^^^^^^^^
[1 of 5] Compiling System.Console.Questioner.Autocomplete ( unix/System/Console/Questioner/Autocomplete.hs, .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/stack-run/stack-run-tmp/System/Console/Questioner/Autocomplete.o )
[2 of 5] Compiling System.Console.Questioner.Util ( unix/System/Console/Questioner/Util.hs, .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/stack-run/stack-run-tmp/System/Console/Questioner/Util.o )
[3 of 5] Compiling System.Console.Questioner.ProgressIndicators ( unix/System/Console/Questioner/ProgressIndicators.hs, .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/stack-run/stack-run-tmp/System/Console/Questioner/ProgressIndicators.o )
[4 of 5] Compiling System.Console.Questioner ( unix/System/Console/Questioner.hs, .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/stack-run/stack-run-tmp/System/Console/Questioner.o )
[5 of 5] Compiling Main ( src/Main.hs, .stack-work/dist/x86_64-linux/Cabal-2.2.0.1/build/stack-run/stack-run-tmp/Main.o )
/tmp/stack2483/stack-run-0.1.1.4/src/Main.hs:18:1: error:
Could not find module ‘Distribution.PackageDescription.Parse’
Perhaps you meant
Distribution.PackageDescription.Parsec (from Cabal-2.2.0.1)
Distribution.PackageDescription.Check (from Cabal-2.2.0.1)
Distribution.PackageDescription.Quirks (from Cabal-2.2.0.1)
Use -v to see a list of the files searched for.
|
18 | import Distribution.PackageDescription.Parse
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OS: Debian 9 x64
I just installed stack today and created new project.
stack complained about some packages, so per Recommended actions I added following to stack.yaml:
extra-deps: [conduit-1.2.13.1, conduit-extra-1.1.17, resourcet-1.1.11, streaming-commons-0.1.19]
Stack version:
% stack --version
Version 1.7.1, Git revision 681c800873816c022739ca7ed14755e85a579565 (5807 commits) x86_64 hpack-0.28.2
name: hl1
version: 0.1.0.0
github: "githubuser/hl1"
license: BSD3
author: "Author name here"
maintainer: "example#example.com"
copyright: "2018 Author name here"
extra-source-files:
- README.md
- ChangeLog.md
# Metadata used when publishing your package
# synopsis: Short description of your package
# category: Web
# To avoid duplicated efforts in documentation and dealing with the
# complications of embedding Haddock markup inside cabal files, it is
# common to point users to the README.md file.
description: Please see the README on GitHub at <https://github.com/githubuser/hl1#readme>
dependencies:
- base >= 4.7 && < 5
library:
source-dirs: src
executables:
hl1-exe:
main: Main.hs
source-dirs: app
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
dependencies:
- hl1
tests:
hl1-test:
main: Spec.hs
source-dirs: test
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
dependencies:
- hl1
The main problem is indicated here:
Could not find module ‘Distribution.PackageDescription.Parse’
stack-run has not been updated to support being built against modern versions of Cabal. That module was removed as of Cabal 2.2.
There is an open PR on the stack-run repo which addresses this issue:
https://github.com/yamadapc/stack-run/pull/15/files#diff-f8f3412da88cd4806f23d59fe59ebc3bR19

Not in scope: type constructor or class ‘Test.Framework.TestSuite’ when trying to create unit tests

I'm writing a small library in Haskell, and want to have tests to accompany it. For testing I intend to use HFT, and the project as a whole is managed by stack. stack test fails for some reason with the following output:
[1 of 2] Compiling Main ( test/Ini.hs, .stack-work/dist/x86_64-linux-tinfo6/Cabal-2.0.1.0/build/ini-tests/ini-tests-tmp/Main.o ) │····························
[2 of 2] Compiling Paths_schemer ( .stack-work/dist/x86_64-linux-tinfo6/Cabal-2.0.1.0/build/ini-tests/autogen/Paths_schemer.hs, .stack-work/dist/x86_64-linux-tinfo6/Cabal-2.0.1.0/build/ini-tests/ini-tests-tm│····························
p/Paths_schemer.o ) │····························
│····························
/stuff/projects/schemer/.stack-work/dist/x86_64-linux-tinfo6/Cabal-2.0.1.0/build/ini-tests/autogen/Paths_schemer.hs:54:39: error: │····························
Not in scope: type constructor or class ‘Test.Framework.TestSuite’ │····························
No module named ‘Test.Framework’ is imported. │····························
│····························
/stuff/projects/schemer/.stack-work/dist/x86_64-linux-tinfo6/Cabal-2.0.1.0/build/ini-tests/autogen/Paths_schemer.hs:55:38: error: │····························
Not in scope: ‘Test.Framework.makeTestSuite’ │····························
No module named ‘Test.Framework’ is imported. │····························
My Ini.hs file that will later contain the tests is very bare-bone, just
import Test.Framework
main :: IO ()
main = htfMain htf_thisModulesTests
My package.yaml is
name: schemer
version: 0.1.0.0
github: "mpevnev/schemer"
license: BSD3
author: "Michail Pevnev"
maintainer: "mpevnev#gmail.com"
copyright: ""
extra-source-files: []
# Metadata used when publishing your package
# synopsis: Short description of your package
# category: Web
# To avoid duplicated efforts in documentation and dealing with the
# complications of embedding Haddock markup inside cabal files, it is
# common to point users to the README.md file.
description: Please see the README on GitHub at <https://github.com/mpevnev/schemer#readme>
dependencies:
- attoparsec
- base >= 4.7 && < 5
- text
library:
source-dirs: src
tests:
ini-tests:
main: Ini.hs
source-dirs: test
ghc-options:
- -threaded
- -rtsopts
- -with-rtsopts=-N
- -F
- -pgmF htfpp
dependencies:
- schemer
- text
- HTF
Here's the autogenerated schemer.cabal:
-- This file has been generated from package.yaml by hpack version 0.28.2.
--
-- see: https://github.com/sol/hpack
--
-- hash: 17ae623236b8f5b101f56373c975656e898efa7506acb143db7375f229509a79
name: schemer
version: 0.1.0.0
description: Please see the README on GitHub at <https://github.com/mpevnev/schemer#readme>
homepage: https://github.com/mpevnev/schemer#readme
bug-reports: https://github.com/mpevnev/schemer/issues
author: Michail Pevnev
maintainer: mpevnev#gmail.com
license: BSD3
license-file: LICENSE
build-type: Simple
cabal-version: >= 1.10
source-repository head
type: git
location: https://github.com/mpevnev/schemer
library
exposed-modules:
Control.Scheme.Ini
Control.Schemer
other-modules:
Paths_schemer
hs-source-dirs:
src
build-depends:
attoparsec
, base >=4.7 && <5
, text
default-language: Haskell2010
test-suite ini-tests
type: exitcode-stdio-1.0
main-is: Ini.hs
other-modules:
Paths_schemer
hs-source-dirs:
test
ghc-options: -threaded -rtsopts -with-rtsopts=-N -F -pgmF htfpp
build-depends:
HTF
, attoparsec
, base >=4.7 && <5
, schemer
, text
default-language: Haskell2010
I'm not sure what's wrong and what is this Paths_schemer thing. Help is appreciated.
The options -F -pgmF htfpp are switched on globally. This applies the HTF preprocessor to all the files of the test suite, including the autogenerated Paths_schemer.
The more scalable solution is to enable the preprocessor only on files that import Test.Framework, using the OPTIONS_GHC pragma in each one:
{-# OPTIONS_GHC -F -pgmF htfpp #-}
Another way is to set other-modules: [] in the test-suite section in package.yaml to avoid generating Paths_schemer, although that only solves the problem for this one module.

Haskell Failed to load interface for module

Hello i am trying to use a module inside another module but it seems it just won't work.I tried updating the cabal file,stack,i reinstalled the platform,ghc and everything and it just won't let it import modules.I tried adding in the cabal file both other-modules and home-modules section ..to no effect.What could be the problem?
Modules:
module Test where
test::IO()
test=do
elem<-getLine
print elem
module Main where
import Test
main :: IO ()
main = do
putStrLn "hello world"
Cabal-build renders this error:
$ cabal build
Resolving dependencies...
Configuring console-0.1.0.0...
Warning: To use the 'default-language' field the package needs to specify at
least 'cabal-version: >= 1.10'.
Preprocessing executable 'console' for console-0.1.0.0..
Building executable 'console' for console-0.1.0.0..
<no location info>: warning: [-Wmissing-home-modules]
These modules are needed for compilation but not listed in your .cabal file's other-modules: Test
<no location info>: warning: [-Wmissing-home-modules]
These modules are needed for compilation but not listed in your .cabal file's other-modules: Test
When i build with Stack i get this error:
C:\<path>\Main.hs:4:1: error:
Failed to load interface for `Test'
Use -v to see a list of the files searched for.
Failed, modules loaded: none.
H>>= :module + *Main
Cabal file:
name: console
version: 0.1.0.0
-- synopsis:
-- description:
homepage: https://github.com/githubuser/console#readme
license: BSD3
license-file: LICENSE
author: Bercovici Adrian Simon
maintainer: example#example.com
copyright: 2018 Bercovici Adrian Simon
category: Web
build-type: Simple
cabal-version: >=1.2
extra-source-files: README.md
Executable console
hs-source-dirs: src
main-is: Main.hs
default-language: Haskell2010
build-depends: base >= 4.7 && < 5
other-modules: Test
The other-modules: directive must go inside the Executable console stanza.

Haskell cabal confused about file and module name

In my haskell project, I have the following directory structure (some entries are missing but not relevant to this problem)
- quanthas
- quanthas.cabal
- src/
- QuantHas/
- Settings.hs
My Settings.hs file contains this module header
module QuantHas.Settings(module QuantHas.Settings) where
My cabal file looks like this
Name: QuantHas
Version: 0.0
Description:
QuantHas project is an attempt to port QuantLib to Haskell keeping the functional flavor of Haskell.
License: BSD3
License-file: LICENSE
Build-Type: Simple
Cabal-Version: >=1.10
Library
Build-Depends: base >= 3 && < 5, array >= 0.2
Exposed-modules: QuantHas.Time.Frequency
QuantHas.Time.TimeUnit
QuantHas.Time.Period
QuantHas.Time.Date
QuantHas.Time.DayCounter
QuantHas.Time.BusinessDayConvention
QuantHas.Time.Calendar
QuantHas.Time.Calendars.UnitedKingdom
QuantHas.Time.Schedule
QuantHas.Settings
QuantHas.Require
default-language: Haskell2010
hs-source-dirs: src
-- ghc-options: -Wall
test-suite QuantHas-tests
type: exitcode-stdio-1.0
hs-source-dirs: testsuite
main-is: Tests.hs
default-language: Haskell2010
When I execute
cabal install --enable-tests
I get this message
src/Quanthas/Settings.hs:17:8: error:
File name does not match module name:
Saw: ‘QuantHas.Settings’
Expected: ‘Quanthas.Settings’
This seems wrong. However, what if we do what cabal expects. So the Settings.hs module header now is
module Quanthas.Settings(module Quanthas.Settings) where
Cabal now says
src/QuantHas/Settings.hs:17:8: error:
File name does not match module name:
Saw: ‘Quanthas.Settings’
Expected: ‘QuantHas.Settings’
And it's at this ppint that I give up and turn to SO. Can anyone help me understand what is going on?
Versions info:
Platform: Macbook Pro running MacOS 10.12.3
Haskell: 8.0.1
Cabal: 1.24.0.0
Thanks!
The issue is that there is a typo in one of the import statements in a different module. Since you're on a case-insensitive filesystem (OS X), GHC is able to find the module contents, but upon checking the module header finds it mismatches with the import statement and errors out.

How to avoid recompiling in this cabal file?

I've been working on this Haskell project, and I have a cabal file for it. Now, my project is structured as a library that implements a simple interpreter. I also have a very short Main file which needs to be build into an executable to call the library. What I want to do is:
1) compile the library and expose some of the modules
2) compile the executable
I have a cabal file that works and seems to do this. The problem is that when it compiles the executable it recompiles all the modules which have already been compiled in step (1). I don't quite understand why it does this - is there any way to stop it, short of creating two separate cabal files?
I don't really want to create two separate cabal files, because cabal doesn't seem to like having both the cabal files in the same directory, and I don't really want to set up a separate project directory for the second step, since it basically just amounts to compiling a single file.
cabal-version: >= 1.6
build-type: Simple
name: HaSC
version: 0.2.3
license: OtherLicense
category: Language
author: Chris B
maintainer: Chris B
copyright: Chris B 2010 - 2011
synopsis: (HA)skell (S)ound (C)hange applier (HaSC) library
description: HaSC implements a little language for applying sound changes to words
homepage: http://www.chrisdb.me.uk/redmine/projects/haskell-sound-change
stability: Alpha
data-files: doc/HaSCDoc.pdf
license-file: LICENSE
library
build-depends:
base >= 4.3,
containers >= 0.3,
parsec >= 3,
parallel >= 3.1,
deepseq >= 1.1,
mtl >= 1.1,
transformers >= 0.2,
text >= 0.10,
text-icu >= 0.6.3,
pretty >= 1,
directory >= 1.1,
filepath >= 1.2
hs-source-dirs: src
exposed-modules: HaSC.IO.Disk,
HaSC.IO.Memory,
HaSC.Exec
other-modules: HaSC.AST,
HaSC.IO,
HaSC.IdentMap,
HaSC.Parse,
HaSC.Regex,
HaSC.Representation,
HaSC.Transformations,
HaSC.Search,
HaSC.State
executable HaSC
GHC-Options: -rtsopts
hs-source-dirs: src
main-is: Main.hs
In your executable section, add the library in Build-Depends so that the executable depends on the library.
There's a small gotcha, though: You also have to move the Main.hs of the executable (and any other source files specific to the executable) to a different subdirectory and specify a different Hs-Source-Dirs so that it doesn't pick up the library modules by being in the same folder.
executable HaSC
Build-Depends: HaSC
Main-Is: Main.hs
Hs-Source-Dirs: foo -- Directory you moved Main.hs to
For this to work, you will need to specify Cabal-Version >= 1.8. See Cabal ticket #89 for the details.

Resources