Haskell on MAC LION - haskell

First of all, thank you for looking at this. I am a newbie to programming( I can program Java and Python)
I am gonna ask some really trivial questions.
How do i install the "extra " of Haskell on my mac? My situation is that i got ghci running, i am following the tutorial from my Terminal http://learnyouahaskell.com/introduction
I downloaded GHC
Xcode
Emacs(not working, more explanation below)
But i would like to have something like they use in their examples, a text editor that help me write in .hs and support the programming language. I tried to download Emacs but i couldn't find "haskell" as supported language, and i have no idea how to install it so it works together with my GHC. Also, i don't think the tutorial says a lot about Cabal. How do i access it? If i just go in and type "cabal install" or just "cabal" it just gives me "not in scope" as an answer.
Maybe i misunderstood cabal? it isn't something you "access" as such?
Thanks for checking my post out. I look forward to functional programming!( i am a mathematician :) )

Did you install ghc directly from http://www.haskell.org/ghc/ ? Usually it is better to install haskell platform as suggested in the tutorial. It includes cabal already.
If you used haskell platform, then try to find where cabal is installed and add the directory into your $PATH variable. I think you can fire a bug if platform installer for Mac doesn't install cabal in usual location.
(Note: AFAIK haskell platform installer is broken for new MacOS, it contains hardcoded path to xcode. But it is simple to find and fix)
Check out haskell mode for emacs. I don't use emacs, so the link is the only I can suggest, sorry.

