@@ -5,39 +5,50 @@ module Node.Platform where
55import Prelude
66import Data.Maybe (Maybe (..))
77
8+ -- | See [the Node docs](https://nodejs.org/dist/latest-v6.x/docs/api/os.html#os_os_platform).
89data Platform
9- = Darwin
10+ = AIX
11+ | Darwin
1012 | FreeBSD
11- | OpenBSD
1213 | Linux
14+ | OpenBSD
1315 | SunOS
1416 | Win32
17+ | Android
1518
1619-- | The String representation for a platform, recognised by Node.js.
1720toString :: Platform -> String
21+ toString AIX = " aix"
1822toString Darwin = " darwin"
1923toString FreeBSD = " freebsd"
20- toString OpenBSD = " openbsd"
2124toString Linux = " linux"
25+ toString OpenBSD = " openbsd"
2226toString SunOS = " sunos"
2327toString Win32 = " win32"
28+ toString Android = " android"
2429
30+ -- | Attempt to parse a `Platform` value from a string, in the format returned
31+ -- | by Node.js' `process.platform`.
2532fromString :: String -> Maybe Platform
33+ fromString " aix" = Just AIX
2634fromString " darwin" = Just Darwin
2735fromString " freebsd" = Just FreeBSD
28- fromString " openbsd" = Just OpenBSD
2936fromString " linux" = Just Linux
37+ fromString " openbsd" = Just OpenBSD
3038fromString " sunos" = Just SunOS
3139fromString " win32" = Just Win32
40+ fromString " android" = Just Android
3241fromString _ = Nothing
3342
3443instance showPlatform :: Show Platform where
44+ show AIX = " AIX"
3545 show Darwin = " Darwin"
3646 show FreeBSD = " FreeBSD"
37- show OpenBSD = " OpenBSD"
3847 show Linux = " Linux"
48+ show OpenBSD = " OpenBSD"
3949 show SunOS = " SunOS"
4050 show Win32 = " Win32"
51+ show Android = " Android"
4152
4253derive instance eqPlatform :: Eq Platform
4354derive instance ordPlatform :: Ord Platform
0 commit comments