Archive for the ‘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.

Haskell Eclipse Plugin

Enjoy happy programming.

Client-server architecture

Recently I decided to design my product using the client-server architecture. It was initially designed as standalone application for windows but will continue to grow as bigger application and I would like to have the uniform architecture. My main points for this decision are following:

  • Main algorithm of the program is computationally intensive, i can imagine a dedicated machine that runs the server part for calculations (continuously for big problems) and one and multiple machines for viewing produced reports.
  • Data storage and data integration. It is possibility to store all data in local database (local for server component) or store it in ACD database. With separate server component this can be more easily administered.
  • It is better to separate the GUI from backed implementation from beginning. This can also permit better testing of separate components.
  • Separate server and client component can permit different licensing schemes like releasing the GUI as open source or the components can be run on different operating systems (server on Linux and clients on Windows)

I am still in process of making decision on exact implementation details: communication protocol etc. It can be some custom or some existing protocol or in future to use web services integration. At the moment do not want too spend to much time on this. My goal is to release a functional version with minimum number of features (just the right number in order to get the call center forecasting done). I consider that initial feedback is important and releasing early is the way to understand better customer requirements.