Fay can't find fay-base - haskell

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.

Related

What does "legacy fallback" mean when cabal is building packages?

When using cabal to build a Haskell package, it appears to mark some packages as legacy fallback:
$ cabal build
Resolving dependencies...
Build profile: -w ghc-9.0.1 -O1
In order, the following will be built (use -v for more details):
- appar-0.1.8 (lib:appar) (requires build)
- auto-update-0.1.6 (lib) (requires build)
- base-compat-0.11.2 (lib) (requires build)
...
Building base-orphans-0.8.4 (lib)
Building appar-0.1.8 (all, legacy fallback)
Downloaded memory-0.16.0
Downloading cryptonite-0.29
Installing base-orphans-0.8.4 (lib)
Downloaded cryptonite-0.29
Downloading some-1.0.3
...
You can see that for some libraries, they are specifically marked (lib), but other libraries are marked (all, legacy fallback).
What is the difference between these? What does legacy fallback mean?
I am using cabal-install version 3.4.0.0:
$ cabal --version
cabal-install version 3.4.0.0
compiled using version 3.4.0.0 of the Cabal library
I took a dive in the source code. The error message comes form here:
dispname = case elabPkgOrComp pkg of
ElabPackage _ -> prettyShow pkgid
++ " (all, legacy fallback)"
ElabComponent comp -> prettyShow pkgid
++ " (" ++ maybe "custom" prettyShow (compComponentName comp) ++ ")"
So I started looking for places where ElabPackage is constructed. I found this:
elaborateSolverToPackage
...
where
...
elab1 = elab0 {
elabUnitId = newSimpleUnitId pkgInstalledId,
elabComponentId = pkgInstalledId,
elabLinkedInstantiatedWith = Map.empty,
elabPkgOrComp = ElabPackage $ ElaboratedPackage {..},
elabModuleShape = modShape
}
This in turn is used here:
elaborateSolverToComponents mapDep spkg#(SolverPackage _ _ _ deps0 exe_deps0)
= case mkComponentsGraph (elabEnabledSpec elab0) pd of
Right g -> do
...
let not_per_component_reasons = why_not_per_component src_comps
if null not_per_component_reasons
then return comps
else do checkPerPackageOk comps not_per_component_reasons
return [elaborateSolverToPackage spkg g $
comps ++ maybeToList setupComponent]
Now the why_not_per_component is very interesting as that function determines when to use the legacy fallback. It is defined here:
-- You are eligible to per-component build if this list is empty
why_not_per_component g
= cuz_buildtype ++ cuz_spec ++ cuz_length ++ cuz_flag ++ cuz_coverage
There in the code right below that we can see that it can be caused by these reasons:
The build-type is Custom or Configure
The cabal-version is less than 1.8
There are no buildable components
You passed the --disable-per-component flag.
Program coverage is enabled
So for the appar library it is because the cabal-version is 1.6 which is lower than 1.8, see https://github.com/kazu-yamamoto/appar/blob/v0.1.8/appar.cabal#L10.

Haskell reexport linker errors

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

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

yesod devel fail when starting development server

