Archive for the ‘functional programming’ Category
Installing Haskell plugin for Eclipse
I use Eclipse for all sorts of development in C, Java and Haskell. It gives me uniform look and feel on every project. This is updated post with instructions for installing Haskell plugin for Eclipse.
This time I am installing on Windows XP (and Ubuntu 9.10 after) machine.
Windows XP
We need the following software installed (and versions i am installing):
- Eclipse (3.5.1) +Java (1.6)
- GHC (6.10)+Cabal
- EclipseFP plugin (1.108.0)
- Scion IDE library
Ubuntu 9.10
I have no success to run Wink on Ubuntu 9.10 (it seems to work on 8.10) so no screencast just instructions for now.
GHC
- First if you don’t have GHC installed install it “sudo apt-get install ghc”. There is still no GHC 6.10 version for Ubuntu so i am installing it manually.
- go to “http://haskell.org/ghc/” Binary Packages->Linux (x86)
- get “ghc-6.10.4-i386-unknown-linux-n.tar.bz2″
- “tar jxvf ghc-6.10.4-i386-unknown-linux-n.tar.bz2″
- “cd ghc-6.10.4/”
- “./configure –prefix=/home/ross/ghc” – here i put installation in custom location in my HOME directory. If you want this to be installed on standard location skip “–prefix” and run as “sudo”. Also skip next steps.
- make install
- Now extend PATH environment variable to this custom location. “vi ~/.bashrc” add “PATH=$PATH:/home/ross/ghc/bin” and “export PATH”
- If you want GHC 6.8 just skip previous steps and “sudo apt-get install ghc”
Cabal
- get Cabal “http://www.haskell.org/cabal/download.html” “cabal-install-0.6.2.tar.gz”
- “tar zxvf cabal-install-0.6.2.tar.gz” – extract archive
- “cd cabal-install-0.6.2/”
- “./bootstrap.sh” – here installation stops with some missing library like “/usr/bin/ld: cannot find -lgmp”. The reason is that you need not only library (in this case Multiprecision Arithmetic Library) but also development version of it. Install development version “sudo apt-get install libgmp3-dev” and run “./bootstrap.sh” again. If all dependencies are resolved “cabal” is installed in you HOME directory for example “/home/ross/.cabal/config”.
- Run cabal to update and to install Scion “~/.cabal/bin/cabal update” “~/.cabal/bin/cabal install scion”. There are some warnings during the installation. Lets hope they aren’t important ones.
Eclipse
- Install eclipse if not already installed “sudo apt-get install eclipse”
- Run and choose “workspace” location.
- Go to “Help->install new software”
- “add” and enter name “GHC 6.10″ and location “http://eclipsefp.sf.net/updates”
- Expand list of plugins and select new version of the plugin “1.108.0″ (this version uses Scion). Install it.
- go to “Window->Preferences->Haskell->Haskell Implementations”. Add name “GHC 6.10″ and executable folder “/home/ross/ghc/bin”. In this case my custom installation location.
- Go to Scion section “autodetect”. It detects the scion server at “/home/ross/.cabal/bin/scion-server”. “apply” options.
- Change default Java to “Haskell” perspective at the right top corner of Eclipse. “click->other..->Haskell”
Haskell programming
Now lets create simple Haskell project to test the installation.
- “file->new->Project->Haskell Project”
- project name “Hello”
- Expand created project and right click on “src” directory “new->haskell module”. Source folder is set to “/Hello/src”. Enter module name “Main”.
- in “Main.hs” file enter “module Main where” next “mian = putStrLn “Hello World!”. Save and click on green button “Run As->Run GHCi session”. Next time you run it there should be “Main” item in “Run” button list.
- Type “main” in console tab. Now you should see “Hello World!” written to console.

Enjoy happy programming.
Commercial Users of Functional Programming Videos
Just found a lot of videos from the “Commercial Users of Functional Programming” Edinburgh 2009
Lectures on Haskel, Scala, Erlang, F# etc.
Running Haskell Array Computations on a GPU
Paper on Multicore Programming in Haskell – A. Al Zain, P. Trinder, M. Aswad, G. Michaelson, K. Hammond and J. Berthold
A. Al Zain, P. Trinder, M. Aswad, G. Michaelson, K. Hammond and J. Berthold “Low-Pain, High-Gain Multicore Programming in Haskell: Coordinating Irregular Symbolic Computations on MultiCore Architectures” – http://www.macs.hw.ac.uk/~greg/publications/
Tags: functional programming, Haskell
Functional Prgoramming Software Testing – videos
Type-driven testing in Haskell – Simon Peyton Jones http://video.google.com/videoplay?docid=-4991530385753299192
Simon Peyton Jones talks about QuickCheck and SmallCheck.
FP A Secret Weapon for Software Testing – John Hughes http://video.google.com/videoplay?docid=4655369445141008672
John Hughes gives an invited talk at ICFP 2007 in Freiburg, Germany, showing from his company’s experience how QuickCheck has found many obscure bugs in commercial software. *Even when the software under test is not written in a functional language.
Tags: functional programming
GPU Kernels as Data-Parallel Array Computations in Haskell
This paper provides a brief overview of approach to GPU programming with Haskell by embedding GPU kernels with a domain-specific language of data-parallel array computations in Haskell code. The paper also presents some preliminary benchmarks.
We present a novel high-level parallel programming model aimed at graphics processing units (GPUs). We embed GPU kernels as data-parallel array computations in the purely functional language Haskell. GPU and CPU computations can be freely interleaved with the type system tracking the two different modes of computation. The embedded language of array computations is sufficiently limited that our system can automatically extract these computations and compile them to efficient GPU code. In this paper, we outline our approach and present the results of a few preliminary benchmarks.
http://www.cse.unsw.edu.au/~chak/papers/LCGK09.html
Tags: functional programming, GPU, Haskell
Simon Peyton Jones – A Tutorial on Parallel and Concurrent Programming in Haskell
Simon Peyton Jones and Satnam Singh, Advanced Functional Progamming Summer School, Nijmegen, May 2008, LNCS
This practical tutorial introduces the features available in Haskell for writing parallel and concurrent programs. We first describe how to write semi-explicit parallel programs by using annotations to express opportunities for parallelism and to help control the granularity of parallelism for effective execution on modern operating systems and processors. We then describe the mechanisms provided by Haskell for writing explicitly parallel programs with a focus on the use of software transactional memory to help share information between threads. Finally, we show how nested data parallelism can be used to write deterministically parallel programs which allows programmers to use rich data types in data parallel programs which are automatically transformed into flat data parallel versions for efficient execution on multi-core processors.
http://research.microsoft.com/en-us/um/people/simonpj/papers/parallel/index.htm
Tags: functional programming, Haskell
