Skip to content
This repository was archived by the owner on Mar 22, 2021. It is now read-only.

Commit 23031dd

Browse files
committed
Export all fields and functions from Haskell module
1 parent 2a56275 commit 23031dd

1 file changed

Lines changed: 56 additions & 7 deletions

File tree

src/Foreign/Lua/Module/System.hs

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,30 @@ Portability : Requires GHC 8 or later.
88
99
Provide a Lua module containing a selection of @'System'@ functions.
1010
-}
11-
module Foreign.Lua.Module.System
12-
( pushModule
11+
module Foreign.Lua.Module.System (
12+
13+
-- * Module
14+
pushModule
1315
, preloadModule
16+
17+
-- * Fields
18+
, arch
19+
, compiler_name
20+
, compiler_version
21+
, os
22+
23+
-- * Functions
24+
, chdir
25+
, currentdir
26+
, env
27+
, getenv
28+
, ls
29+
, mkdir
30+
, rmdir
31+
, setenv
32+
, tmpdirname
33+
, with_env
34+
, with_tmpdir
1435
)
1536
where
1637

@@ -29,14 +50,18 @@ import qualified System.Environment as Env
2950
import qualified System.Info as Info
3051
import qualified System.IO.Temp as Temp
3152

53+
--
54+
-- Module
55+
--
56+
3257
-- | Pushes the @system@ module to the Lua stack.
3358
pushModule :: Lua NumResults
3459
pushModule = do
3560
Lua.newtable
36-
addField "arch" Info.arch
37-
addField "compiler_name" Info.compilerName
38-
addField "compiler_version" (versionBranch Info.compilerVersion)
39-
addField "os" Info.os
61+
addField "arch" arch
62+
addField "compiler_name" compiler_name
63+
addField "compiler_version" compiler_version
64+
addField "os" os
4065
addFunction "chdir" chdir
4166
addFunction "currentdir" currentdir
4267
addFunction "env" env
@@ -55,8 +80,32 @@ pushModule = do
5580
preloadModule :: String -> Lua ()
5681
preloadModule = flip addPackagePreloader pushModule
5782

83+
84+
--
85+
-- Fields
86+
--
87+
88+
-- | The machine architecture on which the program is running.
89+
arch :: String
90+
arch = Info.arch
91+
92+
-- | The Haskell implementation with which the host program was
93+
-- compiled.
94+
compiler_name :: String
95+
compiler_name = Info.compilerName
96+
97+
-- | The version of `compiler_name` with which the host program was
98+
-- compiled.
99+
compiler_version :: [Int]
100+
compiler_version = versionBranch Info.compilerVersion
101+
102+
-- | The operating system on which the program is running.
103+
os :: String
104+
os = Info.os
105+
106+
58107
--
59-
-- Module functions
108+
-- Functions
60109
--
61110

62111
-- | Change current working directory.

0 commit comments

Comments
 (0)