@@ -5,39 +5,50 @@ module Node.Platform where
5
5
import Prelude
6
6
import Data.Maybe (Maybe (..))
7
7
8
+ -- | See [the Node docs](https://nodejs.org/dist/latest-v6.x/docs/api/os.html#os_os_platform).
8
9
data Platform
9
- = Darwin
10
+ = AIX
11
+ | Darwin
10
12
| FreeBSD
11
- | OpenBSD
12
13
| Linux
14
+ | OpenBSD
13
15
| SunOS
14
16
| Win32
17
+ | Android
15
18
16
19
-- | The String representation for a platform, recognised by Node.js.
17
20
toString :: Platform -> String
21
+ toString AIX = " aix"
18
22
toString Darwin = " darwin"
19
23
toString FreeBSD = " freebsd"
20
- toString OpenBSD = " openbsd"
21
24
toString Linux = " linux"
25
+ toString OpenBSD = " openbsd"
22
26
toString SunOS = " sunos"
23
27
toString Win32 = " win32"
28
+ toString Android = " android"
24
29
30
+ -- | Attempt to parse a `Platform` value from a string, in the format returned
31
+ -- | by Node.js' `process.platform`.
25
32
fromString :: String -> Maybe Platform
33
+ fromString " aix" = Just AIX
26
34
fromString " darwin" = Just Darwin
27
35
fromString " freebsd" = Just FreeBSD
28
- fromString " openbsd" = Just OpenBSD
29
36
fromString " linux" = Just Linux
37
+ fromString " openbsd" = Just OpenBSD
30
38
fromString " sunos" = Just SunOS
31
39
fromString " win32" = Just Win32
40
+ fromString " android" = Just Android
32
41
fromString _ = Nothing
33
42
34
43
instance showPlatform :: Show Platform where
44
+ show AIX = " AIX"
35
45
show Darwin = " Darwin"
36
46
show FreeBSD = " FreeBSD"
37
- show OpenBSD = " OpenBSD"
38
47
show Linux = " Linux"
48
+ show OpenBSD = " OpenBSD"
39
49
show SunOS = " SunOS"
40
50
show Win32 = " Win32"
51
+ show Android = " Android"
41
52
42
53
derive instance eqPlatform :: Eq Platform
43
54
derive instance ordPlatform :: Ord Platform
0 commit comments