ByteCodeLink error with GHCi and C file - haskell

When I run my file using a foreign import for a C function I made, I get this error.
ByteCodeLink: can't find label
During interactive linking, GHCi couldn't find the following symbol:
richards
This may be due to you not asking GHCi to load extra object files,
archives or DLLs needed by your current session. Restart GHCi, specifying
the missing library using the -L/path/to/object/dir and -lmissinglibname
flags, or simply by naming the relevant files on the GHCi command line.
Alternatively, this link failure might indicate a bug in GHCi.
If you suspect the latter, please send a bug report to:
glasgow-haskell-bugs#haskell.org
After creating a .cabal file and loading it in GHCi from there, I still get this error.
Any ideas?

Related

How to reload a file in ghci without modifying the source code?

I am using ghc-8.10.2. When I compile a source file (which contains many top bindings and a main function, without a module declaration) into a executable, then type ghci to use the interpreter of ghc, load the source file with the :load filename command. I found that only the main top-binding is visible in ghci environment, other top bindings can be refereed unless I have made some meaningless modification to the source file, and reload it, I have tried to reload the file without making changes in the source file, even with the :reload command, but it doesn't work, so I want to ask if there is a command to force reload a module at any time.
Up to the Haskell Report
An abbreviated form of module, consisting only of the module body, is permitted. If this is used, the header is assumed to be ‘module Main(main) where’.
Meaning that if you don't use a module declaration, by default you only export the main function from it. That's why you can only load such function. If you want to avoid this start your file with
module Main where
...
:r should be it, instead of :reload that other people seem to have used.

Use different configuration for "ghci" and "stack ghci"

I often use ghci for little calculations and stack ghci to work on my actual projects.
To make the first easier I have written a .ghci file with a lot of imported modules in it, but some of these modules aren't present in my stack project and I get nasty errors.
At the moment I use a alias stackghci="stack ghci --ghci-options -ignore-dot-ghci", but then I have the default prompt again and so on..
Is there a way of specifying two .ghci files; one for stack and one for ghci?
ghci supports the --ghci-script flag for specifying additional scripts to read at startup.
Docs for --ghci-script: (link)

gvim syntastic Error: Module XXX cannot read file 'file\etc\etc'

I have a set of libraries that live in another folder and syntastic is trying to look for this libraries in the same folder where program lives. For example, the program I have, let's call it, myprogr.d is in c:\programming\myprogr.d. There are libraries inside that program that are address as this
private import jic.libs.myLibs;
and this library exists in C:\D\Import\jic\libs\mylibs.d. When I compile this program, I pass -IC:\D\Import option to the compiler whom finds the entry point for the mentioned library and continues one without a problem. How can I make Syntastic not give me this error?

cabal repl is too slow

Currently, cabal repl is unusable for me. Typing at the prompt is erratic: a few letters appear, then it seems to hang for 5-10 seconds, only to proceed again afterwards. I suspect it's related to the fact that it loads Alex/Happy generated files (81K and 134K respectively) into the REPL. I don't really need those files for REPL support most of the time. I'm not sure if that's actually the problem, but I don't know what else to try.
I'd like to be able to exclude them from the REPL while still including them in the build process. Even better: can I only use one function from each of those files (lex/parse) somehow?
Edit: I'm seeing this behavior with GHC 7.8.3/Cabal 1.20.0.3 running on OS X 10.9 and a mid-2012 rMBP (Sandy Bridge) with 16GB of RAM. GHC/Cabal was installed via Homebrew.
Edit 2: Cabal file in question
Can you post your .cabal file?
If I understand your situation correctly, here's how I might proceed:
Verify that the alex and happy generated files are causing the slowdown.
If that is the case, consider moving them into a different package so that ghci will load the compiled versions of them.
For #1, I might try replacing the alex and happy generated files with just stubs - skeletal files which contain definitions (= undefined) for only the symbols which are imported by other modules.
I tried reorganizing the code per user5402's answer, but I wasn't able to get much of a speedup, even with code in different base packages.
Instead, I created a .ghci file in the project directory with the following contents:
:set -fobject-code
This loaded compiled versions of modules, with only the exported functions callable. For my uses, this is fine.

emacs haskell-mode repl can't find hugs. how to use ghci instead?

To set up my haskell-in-emacs environment, I dutifully followed the instructions here:
http://tim.dysinger.net/posts/2014-02-18-haskell-with-emacs.html
When I load Main.hs, it syntax-highlights correctly. When I do Ctrl-c Ctrl-l as instructed, it reports:
Searching for program: No such file or directory, hugs.
I'm pretty sure the problem is that it should be using ghci, but I'm new to these packages.
The contact page of the person that wrote the above page says that he does not want to be contacted. So here we are. Any help appreciated.
I'm on OS X 10.9.2 (Mavericks). I already had emacs installed. Otherwise I followed the instructions.
I'm grepping all the places that seem relevant but I can't find a direct mention of a hugs executable anywhere.
Does anyone know where this error message is coming from, and what I can do to get this working?

Resources