-- This program is contained in the Cpuid documentation.
module Main(main) where

import Text.Printf (printf, )
import System.Cpuid

main :: IO ()
main = do
   (a, b, c, d) <- cpuid 0
   _ <- printf "Basic CPUID usage: EAX=0: %8x %8x %8x %8x\n\n" a b c d
   _ <- printf "Vendor string: %s\n\n" =<< vendorString
   _ <- printf "Brand string: %s\n\n" =<< brandString
   putStrLn "Cache information:"
   putStrLn . unlines .
      map (\ v -> "  " ++ show v) =<< cacheInfo
   p <- processorInfo
   _ <- printf "Processor info: family: %d, model: %d, stepping: %d, processor type: %d\n"
      (piFamily p) (piModel p) (piStepping p) (piType p)
   putStrLn "Features:"
   (fc,fd) <- features
   let showFeatures flags =
          putStrLn $ concatMap (\f -> " " ++ show f) $
             filter (flip testFlag flags) [minBound..maxBound]
   showFeatures fd
   showFeatures fc
