Library proposal: Add System.Info.isWindows

Neil Mitchell ndmitchell at gmail.com
Mon Aug 6 08:36:54 EDT 2007


Hi

> important question - what it should return on cygwin (and
> win32-emulating environments on unix if such ones exist)

Very good question. I guess we should return the host operating system
- i.e. Windows on Windows, and Unix on Unix. The emulation is
generally for programs that aren't cross compatible, if you've taken
the time to figure out what OS you are really on, you can probably be
compatible to it.

> How about something slightly more general but still not quite so free
> form as the current System.Info.os :: String.
>
> Ian just added something to Cabal for it's own internal use to clean up
> the use of os-specific #cppery and use of System.Info.os which seems
> reasonable to me:
>
> data OS = Linux | Windows Windows | ... etc | Other String
> data Windows = MingW

Since when did GNU build Windows operating systems? You can add
System.Info.libraries :: [Libary], and make MingW a library, but if
you have a Windows enumeration it really should be for a list of
Windows operating systems.

> So it's easy to pattern match on it and it gives us the ability to be
> more or less specific. For example in the windows case we could
> distinguish the environment, native vs mingw vs cygwin.

> That generalises isWindows and means we don't need isLinux, isOSX etc
> etc. Or if people really want those they can define them in terms of the
> above.

I still propose isWindows. Checking "is this operating system windows"
is the most common thing to do with System.Info.os, so should be
easily accessible and foolproof. I would be perfectly happy to have
something else as well, and implement isWindows on top of it.

> While we're at it, discussing System.Info I think there are several more
> useful things we could add there, like exeExtension and probably several
> more. I seem to recall someone proposed a reasonable list on this
> mailing list some time ago, not just obj and dllExtension but a slightly
> wider rang of things. I can't seem to find it right now, does anyone
> else remember?

I believe Dimitry proposed them about 3 weeks ago.

There are lots of things that could go in System.Info, and I agree
more should be moved along.

Thanks

Neil


More information about the Libraries mailing list