{-# LANGUAGE CPP #-}
{-# LANGUAGE Safe #-}
module System.Info
( os
, arch
, compilerName
, compilerVersion
, fullCompilerVersion
) where
import Data.Version (Version (..))
compilerVersion :: Version
compilerVersion :: Version
compilerVersion = [Int] -> [String] -> Version
Version [Int
major, Int
minor] []
where (Int
major, Int
minor) = Int
compilerVersionRaw Int -> Int -> (Int, Int)
forall a. Integral a => a -> a -> (a, a)
`divMod` Int
100
fullCompilerVersion :: Version
fullCompilerVersion :: Version
fullCompilerVersion = [Int] -> [String] -> Version
Version [Int]
version []
where
version :: [Int]
version :: [Int]
version = (String -> Int) -> [String] -> [Int]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> Int
forall a. Read a => String -> a
read ([String] -> [Int]) -> [String] -> [Int]
forall a b. (a -> b) -> a -> b
$ String -> [String]
splitVersion __GLASGOW_HASKELL_FULL_VERSION__
splitVersion :: String -> [String]
splitVersion :: String -> [String]
splitVersion String
s =
case (Char -> Bool) -> String -> String
forall a. (a -> Bool) -> [a] -> [a]
dropWhile (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'.') String
s of
String
"" -> []
String
s' -> let (String
w, String
s'') = (Char -> Bool) -> String -> (String, String)
forall a. (a -> Bool) -> [a] -> ([a], [a])
break (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'.') String
s'
in String
w String -> [String] -> [String]
forall a. a -> [a] -> [a]
: String -> [String]
splitVersion String
s''
#include "ghcplatform.h"
os :: String
os :: String
os = String
HOST_OS
arch :: String
arch :: String
arch = HOST_ARCH
compilerName :: String
compilerName :: String
compilerName = String
"ghc"
compilerVersionRaw :: Int
compilerVersionRaw :: Int
compilerVersionRaw = __GLASGOW_HASKELL__