Skip to content

Commit

Permalink
Merge pull request #71 from purescript/compiler/0.12
Browse files Browse the repository at this point in the history
Updates for PureScript 0.12
  • Loading branch information
garyb authored May 24, 2018
2 parents 0374573 + e125b49 commit ffdd94f
Show file tree
Hide file tree
Showing 15 changed files with 125 additions and 215 deletions.
38 changes: 22 additions & 16 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
The MIT License (MIT)
Copyright 2018 PureScript

Copyright (c) 2014 PureScript
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 changes: 21 additions & 12 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"name": "purescript-datetime",
"homepage": "https://github.com/purescript/purescript-datetime",
"description": "PureScript library for date and time values",
"license": "MIT",
"license": "BSD-3-Clause",
"repository": {
"type": "git",
"url": "git://github.com/purescript/purescript-datetime.git"
Expand All @@ -16,17 +15,27 @@
"package.json"
],
"dependencies": {
"purescript-enums": "^3.1.0",
"purescript-functions": "^3.0.0",
"purescript-generics": "^4.0.0",
"purescript-integers": "^3.0.0",
"purescript-foldable-traversable": "^3.0.0",
"purescript-maps": "^3.0.0",
"purescript-math": "^2.0.0"
"purescript-bifunctors": "^4.0.0",
"purescript-control": "^4.0.0",
"purescript-either": "^4.0.0",
"purescript-enums": "^4.0.0",
"purescript-foldable-traversable": "^4.0.0",
"purescript-functions": "^4.0.0",
"purescript-gen": "^2.0.0",
"purescript-integers": "^4.0.0",
"purescript-lists": "^5.0.0",
"purescript-math": "^2.1.1",
"purescript-maybe": "^4.0.0",
"purescript-newtype": "^3.0.0",
"purescript-ordered-collections": "^1.0.0",
"purescript-partial": "^2.0.0",
"purescript-prelude": "^4.0.0",
"purescript-tuples": "^5.0.0"
},
"devDependencies": {
"purescript-assert": "^3.0.0",
"purescript-console": "^3.0.0",
"purescript-strings": "^3.0.0"
"purescript-assert": "^4.0.0",
"purescript-console": "^4.0.0",
"purescript-strings": "^4.0.0",
"purescript-proxy": "^3.0.0"
}
}
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"scripts": {
"clean": "rimraf output && rimraf .pulp-cache",
"build": "eslint src && pulp build -- --censor-lib --strict",
"test": "pulp test"
"test": "pulp test --check-main-type Effect.Effect"
},
"devDependencies": {
"eslint": "^3.17.1",
"pulp": "^11.0.x",
"purescript-psa": "^0.5.x",
"rimraf": "^2.6.1"
"eslint": "^4.19.1",
"pulp": "^12.2.0",
"purescript-psa": "^0.6.0",
"rimraf": "^2.6.2"
}
}
32 changes: 15 additions & 17 deletions src/Data/Date.purs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ import Prelude
import Data.Date.Component (Day, Month(..), Weekday(..), Year)
import Data.Enum (toEnum, fromEnum)
import Data.Function.Uncurried (Fn3, runFn3, Fn4, runFn4, Fn6, runFn6)
import Data.Generic (class Generic)
import Data.Maybe (Maybe(..), fromJust)
import Data.Time.Duration (class Duration, toDuration, Milliseconds)

import Data.Time.Duration (class Duration, Milliseconds, toDuration)
import Partial.Unsafe (unsafePartial)

-- | A date value in the Gregorian calendar.
Expand All @@ -45,7 +43,6 @@ exactDate y m d =

derive instance eqDate :: Eq Date
derive instance ordDate :: Ord Date
derive instance genericDate :: Generic Date

instance boundedDate :: Bounded Date where
bottom = Date bottom bottom bottom
Expand Down Expand Up @@ -78,29 +75,30 @@ diff :: forall d. Duration d => Date -> Date -> d
diff (Date y1 m1 d1) (Date y2 m2 d2) =
toDuration $ runFn6 calcDiff y1 (fromEnum m1) d1 y2 (fromEnum m2) d2

