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.
-- 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 # slurpStringSee the documentation and the distribution, which contains this example and many others, for details of what this code is doing.
Sources are available via CVS.
The distribution includes documentation on how to interop with the .NET platform, but is also available in on-line form:
The .NET extensions are by Sigbjorn Finne, with initial encouragement from Erik Meijer.
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.)