If you have the Apple developer tools installed already, you can look at a package manager like e.g. homebrew (see at Link for installation). Then in a terminal you type
brew install ghc haskell-platform
and it will take care of everything, dependencies etc. You will get ghc, ghci, cabal, everything at once. It will put things in /usr/local/ so you might not even have to edit your $PATH ...
For editing, Aquamacs (download at http://aquamacs.org/) supports Haskell out of the box, and is very Mac-friendly.

Related

Override the cabal version of an LTS

I have a project that I want to compile with LTS 2, but I'm stuck trying to work around this well-known bug in OS X 10.11.
Can I somehow specify a newer version of Cabal to use with ghc-7.8.4? Note that the project only really compiles with GHC 7.8.*.
Edit:
Really meant Cabal, not cabal-install.
Edit 2:
Actually, the answer to this question doesn't really solve my concrete problem (compiling helium, which requires GHC <= 7.8.4), because the bug is not specific to Cabal, but rather to unix, which GHC < 7.10 depends upon.
I think the problem is related not just to Cabal library version (btw, stack doesn't use or need cabal-install), but also to GHC version. Stack's FAQ mentions an item about this error, but I think it didn't help for me and I just upgraded to 7.10.2 at the time.
Here's a recipe for installing ghc-7.8.4 into the directory of your choice:
Download the "bindist" from https://www.haskell.org/ghc/download_ghc_7_8_4#macosx_x86_64
Untar it into a scratch directory
Create the destination directory, e.g. $HOME/my-prefix.
In the scratch directory run:
$ ./configure --prefix=$HOME/my-prefix
$ make install
Now ghc may be found in $HOME/my-prefix/bin.
As noted in Michael Snoyman's comment, there is stack setup --upgrade-cabal to do just that. That's it for the answer to this question.
In my specific case (XY problem), for that to work I had to do the usual work-around for that El Capitano related bug, which is explained here. So I enabled rootless, ran the upgrade command and re-enabled rootless.
To no avail I'm afraid: The bug is specific to unix < 2.7.1.0, which GHC 7.8.4 also depends on. So even after upgrading cabal, I can't compile anything in lts-2 unless I disable rootless, which is pretty annoying.
Actually it's kinda depressing that the GHC folks decided not to file a new minor release with the updated unix package. This means that no realistic/recent OS X configuration can build anything which involves GHC < 7.10.

Atom haskell IDE autocompletion and typeinfo not working

I installed atom-haskell packages for syntax coloring, autocompletion and typeinfo but only syntax coloring is working. I installed every dependency (ghc-mod, ghc-modi and hlint). I added paths to dependencies in package haskell-ghc-mod. Everything should be working ... (Project is created via cabal).
EDIT: I dive deeper into into it and I realized that autocompletion depends on ghc-mod browse module command. And when I use this command, it returns nothing. It seems like a bug in ghc-mod for me. Any ideas what to do?
EDIT: this is strange. ghc-mod has working typeinfo, but in Atom, no typeinfo ...
EDIT: cabal version is 1.16.0.2
EDIT: ghc-mod version is 5.3.0.0
EDIT: Interesting. Only thing which is working is coloring ... the rest not works ... It's stupid, after more than 20 years of Haskell development, theres no "usable" IDE for it. I tryed emacs ... again, only coloring ...
Don't know if you are still using the ghc-mod version you said you are(version is 5.3.0.0), but in the docs (https://atom.io/packages/haskell-ghc-mod) it explicitly says the following:
Supported ghc-mod versions are from 4.1.0 to 5.2.1.2.
Try to rm and enforce this version.
According to stackage (https://www.stackage.org/package/ghc-mod) your version was published 14-Aug-2015 and the one supported by the atom plugin was published 8 months ago, 2014-12-31 v5.2.1.2.

haskell-process file not found in haskell-mode

I'm trying to follow the haskell wiki to set up emacs to program haskell. I'm using haskell mode, and that seems to be working and okay, but now I try to generate haskell tags to be able to open a file with the M-. shortcut. I installed hasktags and haskell-mode as described here : http://www.haskell.org/haskellwiki/Emacs/Project_navigation. However, when I try to generate the tags through M-x haskell-process-generate-tags I get a 'not found' error. I found a post on stack overflow about this, How do I set up haskell-mode to generate tags?, which described my problem and solved it by loading haskell-process from .emacs.d/el-get/haskell-mode/haskell-process.el as path.
However, I'm on Ubuntu, and I installed the haskell-mode (and haskell-platform and emacs of course) through aptitude, and that didn't seem to contain this haskell-process.el file mentioned in that post. I then tried to download the haskell-mode through el-get, and that didn't include the haskell-process file either.
So, my question is, am I correct in assuming that I need the haskell-process file to be able to generate the tags, and if so, where can I get that file? I think I saw it in the git repo of haskell-mode, and I can of course pluck it out and put it in my directory, but I've got the feeling that if I have to resort to that, it means I'm doing something wrong.
Kasper
Emacs packages are usually outdated in Debian-based distributions, and I think, that Ubuntu still have very old version of haskell-mode. It's better to install haskell-mode via package.el, that is bundled together with Emacs. Fresh versions of haskell-mode for package.el are available via MELPA. The similar advice I can give for other Emacs packages ;-)

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.

Cabal: Odd Error Message + Lack of Documentation

So I recently installed cabal (from the default binary of ArchLinux).
I then tried to upgrade cabal as a user:
cabal upgrade Cabal --user --prefix=$USER
Resolving dependencies...
cabal: fromFlag NoFlag. Use fromFlagOrDefault
What I've already done:
Googled the error message. Turned up the cabal source and little else.
Looked at haskell-wiki on cabal-install.
Looked through this guide.
So basically I'm wondering:
What's up with the error message?
Could anyone point me in the direction of a cabal tutorial?
I think that's a bug in Arch's package. I'm running Arch as well, and I got the same error.
I then built cabal-install (0.8.2) from Hackage, which didn't complain when I run cabal upgrade Cabal. In fact, it started building right away, although I didn't let it finish because I didn't feel comfortable upgrading a core package.
May I ask why you wanted to upgrade Cabal? The version that comes with ghc is 1.8.0.2, and the latest version is 1.8.0.4 -- not too distant IMO. Besides, if you're running cabal-install as normal user, why not simply cabal install? It doesn't have permission to overwrite the system files anyway.
I'm guessing wildly here, but can you see if
You have a nonstandard Setup.hs?
You have flags: set in ~/.cabal/config?
The most helpful tutorial I have found is not ostensibly about Cabal; it is called How to Write a Haskell Program.
I have looked through the guide you mention (the official Cabal documentation), and the information I wanted is a tiny bit of flotsam swimming in a sea of complexity. I assume that the complexity serves some useful purpose, since I know that good people have been working very hard on Cabal for several years, but as an outsider, I find the state of play discouraging. I was just barely able to build, install, and upload a simple package of my own—with a little help from my friends on SO.
I tentatively suggest you might want to avoid cabal upgrade and maybe try cabal install instead, and see if you can move forward with your original goals.
From user tlo:
The global configuration file for cabal-install is ~/.cabal/config. If
you do not have this file, cabal will create it for you on the first
call to cabal update.
I deleted my config, ran cabal update, and all was good.

Resources