-- | Is this year a leap year according to the proleptic Gregorian calendar?
-- | Checks whether a year is a leap year according to the proleptic Gregorian
-- | calendar.
isLeapYear :: Year -> Boolean
isLeapYear y = (mod y' 4 == 0) && ((mod y' 400 == 0) || not (mod y' 100 == 0))
where
y' = fromEnum y

-- | Get the final day of a month and year, accounting for leap years
-- | Get the final day of a month and year, accounting for leap years.
lastDayOfMonth :: Year -> Month -> Day
lastDayOfMonth y m = case m of
January -> unsafeDay 31
January -> unsafeDay 31
February
| isLeapYear y -> unsafeDay 29
| otherwise -> unsafeDay 28
March -> unsafeDay 31
April -> unsafeDay 30
May -> unsafeDay 31
June -> unsafeDay 30
July -> unsafeDay 31
August -> unsafeDay 31
| otherwise -> unsafeDay 28
March -> unsafeDay 31
April -> unsafeDay 30
May -> unsafeDay 31
June -> unsafeDay 30
July -> unsafeDay 31
August -> unsafeDay 31
September -> unsafeDay 30
October -> unsafeDay 31
November -> unsafeDay 30
December -> unsafeDay 31
October -> unsafeDay 31
November -> unsafeDay 30
December -> unsafeDay 31
where
unsafeDay = unsafePartial fromJust <<< toEnum

Expand Down
5 changes: 0 additions & 5 deletions src/Data/Date/Component.purs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ module Data.Date.Component
import Prelude

import Data.Enum (class Enum, class BoundedEnum, toEnum, fromEnum, Cardinality(..))
import Data.Generic (class Generic)
import Data.Maybe (Maybe(..))

-- | A year component for a date.
Expand All @@ -20,7 +19,6 @@ newtype Year = Year Int

derive newtype instance eqYear :: Eq Year
derive newtype instance ordYear :: Ord Year
derive instance genericYear :: Generic Year

-- Note: these seemingly arbitrary bounds come from relying on JS for date
-- manipulations, as it only supports date ±100,000,000 days of the Unix epoch.
Expand Down Expand Up @@ -61,7 +59,6 @@ data Month

derive instance eqMonth :: Eq Month
derive instance ordMonth :: Ord Month
derive instance genericMonth :: Generic Month

instance boundedMonth :: Bounded Month where
bottom = January
Expand Down Expand Up @@ -124,7 +121,6 @@ newtype Day = Day Int

derive newtype instance eqDay :: Eq Day
derive newtype instance ordDay :: Ord Day
derive instance genericDay :: Generic Day

instance boundedDay :: Bounded Day where
bottom = Day 1
Expand Down Expand Up @@ -156,7 +152,6 @@ data Weekday

derive instance eqWeekday :: Eq Weekday
derive instance ordWeekday :: Ord Weekday
derive instance genericWeekday :: Generic Weekday

instance boundedWeekday :: Bounded Weekday where
bottom = Monday
Expand Down
2 changes: 0 additions & 2 deletions src/Data/DateTime.purs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import Prelude
import Data.Date (Date, Day, Month(..), Weekday(..), Year, canonicalDate, day, exactDate, month, weekday, year)
import Data.Enum (toEnum, fromEnum)
import Data.Function.Uncurried (Fn2, runFn2)
import Data.Generic (class Generic)
import Data.Time (Hour, Millisecond, Minute, Second, Time(..), hour, setHour, millisecond, setMillisecond, minute, setMinute, second, setSecond)
import Data.Time.Duration (class Duration, fromDuration, toDuration, Milliseconds)
import Data.Maybe (Maybe(..))
Expand All @@ -27,7 +26,6 @@ data DateTime = DateTime Date Time

derive instance eqDateTime :: Eq DateTime
derive instance ordDateTime :: Ord DateTime
derive instance genericDateTime :: Generic DateTime

instance boundedDateTime :: Bounded DateTime where
bottom = DateTime bottom bottom
Expand Down
2 changes: 0 additions & 2 deletions src/Data/DateTime/Instant.purs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import Prelude
import Data.DateTime (Millisecond, Second, Minute, Hour, Day, Year, DateTime(..), Date, Time(..), canonicalDate, millisecond, second, minute, hour, day, month, year)
import Data.Enum (fromEnum, toEnum)
import Data.Function.Uncurried (Fn7, runFn7)
import Data.Generic (class Generic)
import Data.Maybe (Maybe(..), fromJust)
import Data.Time.Duration (Milliseconds(..))

Expand All @@ -27,7 +26,6 @@ newtype Instant = Instant Milliseconds

derive newtype instance eqDateTime :: Eq Instant
derive newtype instance ordDateTime :: Ord Instant
derive instance genericDateTime :: Generic Instant

instance boundedInstant :: Bounded Instant where
bottom = Instant (Milliseconds (-8639977881600000.0))
Expand Down
74 changes: 0 additions & 74 deletions src/Data/DateTime/Locale.purs

This file was deleted.

6 changes: 3 additions & 3 deletions src/Data/Interval.purs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Data.Interval
( Interval(..)
, RecurringInterval(..)
, module DurationExports
, module Exports
) where

import Prelude
Expand All @@ -11,7 +11,7 @@ import Data.Bifoldable (class Bifoldable, bifoldl, bifoldr, bifoldrDefault, bifo
import Data.Bifunctor (class Bifunctor, bimap)
import Data.Bitraversable (class Bitraversable, bitraverse, bisequenceDefault)
import Data.Foldable (class Foldable, foldl, foldr, foldrDefault, foldMapDefaultL)
import Data.Interval.Duration as DurationExports
import Data.Interval.Duration (Duration(..), DurationComponent(..), day, hour, millisecond, minute, month, second, week, year) as Exports
import Data.Maybe (Maybe)
import Data.Traversable (class Traversable, traverse, sequenceDefault)

Expand Down Expand Up @@ -70,7 +70,7 @@ instance showInterval :: (Show d, Show a) => Show (Interval d a) where
show (DurationOnly d) = "(DurationOnly " <> show d <> ")"

instance functorInterval :: Functor (Interval d) where
map = bimap id
map = bimap identity

instance bifunctorInterval :: Bifunctor Interval where
bimap _ f (StartEnd x y) = StartEnd (f x) (f y)
Expand Down
1 change: 0 additions & 1 deletion src/Data/Interval/Duration.purs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ module Data.Interval.Duration
import Prelude

import Data.Map as Map
import Data.Monoid (class Monoid, mempty)
import Data.Newtype (class Newtype)

newtype Duration = Duration (Map.Map DurationComponent Number)
Expand Down
2 changes: 1 addition & 1 deletion src/Data/Interval/Duration/Iso.purs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ mkIsoDuration d = case fromList (checkValidIsoDuration d) of
checkValidIsoDuration :: Duration -> List Error
checkValidIsoDuration (Duration asMap) = check {asList, asMap}
where
asList = reverse (Map.toAscUnfoldable asMap)
asList = reverse (Map.toUnfoldable asMap)
check = fold
[ checkWeekUsage
, checkEmptiness
Expand Down
Loading

0 comments on commit ffdd94f

Please sign in to comment.