Can't find AddHandler in reactive-banana - haskell

I am trying out the examples of reactive-banana in its tutorial. When I tried to load the example into ghci, I got an error.
Could not find module `Reactive.Banana.Frameworks.AddHandler'
Running it with ghci -v gives the output at the bottom. I installed wx-2.8 and wxWidgets-0.13.1.3 on ubuntu 14.04 LTS.
When I looked at my cabal directory, the AddHandler file is indeed not there:
$ ls lib/reactive-banana-0.8.0.0/ghc-7.6.3/Reactive/Banana/
Combinators.hi Frameworks.hi Model.hi Prim.hi Types.hi
Experimental Internal Prim Switch.hi
Could someone tell me what went wrong, and how do I fix the error please?
Thanks,
Error message:
~$ ghci teste.hs -v
GHCi, version 7.6.3: http://www.haskell.org/ghc/ :? for help
Glasgow Haskell Compiler, Version 7.6.3, stage 2 booted by GHC version 7.6.3
Using binary package database: /usr/lib/ghc/package.conf.d/package.cache
Using binary package database: /home/ting/.ghc/x86_64-linux-7.6.3/package.conf.d/package.cache
hiding package wxdirect-0.13.1.3 to avoid conflict with later version wxdirect-0.90.1.1
wired-in package ghc-prim mapped to ghc-prim-0.3.0.0-d5221a8c8a269b66ab9a07bdc23317dd
...
wired-in package dph-seq not found.
wired-in package dph-par not found.
Hsc static flags: -static
Loading package ghc-prim ... linking ... done.
*** gcc:
'/usr/bin/gcc' '-fno-stack-protector' '-Wl,--hash-size=31' '-Wl,--reduce-memory-overheads' '-L/usr/lib/ghc/integer-gmp-0.5.0.0' '--print-file-name' 'libgmp.so'
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
*** Chasing dependencies:
Chasing modules from:
Stable obj: []
Stable BCO: []
unload: retaining objs []
unload: retaining bcos []
Ready for upsweep []
Upsweep completely successful.
*** Deleting temp files:
Deleting:
*** Chasing dependencies:
Chasing modules from: *teste.hs
teste.hs:7:8:
Could not find module `Reactive.Banana.Frameworks.AddHandler'
Locations searched:
Reactive/Banana/Frameworks/AddHandler.hs
Reactive/Banana/Frameworks/AddHandler.lhs
Failed, modules loaded: none.

I have been working through that tutorial and wrote a fixed version of the example: Hope that helps.

Remove the import Reactive.Banana.Frameworks.AddHandler line. I think it has been moved to somewhere else and doesn't require explicit import.

Related

ghci / stack and package available

