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