module Foundation.System.Info
(
OS(..)
, os
, Arch(..)
, arch
, cpus
, Endianness(..)
, endianness
, compilerName
, System.Info.compilerVersion
, Data.Version.Version(..)
) where
import qualified System.Info
import qualified Data.Version
import Data.Data
import qualified GHC.Conc
import Foundation.Internal.Base
import Foundation.Primitive.Endianness (Endianness(..), endianness)
import Foundation.String
data OS
= Windows
| OSX
| Linux
| Android
| BSD
deriving (Show, Eq, Ord, Enum, Bounded, Data, Typeable)
os :: Either [Char] OS
os = case System.Info.os of
"darwin" -> Right OSX
"mingw32" -> Right Windows
"linux" -> Right Linux
"linux-android" -> Right Android
"openbsd" -> Right BSD
"netbsd" -> Right BSD
"freebsd" -> Right BSD
str -> Left str
data Arch
= I386
| X86_64
| PowerPC
| PowerPC64
| Sparc
| Sparc64
| ARM
| ARM64
deriving (Show, Eq, Ord, Enum, Bounded, Data, Typeable)
arch :: Either [Char] Arch
arch = case System.Info.arch of
"i386" -> Right I386
"x86_64" -> Right X86_64
"powerpc" -> Right PowerPC
"powerpc64" -> Right PowerPC64
"powerpc64le" -> Right PowerPC64
"sparc" -> Right Sparc
"sparc64" -> Right Sparc64
"arm" -> Right ARM
"aarch64" -> Right ARM64
str -> Left str
compilerName :: String
compilerName = fromList System.Info.compilerName
cpus :: IO Int
cpus = GHC.Conc.getNumProcessors