Skip to content

Commit 45024fe

Browse files
authored
Merge pull request #2 from Dstoq/compiler-0.12
upgrade to compiler 0.12
2 parents 79906a6 + f64a286 commit 45024fe

File tree

3 files changed

+38
-41
lines changed

3 files changed

+38
-41
lines changed

bower.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
"output"
1717
],
1818
"dependencies": {
19-
"purescript-prelude": "^3.1.0",
20-
"purescript-maps": "^3.5.0",
21-
"purescript-datetime": "^3.3.0"
19+
"purescript-prelude": "^4.1.0",
20+
"purescript-datetime": "^4.0.0",
21+
"purescript-foreign-object": "^1.0.0"
2222
},
2323
"devDependencies": {
24-
"purescript-psci-support": "^3.0.0"
24+
"purescript-psci-support": "^4.0.0"
2525
}
2626
}

src/Node/OS.purs

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module Node.OS
2-
( OS, NetworkInterface, CPU
2+
( NetworkInterface
3+
, CPU
34
, eol
45
, Arch(..), arch
56
, cpus
@@ -19,21 +20,20 @@ module Node.OS
1920
) where
2021

2122
import Prelude
22-
23+
2324
import Data.Array ((!!))
2425
import Data.Maybe (Maybe(..), fromMaybe)
25-
import Data.StrMap (StrMap, update)
2626
import Data.Time.Duration (Milliseconds, Seconds)
27-
28-
import Control.Monad.Eff (Eff, kind Effect)
29-
27+
import Foreign.Object (Object, update)
28+
import Effect (Effect)
29+
3030
type NetworkInterface = { address :: String
3131
, netmask :: String
3232
, family :: String
3333
, mac :: String
3434
, internal :: Boolean
3535
}
36-
36+
3737
type CPU = { model :: String
3838
, speed :: Int
3939
, times :: { user :: Milliseconds
@@ -42,9 +42,7 @@ type CPU = { model :: String
4242
, idle :: Milliseconds
4343
, irq :: Milliseconds } }
4444

45-
foreign import data OS :: Effect
46-
47-
loadavg :: forall eff. Eff ( os :: OS | eff ) { one :: Number, five :: Number, fifteen :: Number }
45+
loadavg :: Effect { one :: Number, five :: Number, fifteen :: Number }
4846
loadavg = pure <<< fromMaybe {one: 0.0, five: 0.0, fifteen: 0.0} <<< extract =<< loadavgImpl
4947
where
5048
extract xs = {one: _, five: _, fifteen: _} <$> xs !! 0 <*> xs !! 1 <*> xs !! 2
@@ -59,7 +57,7 @@ instance showArch :: Show Arch where
5957
show IA32 = "IA32"
6058
show UnknownArch = "UnknownArch"
6159

62-
arch :: forall eff. Eff ( os :: OS | eff ) Arch
60+
arch :: Effect Arch
6361
arch = do
6462
a <- archImpl
6563
pure case a of
@@ -77,7 +75,7 @@ instance showEndianness :: Show Endianness where
7775
show BigEndian = "BigEndian"
7876
show UnknownEndian = "UnknownEndian"
7977

80-
endianness :: forall eff. Eff ( os :: OS | eff ) Endianness
78+
endianness :: Effect Endianness
8179
endianness = do
8280
e <- endiannessImpl
8381
pure case e of
@@ -97,7 +95,7 @@ instance showPlatform :: Show Platform where
9795
show Win32 = "Win32"
9896
show UnknownPlatform = "UnknownPlatform"
9997

100-
platform :: forall eff. Eff ( os :: OS | eff ) Platform
98+
platform :: Effect Platform
10199
platform = do
102100
p <- platformImpl
103101
pure case p of
@@ -107,7 +105,7 @@ platform = do
107105
"freebsd" -> FreeBSD
108106
"sunos" -> SunOS
109107
_ -> UnknownPlatform
110-
108+
111109
type UserInfo =
112110
{ uid :: Int
113111
, gid :: Int
@@ -116,30 +114,29 @@ type UserInfo =
116114
, shell :: Maybe String
117115
}
118116

119-
userInfo :: forall eff. {encoding :: String} -> Eff ( os :: OS | eff ) UserInfo
117+
userInfo :: {encoding :: String} -> Effect UserInfo
120118
userInfo = userInfoImpl (flip update "shell") Nothing Just
121119

122120
foreign import eol :: Char
123-
foreign import archImpl :: forall eff. Eff ( os :: OS | eff ) String
124-
foreign import cpus :: forall eff. Eff ( os :: OS | eff ) (Array CPU)
125-
foreign import endiannessImpl :: forall eff. Eff ( os :: OS | eff ) String
126-
foreign import freemem :: forall eff. Eff ( os :: OS | eff ) Number
127-
foreign import homedir :: forall eff. Eff ( os :: OS | eff ) String
128-
foreign import hostname :: forall eff. Eff ( os :: OS | eff ) String
129-
foreign import loadavgImpl :: forall eff. Eff ( os :: OS | eff ) (Array Number)
130-
foreign import platformImpl :: forall eff. Eff ( os :: OS | eff ) String
131-
foreign import release :: forall eff. Eff ( os :: OS | eff ) String
132-
foreign import tmpdir :: forall eff. Eff ( os :: OS | eff ) String
133-
foreign import totalmem :: forall eff. Eff ( os :: OS | eff ) Number
134-
foreign import ostype :: forall eff. Eff ( os :: OS | eff ) String
135-
foreign import uptime :: forall eff. Eff ( os :: OS | eff ) Seconds
121+
foreign import archImpl :: Effect String
122+
foreign import cpus :: Effect (Array CPU)
123+
foreign import endiannessImpl :: Effect String
124+
foreign import freemem :: Effect Number
125+
foreign import homedir :: Effect String
126+
foreign import hostname :: Effect String
127+
foreign import loadavgImpl :: Effect (Array Number)
128+
foreign import platformImpl :: Effect String
129+
foreign import release :: Effect String
130+
foreign import tmpdir :: Effect String
131+
foreign import totalmem :: Effect Number
132+
foreign import ostype :: Effect String
133+
foreign import uptime :: Effect Seconds
136134
foreign import networkInterfaces
137-
:: forall eff
138-
. Eff ( os :: OS | eff ) (StrMap (Array NetworkInterface))
139-
foreign import userInfoImpl
140-
:: forall a eff
141-
. ((a -> Maybe a) -> StrMap a -> StrMap a)
135+
:: Effect (Object (Array NetworkInterface))
136+
foreign import userInfoImpl
137+
:: forall a
138+
. ((a -> Maybe a) -> Object a -> Object a)
142139
-> Maybe a
143140
-> (a -> Maybe a)
144141
-> {encoding :: String}
145-
-> Eff ( os :: OS | eff ) UserInfo
142+
-> Effect UserInfo

test/Main.purs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
module Test.Main where
22

33
import Prelude (Unit)
4-
import Control.Monad.Eff (Eff)
5-
import Control.Monad.Eff.Console (CONSOLE, log)
4+
import Effect (Effect)
5+
import Effect.Console (log)
66

7-
main :: forall e. Eff (console :: CONSOLE | e) Unit
7+
main :: Effect Unit
88
main = do
99
log "You should add some tests."

0 commit comments

Comments
 (0)