[nhc-bugs] How to make System Calls in NHC98?

Malcolm Wallace Malcolm.Wallace@cs.york.ac.uk
Thu, 2 Jan 2003 14:21:06 +0000


Alberto <albertodg@terra.es> writes:

> Hi :) ,  I am creating a tiny app in Haskell to search for a directory 
> in the tree and change the current shell directory just to learn to 
> program better in Haskell and I've always used the Win/Hugs98 
> interpreter but I've just moved to FreeBSD/NHC98 because I want binary 
> code and the thing is I can't find a function in NHC98 to make a pipe to
> comunicate with the shell (csh in my case) and that's the question: are 
> the FreeBSD pipes functionality available in NHC98? By the way, can one 
> make arbitrary System Calls in NHC98 by any means? if no, how can I 
> change the shell's current directory?

The standard Directory library
    http://www.haskell.org/onlinelibrary/directory.html
probably has all the functions you require.  It does not include
pipes, but perhaps you don't really need them.

To make arbitrary system calls, you can use the standard Foreign
Function Interface (FFI)
    http://www.cse.unsw.edu.au/~chak/haskell/ffi/
Any function from C can be "foreign import"ed into Haskell land,
provided there is a method defined to convert values from one
language's representation to the other (to "marshal" them).  All the
basic types already have marshalling functions, and it is relatively
easy to write new marshalling code for more complex structs and so on.

Regards,
    Malcolm