ref: 8550d88e9a32963637f0e15becb6ec4ed13fdba6
parent: 6b32e94435ebd8897740983cd1bfef7fd8fa5f42
author: Lennart Augustsson <lennart.augustsson@epicgames.com>
date: Sun Mar 10 18:09:13 EDT 2024
Add Data.Version and System.Info
--- /dev/null
+++ b/lib/Data/Version.hs
@@ -1,0 +1,19 @@
+module Data.Version(
+ Version(..),
+ showVersion,
+ makeVersion
+ ) where
+
+data Version = Version { versionBranch :: [Int] }+ deriving (Show, Eq, Ord)
+
+showVersion :: Version -> String
+showVersion (Version b) = intercalate "." (map show b)
+
+{-+parseVersion :: ReadP Version
+parseVersion = do branch <- sepBy1 (fmap read (munch1 isDigit)) (char '.')
+ pure Version{versionBranch=branch}+-}
+makeVersion :: [Int] -> Version
+makeVersion b = Version b
--- /dev/null
+++ b/lib/System/Info.hs
@@ -1,0 +1,32 @@
+module System.Info(os, arch, compilerName, compilerVersion, fullCompilerVersion) where
+import Data.Char
+import Data.Version(Version(..))
+import System.Directory
+import System.IO
+import System.Process
+import System.IO.Unsafe
+
+os :: String
+os = if _isWindows then "windows" else uname "-s"
+
+arch :: String
+arch = if _isWindows then "x86_64" else uname "-m"
+
+compilerName :: String
+compilerName = "mhs"
+
+compilerVersion :: Version
+compilerVersion = Version [0,9]
+
+fullCompilerVersion :: Version
+fullCompilerVersion = Version [0,9,0]
+
+-- Assume the system has an uname command
+uname :: String -> String
+uname flag = unsafePerformIO $ do
+ (fn, h) <- openTmpFile "uname"
+ hClose h
+ callCommand $ "uname " ++ flag ++ " >" ++ fn
+ res <- readFile fn
+ removeFile fn
+ return $ map toLower $ filter (not . isSpace) res
--
⑨