Haskell reexport linker errors - haskell

I want to have a function in a Foo.Internal module that is used by other things in there, but it should also be exposed by the Foo module. When I reexport the function from Foo to use elsewhere I get linker errors. I am using stack to build the code, so it might be an issue there, or with cabal, not sure.
Minimal working example:
module Foo.Internal where
secrets = "stuff"
module Foo(secrets) where
import Foo.Internal (secrets)
module Main where
import Foo
main = putStrLn secrets
When I compile this with stack build I get
package-0.1.0.0: build
Preprocessing library package-0.1.0.0...
[1 of 2] Compiling Foo.Internal ( src/Foo/Internal.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/Foo/Internal.o )
[2 of 2] Compiling Foo ( src/Foo.hs, .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/Foo.o )
In-place registering package-0.1.0.0...
Preprocessing executable 'package-exe' for package-0.1.0.0...
Linking .stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/package-exe/package-exe ...
.stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/package-exe/package-exe-tmp/Main.o:(.text+0x26): undefined reference to `packazuEPdwTk5e5ZZOCOiVJMdOJ3P_FooziInternal_secrets_closure'
.stack-work/dist/x86_64-linux/Cabal-1.22.5.0/build/package-exe/package-exe-tmp/Main.o: In function `S2Re_srt':
(.data+0x40): undefined reference to `packazuEPdwTk5e5ZZOCOiVJMdOJ3P_FooziInternal_secrets_closure'
collect2: error: ld returned 1 exit status

Related

Could not load my own modules in ghci haskell

i am trying to load a module called Point.hs into a file called Circle.hs by this way:
module Figures.Circle
( Circle(..)
, getArea
, getPerimeter
) where
import qualified Figures.Point as P
here is my Point.hs file:
module Figures.Point
( Point(..)
) where
this is my directory´s tree:
Figures/
Point.hs
Circle.hs
and this is what ghci´s error says:
Circle.hs:7:1: error:
Could not find module `Figures.Point'
Locations searched:
Figures\Point.hs
Figures\Point.lhs
Figures\Point.hsig
Figures\Point.lhsig
|
7 | import qualified Figures.Point as P
I follow this guide.
I get the same error if I call ghci from within the Figures directory, that can be avoided by calling ghci from the parent directory, so ghci Figures\Circle.hs.

Fay can't find fay-base

I want to use Fay with Yesod, but can't get Fay typechecking to work.
Will appreciate any advice.
$ stack build
[ 9 of 11] Compiling Handler.Home ( src/Handler/Home.hs, .stack-work/dist/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/Cabal-2.4.0.1/build/Handler/Home.o )
/home/user/code/myproject/src/Handler/Home.hs:121:13: error:
_ Exception when trying to run compile-time code:
ghc-pkg describe error:
Timestamp 2019-05-07 18:46:44 UTC for /opt/ghc/8.6.5/lib/ghc-8.6.5/package.conf.d/package.cache
ghc-pkg: cannot find package fay-base <- ########### Why?
GHC package manager version 8.6.5
using cache: /opt/ghc/8.6.5/lib/ghc-8.6.5/package.conf.d/package.cache
db stack: ["/opt/ghc/8.6.5/lib/ghc-8.6.5/package.conf.d"]
flag db stack: ["/opt/ghc/8.6.5/lib/ghc-8.6.5/package.conf.d"]
CallStack (from HasCallStack):
error, called at src/Fay/Compiler/Packages.hs:70:24 in fay-0.24.0.3-CdLcUWVJEOpLCiYHkNVTai:Fay.Compiler.Packages
Code: fayFile' (ConE 'StaticR) "HelloWorld"
_ In the untyped splice: $(fayFile' (ConE 'StaticR) "HelloWorld")
|
121 | $( fayFile' (ConE 'StaticR) "HelloWorld" )
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Fay packages are not yet in stackage, so I added them to stack.yaml as extra-deps:
extra-deps: - fay-0.24.0.3
- fay-base-0.21.1.1
- fay-dom-0.5.0.1
- fay-text-0.3.2.2
- yesod-fay-0.10.0
and to package.yaml as dependencies:
dependencies:
... more dependencies ...
- fay == 0.24.0.3
- fay-base == 0.21.1.1
- fay-dom == 0.5.0.1
- fay-text == 0.3.2.2
- yesod-fay == 0.10.0
Fay packages are in the local package database:
$ stack exec -- ghc-pkg list
/opt/ghc/8.6.5/lib/ghc-8.6.5/package.conf.d
Cabal-2.4.0.1
array-0.5.3.0
base-4.12.0.0
...
/home/user/.stack/snapshots/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/lts-13.30/8.6.5/pkgdb
Cabal-2.4.1.0
Diff-0.3.4
HUnit-1.6.0.0
...
yesod-1.6.0
yesod-core-1.6.14
yesod-form-1.6.5
yesod-newsfeed-1.6.1.0
yesod-persistent-1.6.0.2
yesod-static-1.6.0.1
/home/user/code/myproject/.stack-work/install/x86_64-linux-dkda49f7ca9b244180d3cfb1987cbc9743/lts-13.30/8.6.5/pkgdb
fay-0.24.0.3
fay-base-0.21.1.1
fay-dom-0.5.0.1
fay-text-0.3.2.2
yesod-fay-0.10.0
However trying to set HASKELL_PACKAGE_SANDBOX to the local database as Fay Troubleshooting suggests doesn't work, because sandboxes containing the string .stack are ignored in yesod-fay.
If I remove that check from yesod-fay and force the --package-db to point to the local database, it still doesn't work, complains that fay-base can't find the fay package.
$ stack build
/home/user/code/myproject/src/Handler/Home.hs:121:13: error:
• Exception when trying to run compile-time code:
Unable to compile Fay module "HelloWorld":
ghc: <command line>: cannot satisfy -package fay-base-0.21.1.1:
fay-base-0.21.1.1-91eIy2f24Wa5OHg9LMre7 is unusable due to missing dependencies:
fay-0.24.0.3-CdLcUWVJEOpLCiYHkNVTai
(use -v for more information)
CallStack (from HasCallStack):
error, called at ./Yesod/Fay.hs:483:3 in yesod-fay-0.10.9999-CzTT9fyZ6636pi0gIof7Ge:Yesod.Fay
Code: fayFile' (ConE 'StaticR) "HelloWorld"
• In the untyped splice: $(fayFile' (ConE 'StaticR) "HelloWorld")
|
121 | $( fayFile' (ConE 'StaticR) "HelloWorld" )
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Update: not using satck or cabal and using packages that are installed system-wide, this error doesn't occur. I guess the problem is in my local stack package database (the one in .stack-work)
I concluded that fay doesn't work with stack.