I use intero with some file with no project, and my global (or local stack.yaml) is:
~/.stack/global
$ cat stack.yaml
flags: {}
packages: []
extra-deps: []
resolver: lts-8.21
If I stack exec -- ghci and :l Intero.hs where Intero.hs contains:
$ cat Intero.hs
module Intero where
import Control.Lens.Lens
I get:
$ stack exec -- ghci
GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help
Loaded GHCi configuration from /Users/nrolland/.emacs.d/.ghci
Prelude
λ> :l Intero.hs
[1 of 1] Compiling Intero ( Intero.hs, interpreted )
Intero.hs:3:1: error:
Failed to load interface for ‘Control.Lens.Lens’
Use -v to see a list of the files searched for.
Failed, modules loaded: none.
I relaunched with -v:
$ stack exec -- ghci -v
GHCi, version 8.0.2: http://www.haskell.org/ghc/ :? for help
Glasgow Haskell Compiler, Version 8.0.2, stage 2 booted by GHC version 7.10.3
Using binary package database: /Users/nrolland/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/package.conf.d/package.cache
Using binary package database: /Users/nrolland/.stack/snapshots/x86_64-osx/lts-8.23/8.0.2/pkgdb/package.cache
Using binary package database: /Users/nrolland/Sync/clones/haskGist80/.stack-work/install/x86_64-osx/lts-8.23/8.0.2/pkgdb/package.cache
loading package database /Users/nrolland/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/package.conf.d
loading package database /Users/nrolland/.stack/snapshots/x86_64-osx/lts-8.23/8.0.2/pkgdb
loading package database /Users/nrolland/Sync/clones/haskGist80/.stack-work/install/x86_64-osx/lts-8.23/8.0.2/pkgdb
wired-in package ghc-prim mapped to ghc-prim-0.5.0.0
and when loading the Intero.hs, I get
Intero.hs:3:1: error:
Failed to load interface for ‘Control.Lens.Lens’
Locations searched:
Control/Lens/Lens.hs
Control/Lens/Lens.lhs
Control/Lens/Lens.hsig
Control/Lens/Lens.lhsig
Upsweep partially successful.
*** Deleting temp files:
Deleting:
Failed, modules loaded: none.
loading package database /Users/nrolland/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/package.conf.d
loading package database /Users/nrolland/.stack/snapshots/x86_64-osx/lts-8.23/8.0.2/pkgdb
loading package database /Users/nrolland/Sync/clones/haskGist80/.stack-work/install/x86_64-osx/lts-8.23/8.0.2/pkgdb
wired-in package ghc-prim mapped to ghc-prim-0.5.0.0
wired-in package integer-gmp mapped to integer-gmp-1.0.0.1
wired-in package base mapped to base-4.9.1.0
wired-in package rts mapped to rts-1.0
wired-in package template-haskell mapped to template-haskell-2.11.1.0
wired-in package ghc mapped to ghc-8.0.2
wired-in package dph-seq not found.
wired-in package dph-par not found.
But lens is part of lts-8.23, although when I look it up in ghc-pkg I don't see it
$ stack exec -- ghc-pkg list
/Users/nrolland/.stack/programs/x86_64-osx/ghc-8.0.2/lib/ghc-8.0.2/package.conf.d
Cabal-1.24.2.0
array-0.5.1.1
base-4.9.1.0
binary-0.8.3.0
bytestring-0.10.8.1
containers-0.5.7.1
deepseq-1.4.2.0
directory-1.3.0.0
filepath-1.4.1.1
ghc-8.0.2
ghc-boot-8.0.2
ghc-boot-th-8.0.2
ghc-prim-0.5.0.0
ghci-8.0.2
haskeline-0.7.3.0
hoopl-3.10.2.1
hpc-0.6.0.3
integer-gmp-1.0.0.1
pretty-1.1.3.3
process-1.4.3.0
rts-1.0
template-haskell-2.11.1.0
terminfo-0.4.0.2
time-1.6.0.1
transformers-0.5.2.0
unix-2.7.2.1
xhtml-3000.2.1
/Users/nrolland/.stack/snapshots/x86_64-osx/lts-8.23/8.0.2/pkgdb
(no packages)
/Users/nrolland/Sync/clones/haskGist80/.stack-work/install/x86_64-osx/lts-8.23/8.0.2/pkgdb
(no packages)
How can I easily load up modules without creating a full blown project ?
It might be easy but I am very confused about how this whole thing works..
Packages have to be installed (downloaded and compiled) before they can be used:
stack install lens
If you are working with a Cabalized project (which can be a good idea even for small things), stack will install dependencies listed in your cabal file so you don't have to install them manually.
In response to your comment: I suppose it would technically be possible to download and install all of (some version of) stackage, but this doesn't seem desirable. It would take an awfully long time and has little benefit over installing packages at need. Besides, I don't know of an automated way to do it. I know some interesting work has been done on "offline hackage" storage but it isn't ready for use.

Haskell PFP library problems

