Skip to content

Commit f332c15

Browse files
authored
Merge pull request #18 from purescript-contrib/compiler/0.12
Updates for 0.12
2 parents 8dea07e + dc2c350 commit f332c15

File tree

5 files changed

+44
-51
lines changed

5 files changed

+44
-51
lines changed

.travis.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,20 @@ language: node_js
22
dist: trusty
33
sudo: required
44
node_js: stable
5+
env:
6+
- PATH=$HOME/purescript:$PATH
57
install:
8+
- TAG=$(wget -q -O - https://github.com/purescript/purescript/releases/latest --server-response --max-redirect 0 2>&1 | sed -n -e 's/.*Location:.*tag\///p')
9+
- wget -O $HOME/purescript.tar.gz https://github.com/purescript/purescript/releases/download/$TAG/linux64.tar.gz
10+
- tar -xvf $HOME/purescript.tar.gz -C $HOME/
11+
- chmod a+x $HOME/purescript
612
- npm install -g bower
713
- npm install
814
- bower install --production
915
script:
1016
- npm run -s build
1117
- bower install
12-
- npm -s test
18+
- npm run -s test
1319
after_success:
1420
- >-
1521
test $TRAVIS_TAG &&

bower.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616
"package.json"
1717
],
1818
"dependencies": {
19-
"purescript-datetime": "^3.0.0",
20-
"purescript-exceptions": "^3.0.0",
21-
"purescript-foreign": "^4.0.0",
22-
"purescript-integers": "^3.0.0",
23-
"purescript-now": "^3.0.0"
19+
"purescript-datetime": "^4.0.0",
20+
"purescript-exceptions": "^4.0.0",
21+
"purescript-foreign": "^5.0.0",
22+
"purescript-integers": "^4.0.0",
23+
"purescript-now": "^4.0.0"
2424
},
2525
"devDependencies": {
26-
"purescript-assert": "^3.0.0",
27-
"purescript-console": "^3.0.0",
28-
"purescript-globals": "^3.0.0"
26+
"purescript-assert": "^4.0.0",
27+
"purescript-console": "^4.1.0",
28+
"purescript-globals": "^4.0.0"
2929
}
3030
}

package.json

+4-5
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,9 @@
66
"test": "pulp test"
77
},
88
"devDependencies": {
9-
"eslint": "^3.19.0",
10-
"pulp": "^11.0.0",
11-
"purescript-psa": "^0.5.0",
12-
"purescript": "^0.11.1",
13-
"rimraf": "^2.6.1"
9+
"eslint": "^4.19.1",
10+
"pulp": "^12.2.0",
11+
"purescript-psa": "^0.6.0",
12+
"rimraf": "^2.6.2"
1413
}
1514
}

src/Data/JSDate.purs