Problems updating cabal-install v. 1.20.0.3

Problems updating cabal-install v. 1.20.0.3
The following is what I made
C:\Windows\system32>cabal update
Downloading the latest package list from hackage.haskell.org
Note: there is a new version of cabal-install available.
To upgrade, run: cabal install cabal-install
C:\Windows\system32>cabal install cabal-install
Resolving dependencies...
Configuring network-2.6.0.2...
cabal: The package has a './configure' script. This requires a Unix
compatibility toolchain such as MinGW+MSYS or Cygwin.
Failed to install network-2.6.0.2
cabal: Error: some packages failed to install:
HTTP-4000.2.19 depends on network-2.6.0.2 which failed to install.
cabal-install-1.20.0.4 depends on network-2.6.0.2 which failed to install.
network-2.6.0.2 failed during the configure step. The exception was:
ExitFailure 1
C:\Windows\system32>cabal --v
cabal-install version 1.20.0.3
using version 1.20.0.2 of the Cabal library
After these messages I installed Cygwin64 and tried to reinstall "cabal-install", but nothing changed.
What can I do now? Thank you for your help.
CABAL INFO NETWORK
$ cabal info network
* network (library)
Synopsis: Low-level networking interface
Versions available: 2.3.2.0, 2.4.1.2, 2.4.2.1, 2.4.2.2, 2.4.2.3, 2.5.0.0,
2.6.0.0, 2.6.0.1, 2.6.0.2 (and 39 others)
Versions installed: 2.4.2.3, 2.6.0.2
Homepage: https://github.com/haskell/network
Bug reports: https://github.com/haskell/network/issues
Description: This package provides a low-level networking interface.
In network-2.6 the #Network.URI# module was split off into
its own package, network-uri-2.6. If you're using the
#Network.URI# module you can automatically get it from the
right package by adding this to your .cabal file:
> flag network-uri > description: Get Network.URI from the
network-uri package > default: True > > library > -- ... > if
flag(network-uri) > build-depends: network-uri >= 2.6,
network >= 2.6 > else > build-depends: network-uri < 2.6,
network < 2.6
That is, get the module from either network < 2.6 or from
network-uri >= 2.6.
Category: Network
License: BSD3
Maintainer: Johan Tibell <johan.tibell#gmail.com>
Source repo: git://github.com/haskell/network.git
Dependencies: base >=3 && <5, bytestring <0.11, unix >=2,
test-framework-hunit -any, test-framework -any, network -any,
HUnit -any, bytestring -any, base <5,
test-framework-hunit -any, test-framework -any, network -any,
HUnit -any, bytestring -any, base <5
Documentation: [ Not installed ]
Cached: Yes
Modules:
Network
Network.BSD
Network.Socket
Network.Socket.ByteString
Network.Socket.ByteString.Lazy
Network.Socket.Internal
Following the latest instructions i tried:
I tried:
C:\Windows\system32>cabal install cabal-install --constraint="network==2.4.2.3"
...
Linking dist\build\cabal\cabal.exe ...
Installing executable(s) in C:\Users\Alberto\AppData\Roaming\cabal\bin
Installed cabal-install-1.20.0.4
C:\Windows\system32>cabal --v
cabal-install version 1.20.0.4
using version 1.20.0.2 of the Cabal library
Instead with: cabal install cabal-install -v --constraint="network==2.6.0.2"
These are the last lines:
c:/program files/haskell platform/2014.2.0.0/mingw/bin/../lib/gcc/x86_64-w64-min
gw32/4.6.3/../../../../x86_64-w64-mingw32/bin/ld.exe: final link failed: Invalid
operation
collect2: ld returned 1 exit status
Failed to install cabal-install-1.20.0.4
World file is already up to date.
cabal: Error: some packages failed to install:
cabal-install-1.20.0.4 failed during the building phase. The exception was:
ExitFailure 1
The following is the incomplete version of the verbose process. (Incomplete because the Command Prompt window is too little to contain all the lines.) And also the "Body" of this post is "limited to 30000 characters" and I entered 43408.
Linking...
C:\Program Files\Haskell Platform\2014.2.0.0\bin\ghc.exe --make -fbuilding-cabal
-package -O -static -outputdir dist\build\cabal\cabal-tmp -odir dist\build\cabal
\cabal-tmp -hidir dist\build\cabal\cabal-tmp -stubdir dist\build\cabal\cabal-tmp
-i -idist\build\cabal\cabal-tmp -i. -idist\build\autogen -Idist\build\autogen -
Idist\build\cabal\cabal-tmp -optP-DWIN32 -optP-include -optPdist\build\autogen\c
abal_macros.h -hide-all-packages -package-db dist\package.conf.inplace -package-
id Cabal-1.20.0.2-2d0d4b50a80873bd77d7619acdc39282 -package-id HTTP-4000.2.19-a3
b06338bfc05de6b2dff745ab78e8e2 -package-id Win32-2.3.0.2-698249828064ce7d3e73140
6aa0b6536 -package-id array-0.5.0.0-a620a6e52b09b01c2ee52fdc2f35ba14 -package-id
base-4.7.0.1-7c4827d45272c6220486aa798a981cbc -package-id bytestring-0.10.4.0-0
168d7fce99b3d6589c7684c734053d4 -package-id containers-0.5.5.1-08015588ba3fe884f
62b392b72b7a17f -package-id directory-1.2.1.0-8cccd8e1806d43153b63c8c02500965e -
package-id filepath-1.3.0.2-a4d1d9ee29199e7f421cb1e2eeca7b3c -package-id mtl-2.1
.3.1-045b529925f92141fbca5a09ccb76887 -package-id network-2.6.0.2-cd717cc95784d3
d2c843373d48659787 -package-id network-uri-2.6.0.1-474d71b66fbfc5e5890f880a23bc7
62f -package-id pretty-1.1.1.1-c695907dd1419865c9783baf249b36b0 -package-id proc
ess-1.2.0.0-8428b2db1fb32008b84b305e3dcf61f8 -package-id random-1.0.1.1-1c39aaa7
8f370b133a79ccf1ef25922b -package-id stm-2.4.2-6e8cfbcce8457ecf64e4555b5e253ae6
-package-id time-1.4.2-10261674b91c0791587926806ccad1bb -package-id zlib-0.5.4.1
-28702d80c2a2842f8db883ae46443522 -XHaskell98 .\Main.hs dist\build\cabal\cabal-t
mp\cbits/getnumcores.o -o dist\build\cabal\cabal.exe -Wall -fwarn-tabs -threaded
Linking dist\build\cabal\cabal.exe ...
C:\Users\Alberto\AppData\Roaming\cabal\x86_64-windows-ghc-7.8.3\HTTP-4000.2.19/l
ibHSHTTP-4000.2.19.a(TCP.o):fake:(.text+0x26a6): undefined reference to `shutdow
nWinSock'
C:\Users\Alberto\AppData\Roaming\cabal\x86_64-windows-ghc-7.8.3\HTTP-4000.2.19/l
ibHSHTTP-4000.2.19.a(TCP.o):fake:(.text+0x2fae): undefined reference to `shutdow
nWinSock'
C:\Users\Alberto\AppData\Roaming\cabal\x86_64-windows-ghc-7.8.3\HTTP-4000.2.19/l
ibHSHTTP-4000.2.19.a(TCP.o):fake:(.text+0x300b): undefined reference to `initWin
Sock'
C:\Users\Alberto\AppData\Roaming\cabal\x86_64-windows-ghc-7.8.3\HTTP-4000.2.19/l
ibHSHTTP-4000.2.19.a(TCP.o):fake:(.text+0x3156): undefined reference to `shutdow
nWinSock'
C:\Users\Alberto\AppData\Roaming\cabal\x86_64-windows-ghc-7.8.3\HTTP-4000.2.19/l
ibHSHTTP-4000.2.19.a(TCP.o):fake:(.text+0x393e): undefined reference to `shutdow
nWinSock'
C:\Users\Alberto\AppData\Roaming\cabal\x86_64-windows-ghc-7.8.3\HTTP-4000.2.19/l
ibHSHTTP-4000.2.19.a(TCP.o):fake:(.text+0x399b): undefined reference to `initWin
Sock'
C:\Users\Alberto\AppData\Roaming\cabal\x86_64-windows-ghc-7.8.3\HTTP-4000.2.19/l
ibHSHTTP-4000.2.19.a(TCP.o):fake:(.text+0x3ade): undefined reference to `shutdow
nWinSock'
C:\Users\Alberto\AppData\Roaming\cabal\x86_64-windows-ghc-7.8.3\HTTP-4000.2.19/l
ibHSHTTP-4000.2.19.a(TCP.o):fake:(.text+0x4336): undefined reference to `shutdow
nWinSock'
C:\Users\Alberto\AppData\Roaming\cabal\x86_64-windows-ghc-7.8.3\HTTP-4000.2.19/l
ibHSHTTP-4000.2.19.a(TCP.o):fake:(.text+0x4393): undefined reference to `initWin
Sock'
C:\Users\Alberto\AppData\Roaming\cabal\x86_64-windows-ghc-7.8.3\HTTP-4000.2.19/l
ibHSHTTP-4000.2.19.a(TCP.o):fake:(.text+0x44d6): undefined reference to `shutdow
nWinSock'
C:\Users\Alberto\AppData\Roaming\cabal\x86_64-windows-ghc-7.8.3\HTTP-4000.2.19/l
ibHSHTTP-4000.2.19.a(TCP.o):fake:(.text+0x4c8e): undefined reference to `shutdow
nWinSock'
C:\Users\Alberto\AppData\Roaming\cabal\x86_64-windows-ghc-7.8.3\HTTP-4000.2.19/l
ibHSHTTP-4000.2.19.a(TCP.o):fake:(.text+0x4ceb): undefined reference to `initWin
Sock'
C:\Users\Alberto\AppData\Roaming\cabal\x86_64-windows-ghc-7.8.3\HTTP-4000.2.19/l
ibHSHTTP-4000.2.19.a(TCP.o):fake:(.text+0x4e36): undefined reference to `shutdow
nWinSock'
c:/program files/haskell platform/2014.2.0.0/mingw/bin/../lib/gcc/x86_64-w64-min
gw32/4.6.3/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Alberto\AppData\R
oaming\cabal\x86_64-windows-ghc-7.8.3\HTTP-4000.2.19/libHSHTTP-4000.2.19.a(TCP.o
): bad reloc address 0x0 in section `.data'
c:/program files/haskell platform/2014.2.0.0/mingw/bin/../lib/gcc/x86_64-w64-min
gw32/4.6.3/../../../../x86_64-w64-mingw32/bin/ld.exe: final link failed: Invalid
operation
collect2: ld returned 1 exit status
Failed to install cabal-install-1.20.0.4
World file is already up to date.
cabal: Error: some packages failed to install:
cabal-install-1.20.0.4 failed during the building phase. The exception was:
ExitFailure 1
cabal install cabal-install -v --constraint="network==2.6.0.2"
[17 of 76] Compiling Distribution.Client.Types ( Distribution\Client\Types.hs, d
ist\build\cabal\cabal-tmp\Distribution\Client\Types.o )
[18 of 76] Compiling Distribution.Client.Dependency.Modular.Flag ( Distribution\
Client\Dependency\Modular\Flag.hs, dist\build\cabal\cabal-tmp\Distribution\Clien
t\Dependency\Modular\Flag.o )
[19 of 76] Compiling Distribution.Client.Dependency.Modular.Dependency ( Distrib
ution\Client\Dependency\Modular\Dependency.hs, dist\build\cabal\cabal-tmp\Distri
bution\Client\Dependency\Modular\Dependency.o )
[20 of 76] Compiling Distribution.Client.Dependency.Modular.Tree ( Distribution\
Client\Dependency\Modular\Tree.hs, dist\build\cabal\cabal-tmp\Distribution\Clien
t\Dependency\Modular\Tree.o )
[21 of 76] Compiling Distribution.Client.Dependency.Modular.Index ( Distribution
\Client\Dependency\Modular\Index.hs, dist\build\cabal\cabal-tmp\Distribution\Cli
ent\Dependency\Modular\Index.o )
[22 of 76] Compiling Distribution.Client.Dependency.Modular.Builder ( Distributi
on\Client\Dependency\Modular\Builder.hs, dist\build\cabal\cabal-tmp\Distribution
\Client\Dependency\Modular\Builder.o )
[23 of 76] Compiling Distribution.Client.Dependency.Modular.Message ( Distributi
on\Client\Dependency\Modular\Message.hs, dist\build\cabal\cabal-tmp\Distribution
\Client\Dependency\Modular\Message.o )
[24 of 76] Compiling Distribution.Client.Dependency.Modular.Configured ( Distrib
ution\Client\Dependency\Modular\Configured.hs, dist\build\cabal\cabal-tmp\Distri
bution\Client\Dependency\Modular\Configured.o )
[25 of 76] Compiling Distribution.Client.Dependency.Modular.Assignment ( Distrib
ution\Client\Dependency\Modular\Assignment.hs, dist\build\cabal\cabal-tmp\Distri
bution\Client\Dependency\Modular\Assignment.o )
[26 of 76] Compiling Distribution.Client.Dependency.Modular.Validate ( Distribut
ion\Client\Dependency\Modular\Validate.hs, dist\build\cabal\cabal-tmp\Distributi
on\Client\Dependency\Modular\Validate.o )
[27 of 76] Compiling Distribution.Client.Dependency.TopDown.Types ( Distribution
\Client\Dependency\TopDown\Types.hs, dist\build\cabal\cabal-tmp\Distribution\Cli
ent\Dependency\TopDown\Types.o )
[28 of 76] Compiling Distribution.Client.Dependency.Modular.IndexConversion ( Di
stribution\Client\Dependency\Modular\IndexConversion.hs, dist\build\cabal\cabal-
tmp\Distribution\Client\Dependency\Modular\IndexConversion.o )
[29 of 76] Compiling Distribution.Client.Init.Licenses ( Distribution\Client\Ini
t\Licenses.hs, dist\build\cabal\cabal-tmp\Distribution\Client\Init\Licenses.o )
[30 of 76] Compiling Distribution.Client.Init.Types ( Distribution\Client\Init\T
ypes.hs, dist\build\cabal\cabal-tmp\Distribution\Client\Init\Types.o )
[31 of 76] Compiling Distribution.Client.Compat.Time ( Distribution\Client\Compa
t\Time.hs, dist\build\cabal\cabal-tmp\Distribution\Client\Compat\Time.o )
Distribution\Client\Compat\Time.hs:27:1: Warning:
the 'stdcall' calling convention is unsupported on this platform,
treating as ccall
When checking declaration:
foreign import stdcall safe "static windows.h GetFileAttributesExW" c_getF
ileAttributesEx
:: LPCTSTR -> Int32 -> LPVOID -> IO BOOL
Distribution\Client\Compat\Time.hs:90:62: Warning:
In the use of `bitSize' (imported from Data.Bits):
Deprecated: "Use 'bitSizeMaybe' or 'finiteBitSize' instead"
[32 of 76] Compiling Distribution.Client.Tar ( Distribution\Client\Tar.hs, dist\
build\cabal\cabal-tmp\Distribution\Client\Tar.o )
[33 of 76] Compiling Paths_cabal_install ( dist\build\autogen\Paths_cabal_instal
l.hs, dist\build\cabal\cabal-tmp\Paths_cabal_install.o )
[34 of 76] Compiling Distribution.Client.HttpUtils ( Distribution\Client\HttpUti
ls.hs, dist\build\cabal\cabal-tmp\Distribution\Client\HttpUtils.o )
[35 of 76] Compiling Distribution.Client.FetchUtils ( Distribution\Client\FetchU
tils.hs, dist\build\cabal\cabal-tmp\Distribution\Client\FetchUtils.o )
[36 of 76] Compiling Distribution.Client.Utils ( Distribution\Client\Utils.hs, d
ist\build\cabal\cabal-tmp\Distribution\Client\Utils.o )
[37 of 76] Compiling Distribution.Client.Init.Heuristics ( Distribution\Client\I
nit\Heuristics.hs, dist\build\cabal\cabal-tmp\Distribution\Client\Init\Heuristic
s.o )
[38 of 76] Compiling Distribution.Client.IndexUtils ( Distribution\Client\IndexU
tils.hs, dist\build\cabal\cabal-tmp\Distribution\Client\IndexUtils.o )
[39 of 76] Compiling Distribution.Client.Sandbox.Index ( Distribution\Client\San
dbox\Index.hs, dist\build\cabal\cabal-tmp\Distribution\Client\Sandbox\Index.o )
[40 of 76] Compiling Distribution.Client.InstallPlan ( Distribution\Client\Insta
llPlan.hs, dist\build\cabal\cabal-tmp\Distribution\Client\InstallPlan.o )
[41 of 76] Compiling Distribution.Client.Dependency.Types ( Distribution\Client\
Dependency\Types.hs, dist\build\cabal\cabal-tmp\Distribution\Client\Dependency\T
ypes.o )
[42 of 76] Compiling Distribution.Client.Dependency.Modular.Log ( Distribution\C
lient\Dependency\Modular\Log.hs, dist\build\cabal\cabal-tmp\Distribution\Client\
Dependency\Modular\Log.o )
[43 of 76] Compiling Distribution.Client.Dependency.Modular.Explore ( Distributi
on\Client\Dependency\Modular\Explore.hs, dist\build\cabal\cabal-tmp\Distribution
\Client\Dependency\Modular\Explore.o )
[44 of 76] Compiling Distribution.Client.Dependency.Modular.Preference ( Distrib
ution\Client\Dependency\Modular\Preference.hs, dist\build\cabal\cabal-tmp\Distri
bution\Client\Dependency\Modular\Preference.o )
[45 of 76] Compiling Distribution.Client.Dependency.Modular.Solver ( Distributio
n\Client\Dependency\Modular\Solver.hs, dist\build\cabal\cabal-tmp\Distribution\C
lient\Dependency\Modular\Solver.o )
[46 of 76] Compiling Distribution.Client.Dependency.Modular.ConfiguredConversion
( Distribution\Client\Dependency\Modular\ConfiguredConversion.hs, dist\build\ca
bal\cabal-tmp\Distribution\Client\Dependency\Modular\ConfiguredConversion.o )
[47 of 76] Compiling Distribution.Client.Dependency.Modular ( Distribution\Clien
t\Dependency\Modular.hs, dist\build\cabal\cabal-tmp\Distribution\Client\Dependen
cy\Modular.o )
[48 of 76] Compiling Distribution.Client.BuildReports.Anonymous ( Distribution\C
lient\BuildReports\Anonymous.hs, dist\build\cabal\cabal-tmp\Distribution\Client\
BuildReports\Anonymous.o )
[49 of 76] Compiling Distribution.Client.BuildReports.Storage ( Distribution\Cli
ent\BuildReports\Storage.hs, dist\build\cabal\cabal-tmp\Distribution\Client\Buil
dReports\Storage.o )
[50 of 76] Compiling Distribution.Client.BuildReports.Upload ( Distribution\Clie
nt\BuildReports\Upload.hs, dist\build\cabal\cabal-tmp\Distribution\Client\BuildR
eports\Upload.o )
[51 of 76] Compiling Distribution.Client.Dependency.TopDown.Constraints ( Distri
bution\Client\Dependency\TopDown\Constraints.hs, dist\build\cabal\cabal-tmp\Dist
ribution\Client\Dependency\TopDown\Constraints.o )
[52 of 76] Compiling Distribution.Client.Dependency.TopDown ( Distribution\Clien
t\Dependency\TopDown.hs, dist\build\cabal\cabal-tmp\Distribution\Client\Dependen
cy\TopDown.o )
[53 of 76] Compiling Distribution.Client.Win32SelfUpgrade ( Distribution\Client\
Win32SelfUpgrade.hs, dist\build\cabal\cabal-tmp\Distribution\Client\Win32SelfUpg
rade.o )
Distribution\Client\Win32SelfUpgrade.hs:48:1: Warning:
The qualified import of `System.Win32.DLL' is redundant
except perhaps to import instances from `System.Win32.DLL'
To import instances alone, use: import System.Win32.DLL()
Distribution\Client\Win32SelfUpgrade.hs:164:1: Warning:
the 'stdcall' calling convention is unsupported on this platform,
treating as ccall
When checking declaration:
foreign import stdcall unsafe "static windows.h GetCurrentProcessId" getCu
rrentProcessId
:: IO DWORD
Distribution\Client\Win32SelfUpgrade.hs:167:1: Warning:
the 'stdcall' calling convention is unsupported on this platform,
treating as ccall
When checking declaration:
foreign import stdcall unsafe "static windows.h WaitForSingleObject" waitF
orSingleObject_
:: HANDLE -> DWORD -> IO DWORD
Distribution\Client\Win32SelfUpgrade.hs:178:1: Warning:
the 'stdcall' calling convention is unsupported on this platform,
treating as ccall
When checking declaration:
foreign import stdcall unsafe "static windows.h CreateEventW" createEvent_
:: Ptr () -> BOOL -> BOOL -> LPCTSTR -> IO HANDLE
Distribution\Client\Win32SelfUpgrade.hs:187:1: Warning:
the 'stdcall' calling convention is unsupported on this platform,
treating as ccall
When checking declaration:
foreign import stdcall unsafe "static windows.h OpenEventW" openEvent_
:: DWORD -> BOOL -> LPCTSTR -> IO HANDLE
Distribution\Client\Win32SelfUpgrade.hs:199:1: Warning:
the 'stdcall' calling convention is unsupported on this platform,
treating as ccall
When checking declaration:
foreign import stdcall unsafe "static windows.h SetEvent" setEvent_
:: HANDLE -> IO BOOL
[54 of 76] Compiling Distribution.Client.Init ( Distribution\Client\Init.hs, dis
t\build\cabal\cabal-tmp\Distribution\Client\Init.o )
[55 of 76] Compiling Distribution.Client.Sandbox.Types ( Distribution\Client\San
dbox\Types.hs, dist\build\cabal\cabal-tmp\Distribution\Client\Sandbox\Types.o )
[56 of 76] Compiling Distribution.Client.Run ( Distribution\Client\Run.hs, dist\
build\cabal\cabal-tmp\Distribution\Client\Run.o )
[57 of 76] Compiling Distribution.Client.Check ( Distribution\Client\Check.hs, d
ist\build\cabal\cabal-tmp\Distribution\Client\Check.o )
[58 of 76] Compiling Distribution.Client.Update ( Distribution\Client\Update.hs,
dist\build\cabal\cabal-tmp\Distribution\Client\Update.o )
[59 of 76] Compiling Distribution.Client.Targets ( Distribution\Client\Targets.h
s, dist\build\cabal\cabal-tmp\Distribution\Client\Targets.o )
[60 of 76] Compiling Distribution.Client.Dependency ( Distribution\Client\Depend
ency.hs, dist\build\cabal\cabal-tmp\Distribution\Client\Dependency.o )
[61 of 76] Compiling Distribution.Client.Setup ( Distribution\Client\Setup.hs, d
ist\build\cabal\cabal-tmp\Distribution\Client\Setup.o )
[62 of 76] Compiling Distribution.Client.Config ( Distribution\Client\Config.hs,
dist\build\cabal\cabal-tmp\Distribution\Client\Config.o )
[63 of 76] Compiling Distribution.Client.SetupWrapper ( Distribution\Client\Setu
pWrapper.hs, dist\build\cabal\cabal-tmp\Distribution\Client\SetupWrapper.o )
[64 of 76] Compiling Distribution.Client.Sandbox.Timestamp ( Distribution\Client
\Sandbox\Timestamp.hs, dist\build\cabal\cabal-tmp\Distribution\Client\Sandbox\Ti
mestamp.o )
[65 of 76] Compiling Distribution.Client.Upload ( Distribution\Client\Upload.hs,
dist\build\cabal\cabal-tmp\Distribution\Client\Upload.o )
[66 of 76] Compiling Distribution.Client.List ( Distribution\Client\List.hs, dis
t\build\cabal\cabal-tmp\Distribution\Client\List.o )
[67 of 76] Compiling Distribution.Client.Configure ( Distribution\Client\Configu
re.hs, dist\build\cabal\cabal-tmp\Distribution\Client\Configure.o )
[68 of 76] Compiling Distribution.Client.Fetch ( Distribution\Client\Fetch.hs, d
ist\build\cabal\cabal-tmp\Distribution\Client\Fetch.o )
[69 of 76] Compiling Distribution.Client.SrcDist ( Distribution\Client\SrcDist.h
s, dist\build\cabal\cabal-tmp\Distribution\Client\SrcDist.o )
[70 of 76] Compiling Distribution.Client.Get ( Distribution\Client\Get.hs, dist\
build\cabal\cabal-tmp\Distribution\Client\Get.o )
[71 of 76] Compiling Distribution.Client.Sandbox.PackageEnvironment ( Distributi
on\Client\Sandbox\PackageEnvironment.hs, dist\build\cabal\cabal-tmp\Distribution
\Client\Sandbox\PackageEnvironment.o )
[72 of 76] Compiling Distribution.Client.Freeze ( Distribution\Client\Freeze.hs,
dist\build\cabal\cabal-tmp\Distribution\Client\Freeze.o )
[73 of 76] Compiling Distribution.Client.InstallSymlink ( Distribution\Client\In
stallSymlink.hs, dist\build\cabal\cabal-tmp\Distribution\Client\InstallSymlink.o
)
[74 of 76] Compiling Distribution.Client.Install ( Distribution\Client\Install.h
s, dist\build\cabal\cabal-tmp\Distribution\Client\Install.o )
[75 of 76] Compiling Distribution.Client.Sandbox ( Distribution\Client\Sandbox.h
s, dist\build\cabal\cabal-tmp\Distribution\Client\Sandbox.o )
[76 of 76] Compiling Main ( Main.hs, dist\build\cabal\cabal-tmp\Main
.o )
Building C Sources...
creating dist\build\cabal\cabal-tmp
C:\Program Files\Haskell Platform\2014.2.0.0\bin\ghc.exe -c -static -odir dist\b
uild\cabal\cabal-tmp -Idist\build\autogen -Idist\build\cabal\cabal-tmp -optc-O2
-package-db dist\package.conf.inplace -package-id Cabal-1.20.0.2-2d0d4b50a80873b
d77d7619acdc39282 -package-id HTTP-4000.2.19-a3b06338bfc05de6b2dff745ab78e8e2 -p
ackage-id Win32-2.3.0.2-698249828064ce7d3e731406aa0b6536 -package-id array-0.5.0
.0-a620a6e52b09b01c2ee52fdc2f35ba14 -package-id base-4.7.0.1-7c4827d45272c622048
6aa798a981cbc -package-id bytestring-0.10.4.0-0168d7fce99b3d6589c7684c734053d4 -
package-id containers-0.5.5.1-08015588ba3fe884f62b392b72b7a17f -package-id direc
tory-1.2.1.0-8cccd8e1806d43153b63c8c02500965e -package-id filepath-1.3.0.2-a4d1d
9ee29199e7f421cb1e2eeca7b3c -package-id mtl-2.1.3.1-045b529925f92141fbca5a09ccb7
6887 -package-id network-2.6.0.2-cd717cc95784d3d2c843373d48659787 -package-id ne
twork-uri-2.6.0.1-474d71b66fbfc5e5890f880a23bc762f -package-id pretty-1.1.1.1-c6
95907dd1419865c9783baf249b36b0 -package-id process-1.2.0.0-8428b2db1fb32008b84b3
05e3dcf61f8 -package-id random-1.0.1.1-1c39aaa78f370b133a79ccf1ef25922b -package
-id stm-2.4.2-6e8cfbcce8457ecf64e4555b5e253ae6 -package-id time-1.4.2-10261674b9
1c0791587926806ccad1bb -package-id zlib-0.5.4.1-28702d80c2a2842f8db883ae46443522
cbits/getnumcores.c
Linking...
C:\Program Files\Haskell Platform\2014.2.0.0\bin\ghc.exe --make -fbuilding-cabal
-package -O -static -outputdir dist\build\cabal\cabal-tmp -odir dist\build\cabal
\cabal-tmp -hidir dist\build\cabal\cabal-tmp -stubdir dist\build\cabal\cabal-tmp
-i -idist\build\cabal\cabal-tmp -i. -idist\build\autogen -Idist\build\autogen -
Idist\build\cabal\cabal-tmp -optP-DWIN32 -optP-include -optPdist\build\autogen\c
abal_macros.h -hide-all-packages -package-db dist\package.conf.inplace -package-
id Cabal-1.20.0.2-2d0d4b50a80873bd77d7619acdc39282 -package-id HTTP-4000.2.19-a3
b06338bfc05de6b2dff745ab78e8e2 -package-id Win32-2.3.0.2-698249828064ce7d3e73140
6aa0b6536 -package-id array-0.5.0.0-a620a6e52b09b01c2ee52fdc2f35ba14 -package-id
base-4.7.0.1-7c4827d45272c6220486aa798a981cbc -package-id bytestring-0.10.4.0-0
168d7fce99b3d6589c7684c734053d4 -package-id containers-0.5.5.1-08015588ba3fe884f
62b392b72b7a17f -package-id directory-1.2.1.0-8cccd8e1806d43153b63c8c02500965e -
package-id filepath-1.3.0.2-a4d1d9ee29199e7f421cb1e2eeca7b3c -package-id mtl-2.1
.3.1-045b529925f92141fbca5a09ccb76887 -package-id network-2.6.0.2-cd717cc95784d3
d2c843373d48659787 -package-id network-uri-2.6.0.1-474d71b66fbfc5e5890f880a23bc7
62f -package-id pretty-1.1.1.1-c695907dd1419865c9783baf249b36b0 -package-id proc
ess-1.2.0.0-8428b2db1fb32008b84b305e3dcf61f8 -package-id random-1.0.1.1-1c39aaa7
8f370b133a79ccf1ef25922b -package-id stm-2.4.2-6e8cfbcce8457ecf64e4555b5e253ae6
-package-id time-1.4.2-10261674b91c0791587926806ccad1bb -package-id zlib-0.5.4.1
-28702d80c2a2842f8db883ae46443522 -XHaskell98 .\Main.hs dist\build\cabal\cabal-t
mp\cbits/getnumcores.o -o dist\build\cabal\cabal.exe -Wall -fwarn-tabs -threaded
Linking dist\build\cabal\cabal.exe ...
C:\Users\Alberto\AppData\Roaming\cabal\x86_64-windows-ghc-7.8.3\HTTP-4000.2.19/l
ibHSHTTP-4000.2.19.a(TCP.o):fake:(.text+0x26a6): undefined reference to `shutdow
nWinSock'
C:\Users\Alberto\AppData\Roaming\cabal\x86_64-windows-ghc-7.8.3\HTTP-4000.2.19/l
ibHSHTTP-4000.2.19.a(TCP.o):fake:(.text+0x2fae): undefined reference to `shutdow
nWinSock'
C:\Users\Alberto\AppData\Roaming\cabal\x86_64-windows-ghc-7.8.3\HTTP-4000.2.19/l
ibHSHTTP-4000.2.19.a(TCP.o):fake:(.text+0x300b): undefined reference to `initWin
Sock'
C:\Users\Alberto\AppData\Roaming\cabal\x86_64-windows-ghc-7.8.3\HTTP-4000.2.19/l
ibHSHTTP-4000.2.19.a(TCP.o):fake:(.text+0x3156): undefined reference to `shutdow
nWinSock'
C:\Users\Alberto\AppData\Roaming\cabal\x86_64-windows-ghc-7.8.3\HTTP-4000.2.19/l
ibHSHTTP-4000.2.19.a(TCP.o):fake:(.text+0x393e): undefined reference to `shutdow
nWinSock'
C:\Users\Alberto\AppData\Roaming\cabal\x86_64-windows-ghc-7.8.3\HTTP-4000.2.19/l
ibHSHTTP-4000.2.19.a(TCP.o):fake:(.text+0x399b): undefined reference to `initWin
Sock'
C:\Users\Alberto\AppData\Roaming\cabal\x86_64-windows-ghc-7.8.3\HTTP-4000.2.19/l
ibHSHTTP-4000.2.19.a(TCP.o):fake:(.text+0x3ade): undefined reference to `shutdow
nWinSock'
C:\Users\Alberto\AppData\Roaming\cabal\x86_64-windows-ghc-7.8.3\HTTP-4000.2.19/l
ibHSHTTP-4000.2.19.a(TCP.o):fake:(.text+0x4336): undefined reference to `shutdow
nWinSock'
C:\Users\Alberto\AppData\Roaming\cabal\x86_64-windows-ghc-7.8.3\HTTP-4000.2.19/l
ibHSHTTP-4000.2.19.a(TCP.o):fake:(.text+0x4393): undefined reference to `initWin
Sock'
C:\Users\Alberto\AppData\Roaming\cabal\x86_64-windows-ghc-7.8.3\HTTP-4000.2.19/l
ibHSHTTP-4000.2.19.a(TCP.o):fake:(.text+0x44d6): undefined reference to `shutdow
nWinSock'
C:\Users\Alberto\AppData\Roaming\cabal\x86_64-windows-ghc-7.8.3\HTTP-4000.2.19/l
ibHSHTTP-4000.2.19.a(TCP.o):fake:(.text+0x4c8e): undefined reference to `shutdow
nWinSock'
C:\Users\Alberto\AppData\Roaming\cabal\x86_64-windows-ghc-7.8.3\HTTP-4000.2.19/l
ibHSHTTP-4000.2.19.a(TCP.o):fake:(.text+0x4ceb): undefined reference to `initWin
Sock'
C:\Users\Alberto\AppData\Roaming\cabal\x86_64-windows-ghc-7.8.3\HTTP-4000.2.19/l
ibHSHTTP-4000.2.19.a(TCP.o):fake:(.text+0x4e36): undefined reference to `shutdow
nWinSock'
c:/program files/haskell platform/2014.2.0.0/mingw/bin/../lib/gcc/x86_64-w64-min
gw32/4.6.3/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\Alberto\AppData\R
oaming\cabal\x86_64-windows-ghc-7.8.3\HTTP-4000.2.19/libHSHTTP-4000.2.19.a(TCP.o
): bad reloc address 0x0 in section `.data'
c:/program files/haskell platform/2014.2.0.0/mingw/bin/../lib/gcc/x86_64-w64-min
gw32/4.6.3/../../../../x86_64-w64-mingw32/bin/ld.exe: final link failed: Invalid
operation
collect2: ld returned 1 exit status
Failed to install cabal-install-1.20.0.4
World file is already up to date.
cabal: Error: some packages failed to install:
cabal-install-1.20.0.4 failed during the building phase. The exception was:
ExitFailure 1

Why isn't haddock generating documentation?

My Haskell file (pretty sure this is not the problem) is basically:
import System.IO
...
-- | Every Word is a String
type Word = String
...
-- | Some documentation for Haddock to see
main :: IO ()
main = do
...
My Setup.hs:
import Distribution.Simple
main = defaultMain
My grade.cabal:
name: grade
version: 0.1.0.0
...
build-type: Simple
cabal-version: >=1.8
executable grade
main-is: grade.hs
-- other-modules:
build-depends: base ==4.6.*, split ==0.2.*
hs-source-dirs: src
When I run cabal haddock --executables I get
...
Haddock coverage:
Warning: Not found in environment: Main.main
50% ( 1 / 2) in 'Main'
Warning: Main: could not find link destinations for:
Main.main
Documentation created: dist/doc/html/grade/grade/index.html
and the HTML contains main but no documentation for it. It does not even contain functions I defined other than main. Why is that?
You need to add a module declaration to generate documents for it.
module Main (main, Word) where

Haskell - Packaging cabal package with custom preprocessors

I've implemented a custom preprocessor which creates *.hs files form *.tpl files. It is specified in Setup.hs by using a Build-Type: Custom. Everything works fine, but I can't create tar.gz package from it (using cabal sdist).
Cabal complains, that it can not find the exposed modules which are generated by the preprocessor. The error message is
cabal: Error: Could not find module with any
suffix: ["gc","chs","hsc","x","y","ly","cpphs","hs","lhs"]
How can I make Cabal aware of the fact that the module is not missing, or maybe add tpl to the known file extensions, or something?
This is a known issue with cabal sdist. Use ./dist/setup/setup sdist instead.
Here's an example:
$ cat preprocessor-test.cabal
name: preprocessor-test
version: 0.1.0.0
build-type: Custom
cabal-version: >=1.10
extra-source-files: PreprocessorTest/*.prepro
library
exposed-modules: PreprocessorTest.PreprocessorTest
build-depends: base ==4.5.*
-- hs-source-dirs:
default-language: Haskell2010
$ cat Setup.hs
#!/usr/bin/env runhaskell
import Distribution.Simple
import Distribution.Simple.PreProcess
import Distribution.Simple.Utils
import Distribution.PackageDescription
import Distribution.Simple.LocalBuildInfo
import System.Cmd (rawSystem)
import System.FilePath ((</>))
main = let hooks = simpleUserHooks
dummy = ("prepro", dummyPreprocessor)
in defaultMainWithHooks hooks
{ hookedPreProcessors = dummy:knownSuffixHandlers }
dummyPreprocessor :: BuildInfo -> LocalBuildInfo -> PreProcessor
dummyPreprocessor build local = PreProcessor {
platformIndependent = True,
runPreProcessor =
mkSimplePreProcessor $ \inFile outFile verbosity -> do
notice verbosity (inFile ++ " is being preprocessed to " ++ outFile)
rawSystem "cp" [inFile, outFile]
return ()
}
$ cat PreprocessorTest/PreprocessorTest.prepro
module PreprocessorTest.PreprocessorTest
where
preprocessorTest :: Int
preprocessorTest = 1
$ cabal configure
Resolving dependencies...
[1 of 1] Compiling Main ( Setup.hs, dist/setup/Main.o )
Linking ./dist/setup/setup ...
Configuring preprocessor-test-0.1.0.0...
$ cabal build
Building preprocessor-test-0.1.0.0...
Preprocessing library preprocessor-test-0.1.0.0...
PreprocessorTest/PreprocessorTest.prepro is being preprocessed to
dist/build/PreprocessorTest/PreprocessorTest.hs
[1 of 1] Compiling PreprocessorTest.PreprocessorTest ( dist/build/PreprocessorTest/PreprocessorTest.hs, dist/build/PreprocessorTest/PreprocessorTest.o )
Registering preprocessor-test-0.1.0.0...
$ ./dist/setup/setup sdist
Distribution quality errors:
No 'synopsis' or 'description' field.
The 'license' field is missing or specified as AllRightsReserved.
Distribution quality warnings:
No 'category' field.
No 'maintainer' field.
Note: the public hackage server would reject this package.
Building source dist for preprocessor-test-0.1.0.0...
Preprocessing library preprocessor-test-0.1.0.0...
PreprocessorTest/PreprocessorTest.prepro is being preprocessed to
dist/src/sdist.-6767/preprocessor-test-0.1.0.0/dist/build/PreprocessorTest/PreprocessorTest.hs
Source tarball created: dist/preprocessor-test-0.1.0.0.tar.gz
$ tar tzf dist/preprocessor-test-0.1.0.0.tar.gz
preprocessor-test-0.1.0.0/
preprocessor-test-0.1.0.0/dist/
preprocessor-test-0.1.0.0/dist/build/
preprocessor-test-0.1.0.0/dist/build/PreprocessorTest/
preprocessor-test-0.1.0.0/dist/build/PreprocessorTest/PreprocessorTest.hs
preprocessor-test-0.1.0.0/Setup.hs
preprocessor-test-0.1.0.0/PreprocessorTest/
preprocessor-test-0.1.0.0/PreprocessorTest/PreprocessorTest.prepro
preprocessor-test-0.1.0.0/preprocessor-test.cabal

Resources