[Haskell-beginners] Strange type error with hsc2hs and cabal

PICCA Frederic-Emmanuel frederic-emmanuel.picca at synchrotron-soleil.fr
Sat Jan 30 22:11:31 UTC 2016


Hello, I am still playing with FFI. Now I create a real project with cabal end build a library and an executable for my project.

---hkl.cabal---
name:                hkl
version:             0.1.0.0

executable ghkl
  main-is:             ghkl.hs
  build-depends:       base >=4.8 && <4.9
                     , containers >=0.5 && <0.6
                     , filepath
                     , gtk >=0.13 && <0.14
                     , hkl
  hs-source-dirs:      src
  default-language:    Haskell2010
  pkgconfig-depends:   hkl
  build-tools:         hsc2hs

library
  exposed-modules:    Hkl, Hkl.Types, Hkl.C, Hkl.DArray
  other-extensions:    CPP, ForeignFunctionInterface, EmptyDataDecls, TypeFamilies, FlexibleInstances, FlexibleContexts, RecordWildCards
  build-depends:       base >=4.8 && <4.9, containers >=0.5 && <0.6
  hs-source-dirs:      src
  build-tools:         hsc2hs
  default-language:    Haskell2010
  pkgconfig-depends: hkl
--- ---

but when I compile my project I get this errormessage which is really strange.

$ cabal build
Package has never been configured. Configuring with default flags. If this
fails, please run configure manually.
Warning: The package list for 'hackage.haskell.org' is 17.1 days old.
Run 'cabal update' to get the latest list of available packages.
Resolving dependencies...
Configuring hkl-0.1.0.0...
Warning: 'data-files: ../../gui/ghkl.ui' is a relative path outside of the
source tree. This will not work when generating a tarball with 'sdist'.
Building hkl-0.1.0.0...
Preprocessing library hkl-0.1.0.0...
[1 of 4] Compiling Hkl.Types        ( src/Hkl/Types.hs, dist/build/Hkl/Types.o )
[2 of 4] Compiling Hkl.C            ( src/Hkl/C.hs, dist/build/Hkl/C.o )
[3 of 4] Compiling Hkl.DArray       ( dist/build/Hkl/DArray.hs, dist/build/Hkl/DArray.o )
[4 of 4] Compiling Hkl              ( src/Hkl.hs, dist/build/Hkl.o )
In-place registering hkl-0.1.0.0...
Preprocessing executable 'ghkl' for hkl-0.1.0.0...
[1 of 4] Compiling Hkl.Types        ( src/Hkl/Types.hs, dist/build/ghkl/ghkl-tmp/Hkl/Types.o )
[2 of 4] Compiling Hkl.C            ( src/Hkl/C.hs, dist/build/ghkl/ghkl-tmp/Hkl/C.o )
[3 of 4] Compiling Hkl              ( src/Hkl.hs, dist/build/ghkl/ghkl-tmp/Hkl.o )
[4 of 4] Compiling Main             ( src/ghkl.hs, dist/build/ghkl/ghkl-tmp/Main.o )

src/ghkl.hs:44:39:
    Couldn't match expected type ‘Hkl.Types.EngineList’
                with actual type ‘Hkl.EngineList’
    NB: ‘Hkl.Types.EngineList’
          is defined in ‘Hkl.Types’ in package ‘hkl-0.1.0.0’
        ‘Hkl.EngineList’ is defined at src/Hkl/Types.hs:22:1-74
    In the first argument of ‘Hkl.engineListEnginesGet’, namely
      ‘engines’
    In a stmt of a 'do' block: tmp <- Hkl.engineListEnginesGet engines


if I add a other-modules to ghkl an remove the hkl dependecy it work great.

so what is wrong with this project.

PS: the DArray module is indeed the one using hsc2hs :)


Thansk for your help


Frederic


More information about the Beginners mailing list