Skip to content

Commit 7b1bb66

Browse files
committed
Initial commit
0 parents  commit 7b1bb66

File tree

3 files changed

+152
-0
lines changed

3 files changed

+152
-0
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/bower_components/
2+
/node_modules/
3+
/.pulp-cache/
4+
/output/
5+
/.psci*
6+
/src/.webpack.js

bower.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "purescript-posix-types",
3+
"ignore": [
4+
"**/.*",
5+
"node_modules",
6+
"bower_components",
7+
"output"
8+
],
9+
"dependencies": {
10+
"purescript-console": "^0.1.0"
11+
}
12+
}

src/Data/Posix.purs

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
module Data.Posix where
2+
3+
import Prelude (Show, show, (<>))
4+
import Data.Function (on)
5+
6+
data Signal
7+
= SIGABRT
8+
| SIGALRM
9+
| SIGBUS
10+
| SIGCHLD
11+
| SIGCLD
12+
| SIGCONT
13+
| SIGEMT
14+
| SIGFPE
15+
| SIGHUP
16+
| SIGILL
17+
| SIGINFO
18+
| SIGINT
19+
| SIGIO
20+
| SIGIOT
21+
| SIGKILL
22+
| SIGLOST
23+
| SIGPIPE
24+
| SIGPOLL
25+
| SIGPROF
26+
| SIGPWR
27+
| SIGQUIT
28+
| SIGSEGV
29+
| SIGSTKFLT
30+
| SIGSTOP
31+
| SIGSYS
32+
| SIGTERM
33+
| SIGTRAP
34+
| SIGTSTP
35+
| SIGTTIN
36+
| SIGTTOU
37+
| SIGUNUSED
38+
| SIGURG
39+
| SIGUSR1
40+
| SIGUSR2
41+
| SIGVTALRM
42+
| SIGWINCH
43+
| SIGXCPU
44+
| SIGXFSZ
45+
46+
-- | Convert a Signal to a String. Suitable for Node.js APIs.
47+
toString :: Signal -> String
48+
toString s = case s of
49+
SIGABRT -> "SIGABRT"
50+
SIGALRM -> "SIGALRM"
51+
SIGBUS -> "SIGBUS"
52+
SIGCHLD -> "SIGCHLD"
53+
SIGCLD -> "SIGCLD"
54+
SIGCONT -> "SIGCONT"
55+
SIGEMT -> "SIGEMT"
56+
SIGFPE -> "SIGFPE"
57+
SIGHUP -> "SIGHUP"
58+
SIGILL -> "SIGILL"
59+
SIGINFO -> "SIGINFO"
60+
SIGINT -> "SIGINT"
61+
SIGIO -> "SIGIO"
62+
SIGIOT -> "SIGIOT"
63+
SIGKILL -> "SIGKILL"
64+
SIGLOST -> "SIGLOST"
65+
SIGPIPE -> "SIGPIPE"
66+
SIGPOLL -> "SIGPOLL"
67+
SIGPROF -> "SIGPROF"
68+
SIGPWR -> "SIGPWR"
69+
SIGQUIT -> "SIGQUIT"
70+
SIGSEGV -> "SIGSEGV"
71+
SIGSTKFLT -> "SIGSTKFLT"
72+
SIGSTOP -> "SIGSTOP"
73+
SIGSYS -> "SIGSYS"
74+
SIGTERM -> "SIGTERM"
75+
SIGTRAP -> "SIGTRAP"
76+
SIGTSTP -> "SIGTSTP"
77+
SIGTTIN -> "SIGTTIN"
78+
SIGTTOU -> "SIGTTOU"
79+
SIGUNUSED -> "SIGUNUSED"
80+
SIGURG -> "SIGURG"
81+
SIGUSR1 -> "SIGUSR1"
82+
SIGUSR2 -> "SIGUSR2"
83+
SIGVTALRM -> "SIGVTALRM"
84+
SIGWINCH -> "SIGWINCH"
85+
SIGXCPU -> "SIGXCPU"
86+
SIGXFSZ -> "SIGXFSZ"
87+
88+
instance showSignal :: Show Signal where
89+
show = toString
90+
91+
-- | A process ID.
92+
newtype Pid = Pid Int
93+
94+
runPid :: Pid -> Int
95+
runPid (Pid x) = x
96+
97+
instance showPid :: Show Pid where
98+
show (Pid pid) = "(Pid " <> show pid <> ")"
99+
100+
instance eqPid :: Eq Pid where
101+
eq = eq `on` runPid
102+
103+
instance ordPid :: Ord Pid where
104+
compare = compare `on` runPid
105+
106+
-- | A group ID (for a process or a file).
107+
newtype Gid = Gid Int
108+
109+
runGid :: Gid -> Int
110+
runGid (Gid x) = x
111+
112+
instance showGid :: Show Gid where
113+
show (Gid gid) = "(Gid " <> show gid <> ")"
114+
115+
instance eqGid :: Eq Gid where
116+
eq = eq `on` runGid
117+
118+
instance ordGid :: Ord Gid where
119+
compare = compare `on` runGid
120+
121+
-- | A user ID (for a process or a file).
122+
newtype Uid = Uid Int
123+
124+
runUid :: Uid -> Int
125+
runUid (Uid x) = x
126+
127+
instance showUid :: Show Uid where
128+
show (Uid uid) = "(Uid " <> show uid <> ")"
129+
130+
instance eqUid :: Eq Uid where
131+
eq = eq `on` runUid
132+
133+
instance ordUid :: Ord Uid where
134+
compare = compare `on` runUid

0 commit comments

Comments
 (0)