Idris2/libs/base/System/Info.idr

26 lines
510 B
Idris
Raw Normal View History

2020-05-18 15:59:07 +03:00
module System.Info
%extern prim__os : String
%extern prim__codegen : String
export
os : String
os = prim__os
export
codegen : String
codegen = prim__codegen
2020-05-26 12:59:14 +03:00
export
isWindows : Bool
2020-05-26 21:56:16 +03:00
isWindows = os `elem` ["windows", "mingw32", "cygwin32"]
2021-04-23 13:09:31 +03:00
%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)))