Saturday, August 23, 2008

Getting started with Haskell

Installation
As you can see on haskell.org, there are four implementations of Haskell. I am using GHC. Installation on MS Windows presents no serious issues (unfortunately, many fine things are Linux only with Windows implementation either non-existent or a step child like effort. I am glad GHC team seems to consider Windows effort important enough.

Packages
Packages are at http://hackage.haskell.org/packages/archive/pkg-list.html. I haven't managed to get it working on my system yet. Installing packages one at a time has worked out okay. Here is a sample of how I do it.

  1. Download the package or use darcs client to check out the sources
  2. cd to the directory which contains Setup.hs or Setup.lhs
  3. Run: ghc --make Setup.hs
  4. Run: setup configure
  5. Run: setup build
  6. Run: setup install
These steps will install the package under c:\Program Files\Haskell\... You can them import the packages in Haskell.

Issues
It is possible you will run into some issues in building. For e.g., hscom package complains of missing files as below.

C:\tools\haskell\hscom>setup makefile
Preprocessing library hscom-0.1...
Generating Makefile hscom-0.1...

C:\tools\haskell\hscom>setup configure
Configuring hscom-0.1...
Warning: No license-file field.

C:\tools\haskell\hscom>dir dis

C:\tools\haskell\hscom>setup build
Preprocessing library hscom-0.1...
Building hscom-0.1...

src\Foreign\COM\Automation\SafeArray.hsc:22:22:
Can't find dist\build/Foreign/COM/Automation/Variant.hs-boot

I got around that by copying the missing file.

C:\tools\haskell\hscom>copy src\Foreign\COM\Automation\Variant.hs-boot dist\buil
d\Foreign\COM\Automation
1 file(s) copied.

C:\tools\haskell\hscom>setup configure

C:\tools\haskell\hscom>setup build
Preprocessing library hscom-0.1...
Building hscom-0.1...
[ 1 of 17] Compiling Foreign.COM.Automation.Variant[boot] ( dist\build/Foreign/C
OM/Automation/Variant.hs-boot, dist\build/Foreign/COM/Automation/Variant.o-boot
)
[ 2 of 17] Compiling Foreign.COM.Automation.BSTR ( src/Foreign/COM/Automation/BS
TR.hs, dist\build/Foreign/COM/Automation/BSTR.o )
[ 3 of 17] Compiling Foreign.COM.Marshal.Alloc ( src/Foreign/COM/Marshal/Alloc.h
s, dist\build/Foreign/COM/Marshal/Alloc.o )
[ 4 of 17] Compiling Foreign.COM.Marshal.Exception ( dist\build/Foreign/COM/Mars
hal/Exception.hs, dist\build/Foreign/COM/Marshal/Exception.o )
[ 5 of 17] Compiling Foreign.COM.Automation.Currency ( dist\build/Foreign/COM/Au
tomation/Currency.hs, dist\build/Foreign/COM/Automation/Currency.o )
[ 6 of 17] Compiling Foreign.COM.Automation.Decimal ( dist\build/Foreign/COM/Aut
omation/Decimal.hs, dist\build/Foreign/COM/Automation/Decimal.o )
[ 7 of 17] Compiling Foreign.COM.Automation.SafeArray ( dist\build/Foreign/COM/A
utomation/SafeArray.hs, dist\build/Foreign/COM/Automation/SafeArray.o )
[ 8 of 17] Compiling Foreign.COM.Registry ( dist\build/Foreign/COM/Registry.hs,
dist\build/Foreign/COM/Registry.o )
C:\DOCUME~1\pprakash\LOCALS~1\Temp\ghc2832_0\ghc2832_0.hc: In function `s78n_ent
ry':
C:\DOCUME~1\pprakash\LOCALS~1\Temp\ghc2832_0\ghc2832_0.hc:156: warning: implicit
declaration of function `com_hresult_from_win32'
[ 9 of 17] Compiling Foreign.COM.Marshal.VTable ( src/Foreign/COM/Marshal/VTable
.hs, dist\build/Foreign/COM/Marshal/VTable.o )
[10 of 17] Compiling Foreign.COM.Marshal ( src/Foreign/COM/Marshal.hs, dist\buil
d/Foreign/COM/Marshal.o )
[11 of 17] Compiling Foreign.COM.GUID ( src/Foreign/COM/GUID.hs, dist\build/Fore
ign/COM/GUID.o )
[12 of 17] Compiling Foreign.COM.Client ( dist\build/Foreign/COM/Client.hs, dist
\build/Foreign/COM/Client.o )
[13 of 17] Compiling Foreign.COM.Server ( src/Foreign/COM/Server.hs, dist\build/
Foreign/COM/Server.o )
[14 of 17] Compiling Foreign.COM.Automation.IDispatch ( dist\build/Foreign/COM/A
utomation/IDispatch.hs, dist\build/Foreign/COM/Automation/IDispatch.o )
[15 of 17] Compiling Foreign.COM.Automation.Variant ( dist\build/Foreign/COM/Aut
omation/Variant.hs, dist\build/Foreign/COM/Automation/Variant.o )
[16 of 17] Compiling Foreign.COM.Automation ( src/Foreign/COM/Automation.hs, dis
t\build/Foreign/COM/Automation.o )
[17 of 17] Compiling Foreign.COM.ConnectionPoint ( dist\build/Foreign/COM/Connec
tionPoint.hs, dist\build/Foreign/COM/ConnectionPoint.o )
/usr/bin/ar: creating dist\build\libHShscom-0.1.a

C:\tools\haskell\hscom>setup install
Installing: C:\Program Files\Haskell\hscom-0.1\ghc-6.8.3
Registering hscom-0.1...
Reading package info from "dist\\installed-pkg-config" ... done.
Saving old package config file... done.
Writing new package config file... done.

Installing packages usually only takes a few steps but getting cabal to work would be much better (presuming that it takes care all dependencies of the package I am trying to install).

No comments:

Post a Comment