Agda: Unable to do IO - missing Data.FFI, IO.FFI - io

I've done stuff in agda as a hobby for a few months now, and I started to make a provably safe\correct Tic Tac Toe game.
I've got all the lemmas proofs and definitions, but now that I have tried to get input and print output I've ran into a problem.
All "Hello World" examples taken from the web have failed, most of them with the message that I am missing Data.FFI and IO.FFI.
I've looked around for a solution online,, but none were of use. One website said I should run "cabal install" from agda/agda-stdlib-0.11/ffi but I"m not even sure if I have that folder on my computer, and I have many folders named "agda", all over the computer (this is my first time using linux for something, so I probably did stuff horribly)
This is the error I get when trying to run the code from EMACS with agda-mode (C-c C-x C-c)
Compilation error:
MAlonzo/Code/Agda/Primitive.hs:4:18:
Could not find module ‘Data.FFI’
Use -v to see a list of the files searched for.
MAlonzo/Code/Agda/Primitive.hs:5:18:
Could not find module ‘IO.FFI’
Use -v to see a list of the files searched for.
If it matters, I'm running Ubuntu.
Thank you very much for the help!

One website said I should run "cabal install" from agda/agda-stdlib-0.11/ffi
That is correct. From the README for the standard library 0.11:
-- To compile the library using the MAlonzo compiler you first need to
-- install some supporting Haskell code, for instance as follows:
--
-- cd ffi
-- cabal install

Related

How can I use the command `runhaskell`?

I am trying to run the Haskell script in this StackOverflow answer. Pandoc appears to execute the runhaskell executable because I get the error
Could not find executable runhaskell
Seems like I need Haskell. So I google "install haskell", go to haskell.org, and follow the install instructions. It appears to install correctly. For example, I now have a $HOME/.ghcup/ directory and the stack command works. However, runhaskell still does not work. When I search Haskell Tool Stack, I don't see any meaningful hits. However, there is a stack command called runhaskell. When I add stack runhaskell to the top of chapter.hs from the previous post, I get the same error.
I even tried following a "hello world" for Haskell but the first step, using ghci, fails. So maybe I didn't even install the Haskell Platform correctly.
Feels like a really stupid issue, but I can't figure out how to install the executable runhaskell which, I assume, will run a Haskell program.
looks like runhaskell is not in your $PATH

Could not find module in runhaskell-script