I am trying to run these examples using their library. When I run the command ghci Dice.hs, even if I am in the same folder with Dice.hs it tells
$ ghci Dice.hs
GHCi, version 7.6.3: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Probability.hs:5:8:
Could not find module `Monad'
It is a member of the hidden package `haskell98-2.0.0.2'.
Use -v to see a list of the files searched for.
Failed, modules loaded: none.
I also installed mtl package with Cabal. Other ideas?

GHC cannot find module in cabal sandbox

I am using Haskell version 7.8.4 on (X)Ubuntu 15.10, with Cabal-Install 1.18 both installed through apt. I have not attempted to install anything Haskell-related by hand on this machine. I set up a cabal sandbox, fetched and installed a module only to discover that ghc doesn't seem to be picking it up. ghc -v seems to suggest that I have two versions of the cabal library that are mutually shadowing each other. How does this work?
I am starting out with an empty directory /tmp/haskell-example
then I do a cabal sandbox init.
$ cabal sandbox init
Writing a default package environment file to
/tmp/haskell-example/cabal.sandbox.config
Creating a new sandbox at /tmp/haskell-example/.cabal-sandbox
then I install natural-numbers because I want to use the Data.Natural module in a program. This operation succeeds.
$ cabal install natural-numbers
Resolving dependencies...
Notice: installing into a sandbox located at
/tmp/haskell-example/.cabal-sandbox
Configuring natural-numbers-0.1.2.0...
Building natural-numbers-0.1.2.0...
Installed natural-numbers-0.1.2.0
I can verify that the Data.Natural module has indeed been installed to the cabal sandbox.
$ ls /tmp/haskell-example/.cabal-sandbox/lib/x86_64-linux-ghc-7.8.4/natural-numbers-0.1.2.0
Data
libHSnatural-numbers-0.1.2.0.a
libHSnatural-numbers-0.1.2.0-ghc7.8.4.so
$ ls /tmp/haskell-example/.cabal-sandbox/lib/x86_64-linux-ghc-7.8.4/natural-numbers-0.1.2.0/Data
Natural.dyn_hi
Natural.hi
then I create a simple Main.hs file that imports Data.Natural but does not use it.
module Main where
import Data.Natural
main = putStrLn "Hello World"
When I try to ghc Main.hs I see the following :
$ ghc Main.hs
Main.hs:3:8:
Could not find module ‘Data.Natural’
Use -v to see a list of the files searched for.
With the verbose flag enabled, it seems as if my cabal is getting shadowed by a later cabal, which is in turn shadowing the earlier cabal. Why is this happening?
$ ghc -v Main.hs
Glasgow Haskell Compiler, Version 7.8.4, stage 2 booted by GHC version 7.8.4
Using binary package database: /usr/lib/ghc/package.conf.d/package.cache
hiding package Cabal-1.18.1.5 to avoid conflict with later version Cabal-1.22.1.1
wired-in package ghc-prim mapped to ghc-prim-0.3.1.0-ec14d2f6075975a2ce9112eae431c8e1
wired-in package integer-gmp mapped to integer-gmp-0.5.1.0-de4898ebdc5ab81cedce89121ae9ac84
wired-in package base mapped to base-4.7.0.2-5ef1e7e809bc3b18d74efc783356e209
wired-in package rts mapped to builtin_rts
wired-in package template-haskell mapped to template-haskell-2.9.0.0-c1976a420ad8b9b589eee08844c59ba2
wired-in package dph-seq not found.
wired-in package dph-par not found.
Hsc static flags:
hiding package Cabal-1.18.1.5 to avoid conflict with later version Cabal-1.22.1.1
wired-in package ghc-prim mapped to ghc-prim-0.3.1.0-ec14d2f6075975a2ce9112eae431c8e1
wired-in package integer-gmp mapped to integer-gmp-0.5.1.0-de4898ebdc5ab81cedce89121ae9ac84
wired-in package base mapped to base-4.7.0.2-5ef1e7e809bc3b18d74efc783356e209
wired-in package rts mapped to builtin_rts
wired-in package template-haskell mapped to template-haskell-2.9.0.0-c1976a420ad8b9b589eee08844c59ba2
wired-in package dph-seq not found.
wired-in package dph-par not found.
*** Chasing dependencies:
Chasing modules from: *Main.hs
Main.hs:3:8:
Could not find module ‘Data.Natural’
Locations searched:
Data/Natural.hs
Data/Natural.lhs
*** Deleting temp files:
Deleting:
*** Deleting temp dirs:
Deleting:
If you're into manual hacking, you can pass to ghc the sandbox's pkg db location, such as:
ghc Main.hs -package-db .cabal-sandbox/x86_64-linux-ghc-7.10.2-packages.conf.d/
However the "normal" way to use sandboxes is to always compile using cabal build (or cabal install with no parameters) rather than running ghc directly.
Run cabal init, answer questions as you please
Edit the resulting foo.cabal file (foo is the name of your package).
Run cabal build or cabal install - this will run ghc for you.
When editing the cabal file, check that your exported modules (if it's a lib) are listed and that your main src is correct. Also make sure dependencies such as natural-numbers are listed in the build-depends: clause.

Haskell Could not find module 'Graphics.Gloss'

I'm trying to run a simple Gloss program in Haskell on Xubuntu 14.04.
Now i've run the same program before with no issues on the same machine a while ago but it seems like its no longer working. Apparently it thinks Gloss is not installed when it is.
I've tried a lot of things with no luck.
Error when trying to compile program:
MyProg.hs:2:8:
Could not find module `Graphics.Gloss'
Use -v to see a list of the files searched for.
When using -v flag:
Glasgow Haskell Compiler, Version 7.6.3, stage 2 booted by GHC version 7.6.3
Using binary package database: /usr/lib/ghc/package.conf.d/package.cache
Using binary package database: /home/myuser/.ghc/x86_64-linux-7.6.3/package.conf.d/package.cache
package GLUT-2.4.0.0-31a913db9728fc0bba038e31af3ad274 is unusable due to missing or recursive dependencies:
OpenGL-2.8.0.0-344e8603ffa2fe942e6526830661f0ee
package OpenGL-2.8.0.0-344e8603ffa2fe942e6526830661f0ee is shadowed by package OpenGL-2.8.0.0-965a1de4ba5cd960ad85db9941a93722
package gloss-1.8.1.2-eb3652fd7115ec4d025ca235f1e1d64d is unusable due to missing or recursive dependencies:
GLUT-2.4.0.0-31a913db9728fc0bba038e31af3ad274 OpenGL-2.8.0.0-344e8603ffa2fe942e6526830661f0ee
package gloss-raster-1.8.1.2-fd045cd6d26cf5909eb1793d4659a1f3 is unusable due to missing or recursive dependencies:
gloss-1.8.1.2-eb3652fd7115ec4d025ca235f1e1d64d
hiding package HTTP-4000.2.8 to avoid conflict with later version HTTP-4000.2.19
hiding package Cabal-1.16.0 to avoid conflict with later version Cabal-1.22.4.0
hiding package binary-0.5.1.1 to avoid conflict with later version binary-0.6.4.0
hiding package network-2.4.1.2 to avoid conflict with later version network-2.6.2.0
hiding package parallel-3.2.0.3 to avoid conflict with later version parallel-3.2.0.6
hiding package GLURaw-1.3.0.0 to avoid conflict with later version GLURaw-1.4.0.2
hiding package binary-0.6.4.0 to avoid conflict with later version binary-0.7.4.0
wired-in package ghc-prim mapped to ghc-prim-0.3.0.0-d5221a8c8a269b66ab9a07bdc23317dd
wired-in package integer-gmp mapped to integer-gmp-0.5.0.0-2f15426f5b53fe4c6490832f9b20d8d7
wired-in package base mapped to base-4.6.0.1-8aa5d403c45ea59dcd2c39f123e27d57
wired-in package rts mapped to builtin_rts
wired-in package template-haskell mapped to template-haskell-2.8.0.0-a3012803fde1dc362e555b35a1a78e6d
wired-in package dph-seq not found.
wired-in package dph-par not found.
Hsc static flags: -static
*** Chasing dependencies:
Chasing modules from: *MyProg.hs
MyProg.hs:2:8:
Could not find module `Graphics.Gloss'
Locations searched:
Graphics/Gloss.hs
Graphics/Gloss.lhs
*** Deleting temp files:
Deleting:
*** Deleting temp dirs:
Deleting:
What seems to be the issue? (The machine has not changed at all since the program last worked fine, I had installed and used Gloss successfully then).

Linking Error Using HsLua on Windows

I am having some issues using HsLua as a library. Lua compiles just fine as a standalone. And this version runs on my Linux box without a problem. Here is the linking error I see.
GHCi, version 7.4.1: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude> import Scripting.Lua as Lua
Prelude Lua> l <- Lua.newstate
Loading package hslua-0.3.4 ... linking ... <interactive>: C:\..\AppData\Roaming\cabal\hslua-0.3.4\ghc-7.4.1\HShslua-0.3.4.o: unknown symbol `___strtod'
ghc.exe: unable to load package `hslua-0.3.4'
Prelude Lua>
I did some poking around the libraries and found the call for strtod and I think I may have been close but obviously not close enough.
EDIT
This may or may not help. I'll post the cabal file, I made a couple of changes such as adding the os(windows) portion.
Name: hslua
Version: 0.3.4
...
Extra-source-files: src/*.h
Library
Build-depends: base==4.*
Exposed-modules: Scripting.Lua, Scripting.Lua.ConfigFile
Hs-source-dirs: src
C-sources: src/lapi.c, src/lauxlib.c, src/lbaselib.c, src/lcode.c,
src/ldblib.c, src/ldebug.c, src/ldo.c, src/ldump.c, src/lfunc.c,
src/lgc.c, src/linit.c, src/liolib.c, src/llex.c, src/lmathlib.c,
src/lmem.c, src/loadlib.c, src/lobject.c, src/lopcodes.c,
src/loslib.c, src/lparser.c, src/lstate.c, src/lstring.c,
src/lstrlib.c, src/ltable.c, src/ltablib.c, src/ltm.c,
src/lundump.c, src/lvm.c, src/lzio.c, src/ntrljmp.c
Include-dirs: src
ghc-options: -Wall
extensions: ForeignFunctionInterface
if os(linux)
CC-Options: "-DLUA_USE_LINUX"
if os(darwin)
CC-Options: "-DLUA_USE_MACOSX"
if os(freebsd)
CC-Options: "-DLUA_USE_POSIX"
if os(windows)
CC-Options: "-DLUA_BUILD_AS_DLL"
includes: stdlib.h
I tried a couple of different ways to get the stdlib in the project, I've added it in main headers for the project and I've also specified it in the cabal file. Makes me think that is barking up the wrong tree.
EDIT-2
Well I haven't been able to get this built yet on win32. A couple of other things I tried to do that didn't work for me just in case someone else runs into the same problem.
I linked all of the built object files into a static archive and I got the same error as above. I also tried to use a build DLL and I got a different error but I'm not sure if it were progress forwards or backwards.
C:\..\hslua-0.3.4>ghci liblua.dll -package hslua
GHCi, version 7.4.1: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package hslua-0.3.4 ... linking ... ghc.exe: C:\..\hslua-0.3.4\ghc-7.4.1\HShslua-0.3.4.o: unknown symbol `_lua_close'
ghc.exe: unable to load package `hslua-0.3.4'
Hey I was struggling with exactly the same thing on windows and what worked for me was adding the following to the cabal file
if os(windows)
CC-options: "-D__NO_ISOCEXT"
that makes gcc not use the special __strtod but rather just the normal one.

Resources