-- |
-- Module      : Foundation.System.Info
-- License     : BSD-style
-- Maintainer  : foundation
-- Stability   : experimental
-- Portability : portable
--

{-# LANGUAGE CPP #-}

module Foundation.System.Info
    (
      -- * Operation System info
      OS(..)
    , os
      -- * CPU info
    , Arch(..)
    , arch
    , cpus
    , Endianness(..)
    , endianness
      -- * Compiler info
    , compilerName
    , System.Info.compilerVersion
    , Data.Version.Version(..)
    ) where

import qualified System.Info
import qualified Data.Version
import           Data.Data
import qualified GHC.Conc
import           Basement.Compat.Base
import           Basement.Endianness (Endianness(..), endianness)
import           Foundation.String

data OS
    = Windows
    | OSX
    | Linux
    | Android
    | BSD
  deriving (Int -> OS -> ShowS
[OS] -> ShowS
OS -> String
(Int -> OS -> ShowS)
-> (OS -> String) -> ([OS] -> ShowS) -> Show OS
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OS] -> ShowS
$cshowList :: [OS] -> ShowS
show :: OS -> String
$cshow :: OS -> String
showsPrec :: Int -> OS -> ShowS
$cshowsPrec :: Int -> OS -> ShowS
Show, OS -> OS -> Bool
(OS -> OS -> Bool) -> (OS -> OS -> Bool) -> Eq OS
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OS -> OS -> Bool
$c/= :: OS -> OS -> Bool
== :: OS -> OS -> Bool
$c== :: OS -> OS -> Bool
Eq, Eq OS
Eq OS
-> (OS -> OS -> Ordering)
-> (OS -> OS -> Bool)
-> (OS -> OS -> Bool)
-> (OS -> OS -> Bool)
-> (OS -> OS -> Bool)
-> (OS -> OS -> OS)
-> (OS -> OS -> OS)
-> Ord OS
OS -> OS -> Bool
OS -> OS -> Ordering
OS -> OS -> OS
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: OS -> OS -> OS
$cmin :: OS -> OS -> OS
max :: OS -> OS -> OS
$cmax :: OS -> OS -> OS
>= :: OS -> OS -> Bool
$c>= :: OS -> OS -> Bool
> :: OS -> OS -> Bool
$c> :: OS -> OS -> Bool
<= :: OS -> OS -> Bool
$c<= :: OS -> OS -> Bool
< :: OS -> OS -> Bool
$c< :: OS -> OS -> Bool
compare :: OS -> OS -> Ordering
$ccompare :: OS -> OS -> Ordering
$cp1Ord :: Eq OS
Ord, Int -> OS
OS -> Int
OS -> [OS]
OS -> OS
OS -> OS -> [OS]
OS -> OS -> OS -> [OS]
(OS -> OS)
-> (OS -> OS)
-> (Int -> OS)
-> (OS -> Int)
-> (OS -> [OS])
-> (OS -> OS -> [OS])
-> (OS -> OS -> [OS])
-> (OS -> OS -> OS -> [OS])
-> Enum OS
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: OS -> OS -> OS -> [OS]
$cenumFromThenTo :: OS -> OS -> OS -> [OS]
enumFromTo :: OS -> OS -> [OS]
$cenumFromTo :: OS -> OS -> [OS]
enumFromThen :: OS -> OS -> [OS]
$cenumFromThen :: OS -> OS -> [OS]
enumFrom :: OS -> [OS]
$cenumFrom :: OS -> [OS]
fromEnum :: OS -> Int
$cfromEnum :: OS -> Int
toEnum :: Int -> OS
$ctoEnum :: Int -> OS
pred :: OS -> OS
$cpred :: OS -> OS
succ :: OS -> OS
$csucc :: OS -> OS
Enum, OS
OS -> OS -> Bounded OS
forall a. a -> a -> Bounded a
maxBound :: OS
$cmaxBound :: OS
minBound :: OS
$cminBound :: OS
Bounded, Typeable OS
DataType
Constr
Typeable OS
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> OS -> c OS)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c OS)
-> (OS -> Constr)
-> (OS -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c OS))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c OS))
-> ((forall b. Data b => b -> b) -> OS -> OS)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> OS -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> OS -> r)
-> (forall u. (forall d. Data d => d -> u) -> OS -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> OS -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> OS -> m OS)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> OS -> m OS)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> OS -> m OS)
-> Data OS
OS -> DataType
OS -> Constr
(forall b. Data b => b -> b) -> OS -> OS
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> OS -> c OS
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c OS
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> OS -> u
forall u. (forall d. Data d => d -> u) -> OS -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> OS -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> OS -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> OS -> m OS
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> OS -> m OS
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c OS
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> OS -> c OS
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c OS)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c OS)
$cBSD :: Constr
$cAndroid :: Constr
$cLinux :: Constr
$cOSX :: Constr
$cWindows :: Constr
$tOS :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> OS -> m OS
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> OS -> m OS
gmapMp :: (forall d. Data d => d -> m d) -> OS -> m OS
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> OS -> m OS
gmapM :: (forall d. Data d => d -> m d) -> OS -> m OS
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> OS -> m OS
gmapQi :: Int -> (forall d. Data d => d -> u) -> OS -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> OS -> u
gmapQ :: (forall d. Data d => d -> u) -> OS -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> OS -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> OS -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> OS -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> OS -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> OS -> r
gmapT :: (forall b. Data b => b -> b) -> OS -> OS
$cgmapT :: (forall b. Data b => b -> b) -> OS -> OS
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c OS)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c OS)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c OS)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c OS)
dataTypeOf :: OS -> DataType
$cdataTypeOf :: OS -> DataType
toConstr :: OS -> Constr
$ctoConstr :: OS -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c OS
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c OS
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> OS -> c OS
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> OS -> c OS
$cp1Data :: Typeable OS
Data, Typeable)

