Hugs98 for .NET

What is it?

Hugs98 for .NET is an extension of the Hugs98 Haskell interpreter, providing good interoperation between the world of Haskell and the world of .NET and the .NET Framework.

The Hugs98 interpreter has been extended with features which lets you instantiate and use .NET objects from within Haskell, and vice versa, allows you to call and use Haskell functions from any .NET language.

The motivation behind this work is entirely pragmatic -- I want to be able to use a great language on an important, new platform laden with many great features and libraries. In contrast with other attempts at integrating functional languages with the .NET platform, Hugs98 for .NET takes a hands-off approach, providing 'just' the ability to interoperate well with .NET. That is, it does not try to compile Haskell into .NET's IL and have the .NET run-time execute it. Instead the Hugs98 interpreter operates side-by-side with the .NET run-time, providing code in either world with just the ability to call code in the other.

Example

To give a flavour of what's possible with Hugs98 for .NET, here's how to fetch a URL into a Haskell String:
-- dotnet/examples/basic/Http.hs 
module Main where

import Dotnet

foreign import dotnet
  "static System.Net.WebRequest.Create"
  createURL :: String -> IO (Object ())

fetchURL :: String -> IO String
fetchURL url = do
  req <- createURL url
  when (isNullObj req)
       (ioError (userError ("Unable to fetch " ++ show url)))
  rsp <- req # invoke "GetResponse" ()
  str <- rsp # invoke "GetResponseStream" ()
  str # slurpString
See the documentation and the distribution, which contains this example and many others, for details of what this code is doing.

Download

A Windows Installer containing Hugs98 and the .NET extensions is available via http. To use it, you only need to have the .NET Framework installed on your machine (i.e., no need for Visual Studio .NET).

Sources are available via CVS.

Documentation

For documentation on Haskell, see haskell.org.

The distribution includes documentation on how to interop with the .NET platform, but is also available in on-line form:

Authors

Info on authors and maintainers of Hugs98 can be found via its homepage.

The .NET extensions are by Sigbjorn Finne, with initial encouragement from Erik Meijer.

Copyright and License

The Hugs 98 system is Copyright © Mark P Jones, Alastair Reid, the Yale Haskell Group, and the Oregon Graduate Institute of Science and Technology, 1994-2003, All rights reserved. It is distributed as free software under the license in the file "License", which is included in the distribution.

The .NET extensions are Copyright Sigbjorn Finne, 2002-2003, All rights reserved. It is distributed as free software under the same license as the Hugs98 interpreter (see the file "License.net" included with the distribution.)


Last modified: Wed Mar 12 21:17:05 Pacific Standard Time 2003