
Hi Bill,
I am really talking about a module or perhaps a Haskell class that provides notion for multiple threads of execution, semaphores, .. that "hides" POSIX vs Win32 APIs .. i.e. the underlying OS APIs would be
totally
hidden.
I think you are thinking in a "C" way. In Haskell, portable is the default. If you want to stop your code being portable, you have to go
^^ how? If I define something like "class OS where ...." and define a POSIX instance of "class OS" and a Win32 API instance.. function calls will be to the instances and hence the OS APIs are visible. Yes?
OK, I think I'm slowly figuring out what you are meaning. You want to write some code which runs on POSIX, and some which runs on Win32, each of which bind to some foreign library which is different on both operating systems. The key thing to note about this is that whether a program is running on Windows or Posix is fixed at compile time. Things like classes can do some of what you seem to be after, but it tends to be easier to reach for the C pre processor. Let's take a simple login scenario. In Linux you enter the user name using the call getLine, and in Windows you call something else like getInputString. The way I would structure this would be: getUserName :: IO String #ifdef WINDOWS getUserName = getInputString #else getUserName = getLine #endif (Note - it wouldn't be WINDOWS - I can't remember what the blessed CPP for distinguishing Windows and Posix is) Then your logic code can call getUserName, and the platform differences are papered over. You could use classes, but for something which is OS dependent, I'd tend to use the CPP. Thanks Neil