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?
Related
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.
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.
I have a source file that will only compile with Cabal. It's test code, and in the past (before I complicated my Haskell environment) I would run functions from within ghci.
I know ghci can use object files to load code, but when I try to do so I get the following error. So what am I missing?
[mlitchard#Boris Boris_Test]$ ghci /home/mlitchard/Boris_Test/dist/build/Boris_Test/Boris_Test-tmp/Main.o
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 object (static) /home/mlitchard/Boris_Test/dist/build/Boris_Test/Boris_Test-tmp/Main.o ... done
final link ... ghc: /home/mlitchard/Boris_Test/dist/build/Boris_Test/Boris_Test-tmp/Main.o: unknown symbol
monadzmcontrolzm0zi3zi1zi3_ControlziMonadziTransziControl_zdfMonadBaseControlIOIO_closure'
linking extra libraries/objects failed
When you specify object files manually, GHCi can't tell what the object file depends on, which it would be able to do with .hs files, because it has access to the import ... lines in that situation.
Therefore, you need to add the object files of all the relevant dependencies manually, in this case by adding -package monad-control, when invoking GHCi.
I create a simple module, TestModule.hs, which contains a single exported top-level definition testval = 2. I compile it, creating TestModule.o and TestModule.hi. I delete TestModule.hs. I then load TestModule.o in ghci, like this:
~ λ ghci TestModule.o
GHCi, version 7.0.3.20110517: 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 ffi-1.0 ... linking ... done.
Loading object (static) TestModule.o ... done
final link ... done
Prelude>
As you can see, TestModule isn't in scope and I cannot access testval. Why? How can I accomplish this without access to the source file?
Additional question: how do I accomplish the same thing using the hint package?
Thanks!
You can't interpret something that's already been compiled. If you want to interpret it, you need the source. You can make a package, if you like. Instructions are here.
The page: (http://en.wikibooks.org/wiki/Haskell/GUI) describes that to run wx code, one can install wx and then one must "register wxHaskell with GHC" - but I think the binary installer of wxHaskell (http://wxhaskell.sourceforge.net/download.html) does that automatically?
I installed wx-config, and then wxPack, and wxHaskell. and then did cabal install of wx and wxcore. I am running some wx demos from Leksah, which seem mostly good - but they had some weird errors (I found an alleged solution to that: "wxhaskell-labels-cant-display-full-text"), but I wanted to try some things just from GHCi.
I try to run their simple demos, and the the errors:
D:\csPlangs\Haskell\play>ghci -package wx wxGui1.hs
GHCi, version 7.0.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.
Loading package array-0.3.0.2 ... linking ... done.
Loading package stm-2.2.0.1 ... linking ... done.
Loading package bytestring-0.9.1.10 ... linking ... done.
Loading package containers-0.4.0.0 ... linking ... done.
Loading package Win32-2.2.0.1 ... linking ... done.
Loading package filepath-1.2.0.0 ... linking ... done.
Loading package old-locale-1.0.0.2 ... linking ... done.
Loading package old-time-1.0.0.6 ... linking ... done.
Loading package directory-1.1.0.0 ... linking ... done.
Loading package transformers-0.2.2.0 ... linking ... done.
Loading package mtl-2.0.1.0 ... linking ... done.
Loading package parsec-3.1.1 ... linking ... done.
Loading package time-1.2.0.3 ... linking ... done.
Loading package wxdirect-0.12.1.4 ... linking ... done.
Loading package wxcore-0.12.1.7 ... ghc.exe: stdc++: The specified module could
not be found.
<command line>: can't load .so/.DLL for: stdc++ (addDLL: could not load DLL)
And also the [interesting] error:
*Main> q
<interactive>:1:1: Not in scope: `q'
*Main>
ghc.exe: panic! (the 'impossible' happened)
(GHC version 7.0.3 for i386-unknown-mingw32):
thread blocked indefinitely in an MVar operation
Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug
It appears to be a known problem with the combination of wxHaskell, GHCi, and Windows. From http://www.haskell.org/haskellwiki/WxHaskell/Quick_start
On Windows 7, ghci will complain "can't load .so/.DLL for: std c++ ...". But ghc --make Hello.hs; Hello.exe on the command line works well.
So, you can compile your code. You just can't run it through the interpreter.