Library proposal: Add System.Info.isWindows

John Meacham john at repetae.net
Thu Aug 9 20:57:45 EDT 2007


On Tue, Aug 07, 2007 at 01:04:59PM +0100, Ian Lynagh wrote:
> On Mon, Aug 06, 2007 at 01:36:54PM +0100, Neil Mitchell wrote:
> I was actually planning to propose something along similar lines this
> week, in order to replace ifdef's like in the GHC and library sources with
> pattern matches like I have done in Cabal, e.g.:
> 
> -#if mingw32_HOST_OS || mingw32_TARGET_OS
> -dllExtension = "dll"
> -#else
> -dllExtension = "so"
> -#endif
> 
> +dllExtension = case os of
> +                   Windows _ -> "dll"
> +                   _         -> "so"

Yes, removing ifdefs like this is very important to compilers such as
jhc that produce portable C code, it is very unlikely the answers to
these questions are available at compile time. especially when bundling
a library for distribution.

I would also like to see nativeWordSize and nativePointerSize fields of
type Int. sizeof (undefined :: CInt) and sizeof (undefined :: Ptr a)
sort of work... but are rather convoluted for such a common thing that
needs to be queried.

for targeted compilers such as ghc, these will be compile time constants
so will optimize away, for ones such as jhc, the actual determination of
the values may be defered.

        John


-- 
John Meacham - ⑆repetae.net⑆john⑈


More information about the Libraries mailing list