Idris2/libs/base/System/Info.idr
2021-06-12 21:06:08 -05:00

28 lines
526 B
Idris

module System.Info
%default total
%extern prim__os : String
%extern prim__codegen : String
export
os : String
os = prim__os
export
codegen : String
codegen = prim__codegen
export
isWindows : Bool
isWindows = os `elem` ["windows", "mingw32", "cygwin32"]
%foreign "C:idris2_getNProcessors, libidris2_support, idris_support.h"
prim__getNProcessors : PrimIO Int
export
getNProcessors : IO (Maybe Nat)
getNProcessors = do
i <- fromPrim prim__getNProcessors
pure (if i < 0 then Nothing else Just (integerToNat (cast i)))