Haskell Program to print system information
Program
import System.Info
main = do
putStrLn ("Operating System: " ++ os)
putStrLn ("Architecture: " ++ arch)
putStrLn ("Compiler Name: " ++ compilerName)
putStrLn ("Compiler Version: " ++ compilerVersion)
This Haskell program retrieves and displays system-related details such as the operating system, architecture, compiler name, and compiler version.
-
import System.Info
- Imports the
System.Info
module, which provides system-related information.
- Imports the
-
putStrLn ("Operating System: " ++ os)
- Prints the name of the operating system using the
os
variable.
- Prints the name of the operating system using the
-
putStrLn ("Architecture: " ++ arch)
- Prints the system architecture (e.g., "x86_64" or "arm").
-
putStrLn ("Compiler Name: " ++ compilerName)
- Displays the name of the Haskell compiler used.
-
putStrLn ("Compiler Version: " ++ compilerVersion)
- Displays the version of the Haskell compiler.
Key Takeaways
- The
System.Info
module provides system-related details. - The program prints OS, architecture, and compiler details using predefined variables (
os
,arch
,compilerName
,compilerVersion
). - Useful for debugging or gathering system configuration details.
Output
$ ghc print-system-info.hs
[1 of 1] Compiling Main ( print-system-info.hs, print-system-info.o )
Linking print-system-info ...
$ ./print-system-info
"linux"
"x86_64"
"ghc"
Version {versionBranch = [8,0], versionTags = []}