Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are possible values for the System.Info "os" function in Haskell?

What are possible values for the "os" function from the System.Info package in the Standard Libraries?

Also: Are these values reliable, are they portable across many compilers? Will Hugs on windows return the same value as ghc on windows?

Are there better ways for sniffing for the operating system?

like image 556
scravy Avatar asked Feb 18 '12 13:02

scravy


1 Answers

The variables for GHC are taken from the "autotools" tool suite, the tool suite that produces the well-known "configure" scripts that are almost always used when compiling something (./configure; make; make install). configure uses a standard "compiler identification string" like x86_64-unknown-linux-gnu for C compilers, and additionally computes a more detailed set of variables that identify the host platform. These variables are used in the generated Makefile of GHC, and this file further produces the ghcplatform.h file you see in the Info.hs file.

Almost the exact same procedure is used by HUGS to get the platform variables, except that the header file is named differently (as you are able to see in the source code that you linked).

Since both GHC and HUGS98 on Windows are compiled with MinGW and autotools as well, the variables are consistent on that platform.

like image 129
dflemstr Avatar answered Nov 15 '22 22:11

dflemstr