-- | get the operating system on which the program is running.
--
-- Either return the known `OS` or a strict `String` of the OS name.
--
-- This function uses the `base`'s `System.Info.os` function.
--
os :: Either [Char] OS
os :: Either String OS
os = case String
System.Info.os of
    String
"darwin"  -> OS -> Either String OS
forall a b. b -> Either a b
Right OS
OSX
    String
"mingw32" -> OS -> Either String OS
forall a b. b -> Either a b
Right OS
Windows
    String
"linux"   -> OS -> Either String OS
forall a b. b -> Either a b
Right OS
Linux
    String
"linux-android" -> OS -> Either String OS
forall a b. b -> Either a b
Right OS
Android
    String
"openbsd" -> OS -> Either String OS
forall a b. b -> Either a b
Right OS
BSD
    String
"netbsd"  -> OS -> Either String OS
forall a b. b -> Either a b
Right OS
BSD
    String
"freebsd" -> OS -> Either String OS
forall a b. b -> Either a b
Right OS
BSD
    String
str       -> String -> Either String OS
forall a b. a -> Either a b
Left String
str

-- | Enumeration of the known GHC supported architecture.
--
data Arch
    = I386
    | X86_64
    | PowerPC
    | PowerPC64
    | Sparc
    | Sparc64
    | ARM
    | ARM64
  deriving (Int -> Arch -> ShowS
[Arch] -> ShowS
Arch -> String
(Int -> Arch -> ShowS)
-> (Arch -> String) -> ([Arch] -> ShowS) -> Show Arch
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Arch] -> ShowS
$cshowList :: [Arch] -> ShowS
show :: Arch -> String
$cshow :: Arch -> String
showsPrec :: Int -> Arch -> ShowS
$cshowsPrec :: Int -> Arch -> ShowS
Show, Arch -> Arch -> Bool
(Arch -> Arch -> Bool) -> (Arch -> Arch -> Bool) -> Eq Arch
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Arch -> Arch -> Bool
$c/= :: Arch -> Arch -> Bool
== :: Arch -> Arch -> Bool
$c== :: Arch -> Arch -> Bool
Eq, Eq Arch
Eq Arch
-> (Arch -> Arch -> Ordering)
-> (Arch -> Arch -> Bool)
-> (Arch -> Arch -> Bool)
-> (Arch -> Arch -> Bool)
-> (Arch -> Arch -> Bool)
-> (Arch -> Arch -> Arch)
-> (Arch -> Arch -> Arch)
-> Ord Arch
Arch -> Arch -> Bool
Arch -> Arch -> Ordering
Arch -> Arch -> Arch
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Arch -> Arch -> Arch
$cmin :: Arch -> Arch -> Arch
max :: Arch -> Arch -> Arch
$cmax :: Arch -> Arch -> Arch
>= :: Arch -> Arch -> Bool
$c>= :: Arch -> Arch -> Bool
> :: Arch -> Arch -> Bool
$c> :: Arch -> Arch -> Bool
<= :: Arch -> Arch -> Bool
$c<= :: Arch -> Arch -> Bool
< :: Arch -> Arch -> Bool
$c< :: Arch -> Arch -> Bool
compare :: Arch -> Arch -> Ordering
$ccompare :: Arch -> Arch -> Ordering
$cp1Ord :: Eq Arch
Ord, Int -> Arch
Arch -> Int
Arch -> [Arch]
Arch -> Arch
Arch -> Arch -> [Arch]
Arch -> Arch -> Arch -> [Arch]
(Arch -> Arch)
-> (Arch -> Arch)
-> (Int -> Arch)
-> (Arch -> Int)
-> (Arch -> [Arch])
-> (Arch -> Arch -> [Arch])
-> (Arch -> Arch -> [Arch])
-> (Arch -> Arch -> Arch -> [Arch])
-> Enum Arch
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: Arch -> Arch -> Arch -> [Arch]
$cenumFromThenTo :: Arch -> Arch -> Arch -> [Arch]
enumFromTo :: Arch -> Arch -> [Arch]
$cenumFromTo :: Arch -> Arch -> [Arch]
enumFromThen :: Arch -> Arch -> [Arch]
$cenumFromThen :: Arch -> Arch -> [Arch]
enumFrom :: Arch -> [Arch]
$cenumFrom :: Arch -> [Arch]
fromEnum :: Arch -> Int
$cfromEnum :: Arch -> Int
toEnum :: Int -> Arch
$ctoEnum :: Int -> Arch
pred :: Arch -> Arch
$cpred :: Arch -> Arch
succ :: Arch -> Arch
$csucc :: Arch -> Arch
Enum, Arch
Arch -> Arch -> Bounded Arch
forall a. a -> a -> Bounded a
maxBound :: Arch
$cmaxBound :: Arch
minBound :: Arch
$cminBound :: Arch
Bounded, Typeable Arch
DataType
Constr
Typeable Arch
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> Arch -> c Arch)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c Arch)
-> (Arch -> Constr)
-> (Arch -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c Arch))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Arch))
-> ((forall b. Data b => b -> b) -> Arch -> Arch)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Arch -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Arch -> r)
-> (forall u. (forall d. Data d => d -> u) -> Arch -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> Arch -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> Arch -> m Arch)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Arch -> m Arch)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> Arch -> m Arch)
-> Data Arch
Arch -> DataType
Arch -> Constr
(forall b. Data b => b -> b) -> Arch -> Arch
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Arch -> c Arch
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Arch
forall a.
Typeable a
-> (forall (c :: * -> *).
    (forall d b. Data d => c (d -> b) -> d -> c b)
    -> (forall g. g -> c g) -> a -> c a)