I code haskell of poor quality in december each year. This year my environment is broken for some reason.
When I try to run my old scripts with
runhaskell .\myCode.hs
I get
Could not find module `Data.List.Split'
Use -v to see a list of the files searched for.
This question has a comment in one of the answers:
Maybe he doesn't even use a .cabal or .yaml file and only wants to write a stand-alone Haskell script for runhaskell.
That is exactly what I'm after, but the comment thread does not provide an answer. It worked 2016-2018 and I do not remember this issue, and I've never had the setup that is written about here or here("hidden modules").
Anyone have an idea how to fix this?
Edit: I tried the guide here which says to download the package, extract it and run:
runhaskell Setup configure
runhaskell Setup build
runhaskell Setup install
But I just get an error which says:
$ runhaskell Setup configure
Configuring split-0.2.3.3...
Setup: Encountered missing dependencies:
base <4.12
And I do have a Haskell\8.6.3\lib\base-4.12.0.0 in the installation.
Data.List.Split is not part of "base", the core libraries that are distributed with Haskell. It is part of an external package named "split". If you want to use it, you must get that package somehow. This is typically done with cabal or stack. Perhaps there is a way to do this that runhaskell understands; I don't know anything about runhaskell.
Ok so after following the instructions to do things manually, I double checked that I had the latest split package. The web page says the package requires base (<4.14) but it still complains Setup: Encountered missing dependencies: base <4.12 when I try to run runhaskell Setup configure
But then after I've tried and failed to install an older 'base', seemed like a long shot anyway, I simply followed the 'Installing packages using cabal' part of the guide.
cabal update
cabal install split
I ran those two commands and ignored the warnings that it was part of the legacy v1 cabal usage. It worked and it installed split so the runhaskell command could access it.

Idris/cabal install issues from removePathRecursive on Windows

Installing Idris on Windows 10 using instructions to:
Install Haskell following this
Replaced , with ; in multiline paths of config files as reported by #gergelybat in this
c:\Users\me\cabal update
c:\Users\me\cabal install idris
Several dependency errors arise, I follow Idris' instructions to apply with blind faith the following further flags
----reinstall
--avoid-reinstalls
--force-reinstalls
--upgrade-dependencies
Progress is made things begin to be built, we get all the way to building a temp directory with something called idris-1.3.1\…\setup.exe
Then we crash with following error:
C:\Users\me\AppData\Local\Temp\cabal-tmp-26128\idris-1.3.1\dist\setup: removeDirectoryRecursive:
…": unsatisfied constraints (The directory is not empty.)
Googling this I find this same error happens across cabal installs and logged as issues on oodles of GitHub projects. Theories are all over the map and no solutions provided. The Haskell documentation on removeDirectoryRecursive offers a clue ending with the remark that this fails on Windows if the directory is a symbolic-link.
How does one get past this problem to finish an install?
This is mostly to record the steps that worked, thanks to Michael Sonyman for the major tip.
Steps to follow.
Install Haskell (with Stack) following this
Replace , with ; in multiline paths of config files as reported by #gergelybat in this
Check that you have a version of make by checking stack exec -- which make
if you get no make then install GnuWin32,
ensure that the install directory for (e.g. c:\Program Files (x86)\GnuWin32\bin is added to your system path (follow "set environment variables").
Restart PowerShell/Command prompt, retry step 3, you should see a make found, if not recheck your steps.
Run stack install --resolver lts-12.26 idris … this may be very slow. It ends by copying the Idris compiler and other items to C:\Users\you\AppData\Roaming\local\bin:
Test by typing idris at prompt, it should load the Idris REPL.
Enjoy dependent typing for the rest of your programming life.
You could try using cabal new-build or cabal new-install, but I am not sure if that will work.

Haskell "Could not find module ---" Quipper

I am extremely new to haskell and I have been searching all over the web but I haven't been able to solve my problem. I downloaded the Quipper package but I have not been able to get haskell to recognize where all of the modules and files are and how to properly link everything.
I have downloaded all of the files and programs and installed them properly, I just dont know how to get haskell to recognize the quipper libraries and templates. Evey time I try:
:load And_gate.hs or some other file.
I get:
Could not find module "Quipper" or its respective modules it requires.
I don't think it is an error or anything, I think it is just my lack of knowledge on how haskell works.
I'm using windows 7.
So I emailed Peter Selinger, one of the professors who created Quipper.
The only thing I need to do extra was inside MSYS:
ghci -iC:/quipper -iC:/quipper/quipper
This complies everything correctly and the files run properly.
Here is his email to me:
Dear -----,
thanks for writing. Let me see if I can help.
Are you following the instructions in the README file? Under "Building
the various algorithms and programs", the instruction is to run
"make". This would build all of the tests in the "tests" directory
automatically.
Next, to compile a Quipper program, you should use the "quipper"
script that is located in quipper/scripts. It works just like "ghc",
except that it automatically includes the correct directories for
Quipper's files in the search path. On Windows, you would be using
"quipper.bat".
Quipper is not really meant to be run interactively, i.e., from ghci.
However, if you do need to run Quipper interactively, I recommend
using the "quipperi" script, also in quipper/scripts. This too would
set the load paths correctly. In Windows, use "quipperi.bat".
Finally, if you need to include Quipper stuff from ghci, but for some
reason can't or don't want to use the quipperi script, you need to
specify those directories with the "-i" option, for example
ghci -iC:/quipper -iC:/quipper/quipper
It could be that in Windows, you need to use "\" instead of "/", but I
am not sure if this is necessary.
I hope this helps, -- Peter
When compiling and exe with ghc just make sure you include the commands:
-iC:/quipper -iC:/quipper/quipper.
If you use the quipper script as suggested by Professor Selinger, inside of MSYS do the following:
Navigate to the folder in which all of the Quipper files are held, this was my case:
cd C:/quipper/quipper/scripts
Then type quipper and your file's location in MSYS to compile an exe like so:
quipper C:/quipper/tests/And_gate.hs
The file will compile and should print updates like so:
[1 of 22] Compiling Libraries.Typeable (......
[2 of 22] Compiling Libraries.Tuple (......
and so on.
The exe (in this case And_gate.exe) will be inside the folder it was compiled from (C:/quipper/tests). You'll need to move it to a folder that contains the acroread.bat which comes in quipper/scripts for it to work properly.
For some reason, this code isn't packaged as a standard Haskell package. It if were, installing it would be fairly simple. As it is, the instructions in the README file look awful (especially under Windows, where it looks like you need MSYS to run the makefile).
Your problem might be as simple as telling GHCi which folder to look in to find the files; you can do that using the :cd command. Since you're on Windows, I'd suggest trying WinGHCi, which should allow you to browse to the right folder using the GUI.
If it isn't that simple... really, as a Haskell beginner, you're probably going to struggle to get this working. The documentation looks pretty minimal.
If you red both README and INSTALLING.windows and did everything as well, then you should add a path to Quipper's script folder to environment variable. Here is the path:
quipper-*/quipper/scripts/
where quipper-* is a <distribution name>-<version>.
There are two important scripts in that folder. The first one is quipper.bat which runs a ghc compiler to run Quipper's modules. The second one is quipperi.bat which is a ghci analogue for Quipper.
Now, when you added a path to variable, you can run And_gate.hs in Quipper's interpreter as follows:
quipperi And_gate.hs

Help with running the Yesod Development server?

I'm currently trying out web development frameworks for haskell and I recently came across yesod. It seemed pretty interesting so I installed it using cabal, however I'm not able to run the development server. Following their getting started instructions here's the result:
$ yesod init
$ cd mysite
$ yesod devel
Configuring mysite-0.0.0...
Testing files...
Rebuilding app
yesod: bind: resource busy (Address already in use)
Preprocessing library mysite-0.0.0...
Preprocessing executables for mysite-0.0.0...
Building mysite-0.0.0...
Controller.hs:16:7:
Could not find module `Data.Dynamic':
It is a member of the hidden package `base'.
Perhaps you need to add `base' to the build-depends in your .cabal file.
It is a member of the hidden package `base-3.0.3.2'.
Perhaps you need to add `base' to the build-depends in your .cabal file.
Use -v to see a list of the files searched for.
Testing files...
Testing files...
^^ above line just keeps repeating...
I'm assuming it has something to do with the Data.Dynamic module but I don't know how to go about fixing it.
Additional Info
Running Ubuntu 10.10 Maverick
ghc version:
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 6.12.1
I haven't run into this specific issue, but the error message looks like it's a simple question of GHC being unable to find version 3.0.3.2 the package "base." This version has been buildable since GHC 6.9, so you should have it. Try running the following command:
ghc-pkg check
This will tell you if there is something wrong with your packages. Cabal can be a bit of a nightmare for dependencies -- partly, it seems, because a lot of Haskell developers underestimate the extent to which their underlying libraries will shift in the future. So they will define a dependency as ">= [version of package x]" without limiting the max version to the one presently available. Or they just leave out version-limiting altogether.
Yesod, I'm happy to say, doesn't fall into this trap. But several of the libraries it depends on do. When you start developing in Haskell, learn this lesson: never assume that future versions of a library won't break your code. They will. A lot.
If ghc-pkg comes up with broken packages, you may need to clean up/uninstall/reinstall these packages until they are either cleaned up or hidden. (Just do ghc-pkg hide [package name] to tell ghc to ignore that package.
Your next problem is that hidden base package. Try the following:
ghc-pkg list | grep base
If you see brackets around the library, that means it's hidden. The package base-3.0.3.2 might show up as hidden (although that's a bit unlikely, as that's where the backward-compatible Prelude lives). If it is hidden, try to unhide it with the following command:
ghc-pkg expose base-3.0.3.2
Now try re-running yesod devel and see how it goes. Best case scenario is that it works. If not, let us know.
According to the Yesod in Five Minutes guide, you appear to be missing the a call to the command "cabal install" between your "cd mysite" and "yesod devel". It may need to install further packages based on what your responses were during "yesod init", such as which database you want to use.
Also, you may want to check that the port is not currently being used, as you have the "Address already in use" shown in your transcript.
First, it would be a good idea to resolve any broken packages reported by ghc-pkg check, by removing/reinstalling/upgrading them.
Next, can you manually cabal build the mysite app without trouble ? If your mysite.cabal actually does not specify base in the build-depends list, you should follow the suggestion to add that.
The repeating Testing Files message is normal for current yesod devel, it is polling your source files.

Resources