|
1 | 1 | module Data.Posix where |
2 | 2 |
|
3 | | -import Prelude (class Show, show, (<>), class Ord, compare, class Eq, eq) |
4 | | -import Data.Function (on) |
| 3 | +import Prelude |
| 4 | +import Data.Newtype (class Newtype) |
5 | 5 |
|
6 | 6 | -- | A process ID. |
7 | 7 | newtype Pid = Pid Int |
8 | 8 |
|
9 | | -runPid :: Pid -> Int |
10 | | -runPid (Pid x) = x |
| 9 | +derive instance newtypePid :: Newtype Pid _ |
| 10 | +derive newtype instance eqPid :: Eq Pid |
| 11 | +derive newtype instance ordPid :: Ord Pid |
11 | 12 |
|
12 | 13 | instance showPid :: Show Pid where |
13 | 14 | show (Pid pid) = "(Pid " <> show pid <> ")" |
14 | 15 |
|
15 | | -instance eqPid :: Eq Pid where |
16 | | - eq = eq `on` runPid |
17 | | - |
18 | | -instance ordPid :: Ord Pid where |
19 | | - compare = compare `on` runPid |
20 | | - |
21 | 16 | -- | A group ID (for a process or a file). |
22 | 17 | newtype Gid = Gid Int |
23 | 18 |
|
24 | | -runGid :: Gid -> Int |
25 | | -runGid (Gid x) = x |
| 19 | +derive instance newtypeGid :: Newtype Gid _ |
| 20 | +derive newtype instance eqGid :: Eq Gid |
| 21 | +derive newtype instance ordGid :: Ord Gid |
26 | 22 |
|
27 | 23 | instance showGid :: Show Gid where |
28 | 24 | show (Gid gid) = "(Gid " <> show gid <> ")" |
29 | 25 |
|
30 | | -instance eqGid :: Eq Gid where |
31 | | - eq = eq `on` runGid |
32 | | - |
33 | | -instance ordGid :: Ord Gid where |
34 | | - compare = compare `on` runGid |
35 | | - |
36 | 26 | -- | A user ID (for a process or a file). |
37 | 27 | newtype Uid = Uid Int |
38 | 28 |
|
39 | | -runUid :: Uid -> Int |
40 | | -runUid (Uid x) = x |
| 29 | +derive instance newtypeUid :: Newtype Uid _ |
| 30 | +derive newtype instance eqUid :: Eq Uid |
| 31 | +derive newtype instance ordUid :: Ord Uid |
41 | 32 |
|
42 | 33 | instance showUid :: Show Uid where |
43 | 34 | show (Uid uid) = "(Uid " <> show uid <> ")" |
44 | | - |
45 | | -instance eqUid :: Eq Uid where |
46 | | - eq = eq `on` runUid |
47 | | - |
48 | | -instance ordUid :: Ord Uid where |
49 | | - compare = compare `on` runUid |
0 commit comments