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.

  1. import System.Info

    • Imports the System.Info module, which provides system-related information.
  2. putStrLn ("Operating System: " ++ os)

    • Prints the name of the operating system using the os variable.
  3. putStrLn ("Architecture: " ++ arch)

    • Prints the system architecture (e.g., "x86_64" or "arm").
  4. putStrLn ("Compiler Name: " ++ compilerName)

    • Displays the name of the Haskell compiler used.
  5. 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 = []}