I was starting to read about Yesod and I tried to install it on my Linux Mint Maya 64-bit machine.
The haskell platform was already installed, I just installed the yesod-platform package with cabal install yesod-platform and all worked very well.
Next step was to call yesod init with respond to all the questions - the application name: test. The problems starts when I called yesod devel... here it is what I've got:
Yesod devel server. Press ENTER to quit
Resolving dependencies...
Configuring test-0.0.0...
Rebuilding application...
Building test-0.0.0...
Preprocessing library test-0.0.0...
Registering test-0.0.0...
Starting development server: runghc -package-confdist/package.conf.inplace devel.hs
devel.hs:2:1:
Failed to load interface for `Application'
It is not a module in the current program, or in any known package.
Exit code: ExitFailure 1
I'm a little bit lost with this issue - I made a lot of research related to it but I have no luck...
Can anyone help with this problem?
Here it is my ghc-pkg list:
/var/lib/ghc/package.conf.d:
Cabal-1.14.0
GLUT-2.1.2.1
HDBC-2.3.1.1
HDBC-odbc-2.2.3.0
HTTP-4000.2.2
HUnit-1.2.4.2
MonadCatchIO-mtl-0.3.0.4
OpenGL-2.2.3.1
QuickCheck-2.4.2
SHA-1.5.0.0
aeson-0.6.0.0
ansi-terminal-0.5.5
array-0.4.0.0
asn1-data-0.6.1.3
attoparsec-0.10.1.1
attoparsec-conduit-0.2.0
attoparsec-enumerator-0.3
authenticate-1.0.0.1
base-4.5.0.0
base-unicode-symbols-0.2.2.3
base64-bytestring-0.1.1.0
bin-package-db-0.0.0.0
binary-0.5.1.0
blaze-builder-0.3.1.0
blaze-builder-conduit-0.2.0
blaze-html-0.4.3.1
byteorder-1.0.3
bytestring-0.9.2.1
bytestring-lexing-0.4.0
case-insensitive-0.4.0.1
cereal-0.3.5.1
certificate-1.1.0
cgi-3001.1.8.2
clientsession-0.7.4.1
conduit-0.2.0
containers-0.4.2.1
convertible-1.0.11.0
cookie-0.4.0
cprng-aes-0.2.3
crypto-api-0.9
crypto-conduit-0.1.3.1
crypto-pubkey-types-0.1.0
cryptocipher-0.3.0
cryptohash-0.7.4
css-text-0.1.1
data-default-0.3.0
deepseq-1.3.0.0
directory-1.1.0.2
dlist-0.5
email-validate-0.2.8
entropy-0.2.1
enumerator-0.4.18
extensible-exceptions-0.1.1.4
failure-0.2.0
fast-logger-0.0.2
fgl-5.4.2.4
file-embed-0.0.4.1
filepath-1.3.0.0
(ghc-7.4.1)
ghc-prim-0.2.0.0
hamlet-0.10.8
hashable-1.1.2.3
haskell-src-1.0.1.5
(haskell2010-1.1.0.1)
(haskell98-2.0.0.1)
hjsmin-0.0.15
hoopl-3.8.7.3
hpc-0.5.1.1
html-1.0.1.2
http-conduit-1.2.5
http-date-0.0.2
http-types-0.6.9
integer-gmp-0.4.0.0
language-javascript-0.4.10
largeword-1.0.1
lifted-base-0.1.0.3
mime-mail-0.4.1.1
monad-control-0.3.1
mtl-2.0.1.0
network-2.3.0.10
old-locale-1.0.0.4
old-time-1.1.0.0
parallel-3.2.0.2
parsec-3.1.2
path-pieces-0.1.0
persistent-0.8.0.1
persistent-template-0.8.1.1
pool-conduit-0.0.0.1
pretty-1.1.1.0
primitive-0.4.1
process-1.1.0.1
pureMD5-2.1.0.3
pwstore-fast-2.2
random-1.0.1.1
ranges-0.2.4
regex-base-0.93.2
regex-compat-0.95.1
regex-posix-0.95.1
resource-pool-0.2.1.0
rts-1.0
safe-0.3.3
semigroups-0.8
shakespeare-0.10.3.1
shakespeare-css-0.10.7
shakespeare-i18n-0.0.1
shakespeare-js-0.11.0.1
shakespeare-text-0.10.5
simple-sendfile-0.2.0
skein-0.1.0.5
socks-0.4.1
stm-2.2.0.1
syb-0.3.6
system-filepath-0.4.6
tagged-0.2.3.1
tagsoup-0.12.6
template-haskell-2.7.0.0
text-0.11.1.13
time-1.4
tls-0.9.0
tls-extra-0.4.3
transformers-0.2.2.0
transformers-base-0.4.1
unix-2.5.1.0
unix-compat-0.3.0.1
unordered-containers-0.1.4.6
utf8-light-0.4.0.1
utf8-string-0.3.7
vault-0.1.0.0
vector-0.9.1
wai-1.1.0.1
wai-app-static-1.1.2
wai-extra-1.1.0.1
wai-logger-0.1.4
warp-1.1.0.1
xhtml-3000.2.0.5
xml-conduit-0.5.3
xml-types-0.3.1
xss-sanitize-0.3.1
yaml-0.5.2
yesod-0.10.1.3
yesod-auth-0.8.1.1
yesod-core-0.10.2.1
yesod-form-0.4.2
yesod-json-0.3.1
yesod-persistent-0.3.1
yesod-routes-0.0.1
yesod-static-0.10.1
zlib-0.5.3.3
zlib-bindings-0.0.3.2
zlib-conduit-0.2.0
/home/ionica/.ghc/x86_64-linux-7.4.1/package.conf.d:
Cabal-1.16.0.1
HDBC-2.3.1.1
HDBC-odbc-2.3.1.0
HDBC-sqlite3-2.3.3.0
HaXml-1.23.3
SHA-1.5.1
aeson-0.6.0.2
ansi-terminal-0.5.5
asn1-data-0.7.1
attoparsec-0.10.2.0
attoparsec-conduit-0.5.0.2
authenticate-1.3.1.1
base-unicode-symbols-0.2.2.4
base64-bytestring-1.0.0.0
blaze-builder-0.3.1.0
blaze-builder-conduit-0.5.0.1
blaze-html-0.5.1.0
blaze-markup-0.5.1.1
byteorder-1.0.3
cairo-0.12.3.1
case-insensitive-0.4.0.3
cereal-0.3.5.2
certificate-1.2.8
cipher-aes-0.1.2
clientsession-0.8.0.1
conduit-0.5.2.5
conduit-0.5.2.6
convertible-1.0.11.1
cookie-0.4.0.1
cpphs-1.14
cprng-aes-0.2.4
cpu-0.1.1
crypto-api-0.10.2
crypto-conduit-0.4.0.1
crypto-pubkey-types-0.1.1
cryptocipher-0.3.5
cryptohash-0.7.5
css-text-0.1.1
data-default-0.5.0
date-cache-0.3.0
derive-2.5.11
dlist-0.5
email-validate-0.2.8
entropy-0.2.1
failure-0.2.0.1
fast-logger-0.3.1
file-embed-0.0.4.6
filesystem-conduit-0.5.0.1
ghc-paths-0.1.0.8
gio-0.12.3
glib-0.12.3.1
gtk-0.12.3.1
hamlet-1.1.1
hashable-1.1.2.5
haskell-src-exts-1.13.5
hjsmin-0.1.3
hspec-1.3.0.1
hspec-expectations-0.3.0.2
html-conduit-0.1.0.2
http-conduit-1.6.1.2
http-date-0.0.2
http-types-0.7.3.0.1
language-javascript-0.5.5
largeword-1.0.3
lifted-base-0.1.2
lifted-base-0.2
mime-mail-0.4.1.2
mime-types-0.1.0.0
monad-control-0.3.1.4
monad-logger-0.2.1
network-conduit-0.6.0
network-conduit-0.6.1.1
pango-0.12.3
parallel-3.2.0.2
parallel-3.2.0.3
parallel-io-0.3.2.1
path-pieces-0.1.2
pem-0.1.1
persistent-1.0.1.3
persistent-sqlite-0.8.0
persistent-sqlite-1.0.0
persistent-template-1.0.0.2
polyparse-1.8
pool-conduit-0.1.0.3
primitive-0.5
primitive-0.5.0.1
pureMD5-2.1.2.1
pwstore-fast-2.3
ranges-0.2.4
resource-pool-0.2.1.1
resourcet-0.4.0.1
resourcet-0.4.0.2
safe-0.3.3
semigroups-0.8.4.1
shakespeare-1.0.1.4
shakespeare-css-1.0.1.5
shakespeare-i18n-1.0.0.2
shakespeare-js-1.0.0.6
shakespeare-text-1.0.0.5
silently-1.2.0.2
simple-sendfile-0.2.8
skein-0.1.0.9
socks-0.4.2
split-0.1.4.3
stringsearch-0.3.6.4
system-fileio-0.3.10
system-filepath-0.4.7
tagged-0.4.4
tagsoup-0.12.8
tagstream-conduit-0.5.3
tar-0.3.2.0
tar-0.4.0.1
tls-0.9.11
tls-extra-0.4.7
transformers-base-0.4.1
uniplate-1.6.7
unix-compat-0.4.0.0
unix-time-0.1.2
unordered-containers-0.2.2.1
utf8-string-0.3.7
vault-0.2.0.1
vector-0.10
vector-0.10.0.1
void-0.5.8
wai-1.3.0.1
wai-app-static-1.3.0.2
wai-extra-1.3.0.3
wai-logger-0.3.0
wai-test-1.3.0
warp-1.3.4.1
xml-conduit-1.0.3.1
xml-types-0.3.3
xss-sanitize-0.3.2
yaml-0.8.1
yesod-1.1.2
yesod-auth-1.1.1.2
yesod-core-1.1.3.1
yesod-default-0.6.1
yesod-default-1.1.0.2
yesod-form-1.1.3
yesod-json-1.1.0
yesod-persistent-1.1.0
yesod-platform-1.1.4
yesod-routes-1.1.0.1
yesod-routes-1.1.0.2
yesod-static-1.1.0.1
yesod-test-0.3.0.1
zlib-bindings-0.1.1.1
zlib-conduit-0.5.0.1
After a complete clean up of the system - I mean uninstall haskell-platform, yesod-platform and delete files related to haskell, yesod and ghc - then a fresh install for haskell-platform + yesod-platform all goes splendid.

Resources