-> (forall (c :: * -> *).
    (forall b r. Data b => c (b -> r) -> c r)
    -> (forall r. r -> c r) -> Constr -> c a)
-> (a -> Constr)
-> (a -> DataType)
-> (forall (t :: * -> *) (c :: * -> *).
    Typeable t =>
    (forall d. Data d => c (t d)) -> Maybe (c a))
-> (forall (t :: * -> * -> *) (c :: * -> *).
    Typeable t =>
    (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c a))
-> ((forall b. Data b => b -> b) -> a -> a)
-> (forall r r'.
    (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall r r'.
    (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> a -> r)
-> (forall u. (forall d. Data d => d -> u) -> a -> [u])
-> (forall u. Int -> (forall d. Data d => d -> u) -> a -> u)
-> (forall (m :: * -> *).
    Monad m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> (forall (m :: * -> *).
    MonadPlus m =>
    (forall d. Data d => d -> m d) -> a -> m a)
-> Data a
forall u. Int -> (forall d. Data d => d -> u) -> Arch -> u
forall u. (forall d. Data d => d -> u) -> Arch -> [u]
forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Arch -> r
forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Arch -> r
forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Arch -> m Arch
forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Arch -> m Arch
forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Arch
forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Arch -> c Arch
forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Arch)
forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Arch)
$cARM64 :: Constr
$cARM :: Constr
$cSparc64 :: Constr
$cSparc :: Constr
$cPowerPC64 :: Constr
$cPowerPC :: Constr
$cX86_64 :: Constr
$cI386 :: Constr
$tArch :: DataType
gmapMo :: (forall d. Data d => d -> m d) -> Arch -> m Arch
$cgmapMo :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Arch -> m Arch
gmapMp :: (forall d. Data d => d -> m d) -> Arch -> m Arch
$cgmapMp :: forall (m :: * -> *).
MonadPlus m =>
(forall d. Data d => d -> m d) -> Arch -> m Arch
gmapM :: (forall d. Data d => d -> m d) -> Arch -> m Arch
$cgmapM :: forall (m :: * -> *).
Monad m =>
(forall d. Data d => d -> m d) -> Arch -> m Arch
gmapQi :: Int -> (forall d. Data d => d -> u) -> Arch -> u
$cgmapQi :: forall u. Int -> (forall d. Data d => d -> u) -> Arch -> u
gmapQ :: (forall d. Data d => d -> u) -> Arch -> [u]
$cgmapQ :: forall u. (forall d. Data d => d -> u) -> Arch -> [u]
gmapQr :: (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Arch -> r
$cgmapQr :: forall r r'.
(r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Arch -> r
gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Arch -> r
$cgmapQl :: forall r r'.
(r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Arch -> r
gmapT :: (forall b. Data b => b -> b) -> Arch -> Arch
$cgmapT :: (forall b. Data b => b -> b) -> Arch -> Arch
dataCast2 :: (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Arch)
$cdataCast2 :: forall (t :: * -> * -> *) (c :: * -> *).
Typeable t =>
(forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Arch)
dataCast1 :: (forall d. Data d => c (t d)) -> Maybe (c Arch)
$cdataCast1 :: forall (t :: * -> *) (c :: * -> *).
Typeable t =>
(forall d. Data d => c (t d)) -> Maybe (c Arch)
dataTypeOf :: Arch -> DataType
$cdataTypeOf :: Arch -> DataType
toConstr :: Arch -> Constr
$ctoConstr :: Arch -> Constr
gunfold :: (forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Arch
$cgunfold :: forall (c :: * -> *).
(forall b r. Data b => c (b -> r) -> c r)
-> (forall r. r -> c r) -> Constr -> c Arch
gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Arch -> c Arch
$cgfoldl :: forall (c :: * -> *).
(forall d b. Data d => c (d -> b) -> d -> c b)
-> (forall g. g -> c g) -> Arch -> c Arch
$cp1Data :: Typeable Arch
Data, Typeable)

-- | get the machine architecture on which the program is running
--
-- Either return the known architecture or a Strict `String` of the
-- architecture name.
--
-- This function uses the `base`'s `System.Info.arch` function.
--
arch :: Either [Char] Arch
arch :: Either String Arch
arch = case String
System.Info.arch of
    String
"i386"          -> Arch -> Either String Arch
forall a b. b -> Either a b
Right Arch
I386
    String
"x86_64"        -> Arch -> Either String Arch
forall a b. b -> Either a b
Right Arch
X86_64
    String
"powerpc"       -> Arch -> Either String Arch
forall a b. b -> Either a b
Right Arch
PowerPC
    String
"powerpc64"     -> Arch -> Either String Arch
forall a b. b -> Either a b
Right Arch
PowerPC64
    String
"powerpc64le"   -> Arch -> Either String Arch
forall a b. b -> Either a b
Right Arch
PowerPC64
    String
"sparc"         -> Arch -> Either String Arch
forall a b. b -> Either a b
Right Arch
Sparc
    String
"sparc64"       -> Arch -> Either String Arch
forall a b. b -> Either a b
Right Arch
Sparc64
    String
"arm"           -> Arch -> Either String Arch
forall a b. b -> Either a b
Right Arch
ARM
    String
"aarch64"       -> Arch -> Either String Arch
forall a b. b -> Either a b
Right Arch
ARM64
    String
str             -> String -> Either String Arch
forall a b. a -> Either a b
Left String
str

-- | get the compiler name
--
-- get the compilerName from base package but convert
-- it into a strict String
compilerName :: String
compilerName :: String
compilerName = [Item String] -> String
forall l. IsList l => [Item l] -> l
fromList String
[Item String]
System.Info.compilerName

-- | returns the number of CPUs the machine has
cpus :: IO Int
cpus :: IO Int
cpus = IO Int
GHC.Conc.getNumProcessors