+18-27
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
-- | a `Generic` instance.
99
module Data.JSDate
1010
( JSDate
11-
, LOCALE
1211
, readDate
1312
, isValid
1413
, fromDateTime
@@ -48,21 +47,19 @@ module Data.JSDate
4847

4948
import Prelude
5049

51-
import Control.Monad.Eff (kind Effect, Eff)
52-
import Control.Monad.Eff.Exception (EXCEPTION)
53-
import Control.Monad.Eff.Now (NOW)
5450
import Data.Date as Date
5551
import Data.DateTime (DateTime(..), Date)
5652
import Data.DateTime as DateTime
5753
import Data.DateTime.Instant (Instant)
5854
import Data.DateTime.Instant as Instant
5955
import Data.Enum (fromEnum)
60-
import Data.Foreign (F, Foreign, unsafeReadTagged)
6156
import Data.Function.Uncurried (Fn2, runFn2)
6257
import Data.Int (toNumber)
6358
import Data.Maybe (Maybe(..))
6459
import Data.Time as Time
6560
import Data.Time.Duration (Milliseconds(..))
61+
import Effect (Effect)
62+
import Foreign (F, Foreign, unsafeReadTagged)
6663

6764
-- | The type of JavaScript `Date` objects.
6865
foreign import data JSDate :: Type
@@ -76,10 +73,6 @@ instance ordJSDate :: Ord JSDate where
7673
instance showJSDate :: Show JSDate where
7774
show a = "(fromTime " <> show (getTime a) <> ")"
7875

79-
-- | The effect type used when indicating the current machine's date/time locale
80-
-- | is used in computing a value.
81-
foreign import data LOCALE :: Effect
82-
8376
-- | Attempts to read a `Foreign` value as a `JSDate`.
8477
readDate :: Foreign -> F JSDate
8578
readDate = unsafeReadTagged "Date"
@@ -142,18 +135,17 @@ foreign import jsdate
142135
-- | Constructs a new `JSDate` from component values using the current machine's
143136
-- | locale. If any of the values are `NaN` the resulting date will be invalid.
144137
foreign import jsdateLocal
145-
:: forall eff
146-
. { year :: Number
138+
:: { year :: Number
147139
, month :: Number
148140
, day :: Number
149141
, hour :: Number
150142
, minute :: Number
151143
, second :: Number
152144
, millisecond :: Number
153145
}
154-
-> Eff (locale :: LOCALE | eff) JSDate
146+
-> Effect JSDate
155147

156-
foreign import dateMethodEff :: forall eff a. Fn2 String JSDate (Eff eff a)
148+
foreign import dateMethodEff :: forall a. Fn2 String JSDate (Effect a)
157149
foreign import dateMethod :: forall a. Fn2 String JSDate a
158150

159151
-- | Attempts to parse a date from a string. The behaviour of this function is
@@ -163,15 +155,14 @@ foreign import dateMethod :: forall a. Fn2 String JSDate a
163155
-- |
164156
-- | The `LOCALE` effect is present here as if no time zone is specified in the
165157
-- | string the current locale's time zone will be used instead.
166-
foreign import parse
167-
:: forall eff. String -> Eff (locale :: LOCALE | eff) JSDate
158+
foreign import parse :: String -> Effect JSDate
168159

169160
-- | Gets a `JSDate` value for the date and time according to the current
170161
-- | machine's clock.
171162
-- |
172163
-- | Unless a `JSDate` is required specifically, consider using the functions in
173-
-- | `Control.Monad.Eff.Now` instead.
174-
foreign import now :: forall eff. Eff (now :: NOW | eff) JSDate
164+
-- | `Effect.Now` instead.
165+
foreign import now :: Effect JSDate
175166

176167
-- | Returns the date as a number of milliseconds since 1970-01-01 00:00:00 UTC.
177168
getTime :: JSDate -> Number
@@ -211,55 +202,55 @@ getUTCSeconds dt = runFn2 dateMethod "getUTCSeconds" dt
211202

212203
-- | Returns the day of the month for a date, according to the current
213204
-- | machine's date/time locale.
214-
getDate :: forall eff. JSDate -> Eff (locale :: LOCALE | eff) Number
205+
getDate :: JSDate -> Effect Number
215206
getDate dt = runFn2 dateMethodEff "getDate" dt
216207

217208
-- | Returns the day of the week for a date, according to the current
218209
-- | machine's date/time locale.
219-
getDay :: forall eff. JSDate -> Eff (locale :: LOCALE | eff) Number
210+
getDay :: JSDate -> Effect Number
220211
getDay dt = runFn2 dateMethodEff "getDay" dt
221212

222213
-- | Returns the year for a date, according to the current machine's date/time
223214
-- | locale.
224-
getFullYear :: forall eff. JSDate -> Eff (locale :: LOCALE | eff) Number
215+
getFullYear :: JSDate -> Effect Number
225216
getFullYear dt = runFn2 dateMethodEff "getFullYear" dt
226217

227218
-- | Returns the hour for a date, according to the current machine's date/time
228219
-- | locale.
229-
getHours :: forall eff. JSDate -> Eff (locale :: LOCALE | eff) Number
220+
getHours :: JSDate -> Effect Number
230221
getHours dt = runFn2 dateMethodEff "getHours" dt
231222

232223
-- | Returns the milliseconds for a date, according to the current machine's
233224
-- | date/time locale.
234-
getMilliseconds :: forall eff. JSDate -> Eff (locale :: LOCALE | eff) Number
225+
getMilliseconds :: JSDate -> Effect Number
235226
getMilliseconds dt = runFn2 dateMethodEff "getMilliseconds" dt
236227

237228
-- | Returns the minutes for a date, according to the current machine's
238229
-- | date/time locale.
239-
getMinutes :: forall eff. JSDate -> Eff (locale :: LOCALE | eff) Number
230+
getMinutes :: JSDate -> Effect Number
240231
getMinutes dt = runFn2 dateMethodEff "getMinutes" dt
241232

242233
-- | Returns the month for a date, according to the current machine's
243234
-- | date/time locale.
244-
getMonth :: forall eff. JSDate -> Eff (locale :: LOCALE | eff) Number
235+
getMonth :: JSDate -> Effect Number
245236
getMonth dt = runFn2 dateMethodEff "getMonth" dt
246237

247238
-- | Returns the seconds for a date, according to the current machine's
248239
-- | date/time locale.
249-
getSeconds :: forall eff. JSDate -> Eff (locale :: LOCALE | eff) Number
240+
getSeconds :: JSDate -> Effect Number
250241
getSeconds dt = runFn2 dateMethodEff "getSeconds" dt
251242

252243
-- | Returns the time-zone offset for a date, according to the current machine's
253244
-- | date/time locale.
254-
getTimezoneOffset :: forall eff. JSDate -> Eff (locale :: LOCALE | eff) Number
245+
getTimezoneOffset :: JSDate -> Effect Number
255246
getTimezoneOffset dt = runFn2 dateMethodEff "getTimezoneOffset" dt
256247

257248
-- | Returns the date portion of a date value as a human-readable string.
258249
toDateString :: JSDate -> String
259250
toDateString dt = runFn2 dateMethod "toDateString" dt
260251

261252
-- | Converts a date value to an ISO 8601 Extended format date string.
262-
toISOString :: forall eff. JSDate -> Eff (exception :: EXCEPTION | eff) String
253+
toISOString :: JSDate -> Effect String
263254
toISOString dt = runFn2 dateMethodEff "toISOString" dt
264255

265256
-- | Returns a string representing for a date value.

test/Test/Main.purs

+7-10
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,22 @@ module Test.Main where
22

33
import Prelude
44

5-
import Control.Monad.Eff (Eff)
6-
import Control.Monad.Eff.Console (CONSOLE, log)
75
import Control.Monad.Except (runExcept)
8-
96
import Data.DateTime as DT
10-
import Data.Enum (toEnum)
117
import Data.Either (isRight)
12-
import Data.Foreign (F, Foreign)
8+
import Data.Enum (toEnum)
139
import Data.JSDate as JSD
1410
import Data.Maybe (Maybe(..), fromJust)
15-
import Partial.Unsafe (unsafePartial)
16-
11+
import Effect (Effect)
12+
import Effect.Console (log)
13+
import Foreign (F, Foreign)
1714
import Global (nan)
18-
19-
import Test.Assert (ASSERT, assert)
15+
import Partial.Unsafe (unsafePartial)
16+
import Test.Assert (assert)
2017

2118
foreign import myDate :: Foreign
2219

23-
main :: forall eff. Eff (console :: CONSOLE, assert :: ASSERT, locale :: JSD.LOCALE | eff) Unit
20+
main :: Effect Unit
2421
main = do
2522

2623
log "Checking that readDate will read JS date values..."

0 commit comments

Comments
 (0)