Skip to content

Commit

Permalink
Merge pull request #26 from purescript/ps-0.11
Browse files Browse the repository at this point in the history
Update for PureScript 0.11
  • Loading branch information
garyb authored Mar 26, 2017
2 parents 6f04722 + 13f4698 commit bf99e6a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: node_js
dist: trusty
sudo: required
node_js: 6
node_js: stable
env:
- PATH=$HOME/purescript:$PATH
install:
Expand Down
10 changes: 5 additions & 5 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
"package.json"
],
"dependencies": {
"purescript-either": "^2.0.0",
"purescript-strings": "^2.0.0",
"purescript-unfoldable": "^2.0.0"
"purescript-either": "^3.0.0",
"purescript-strings": "^3.0.0",
"purescript-unfoldable": "^3.0.0"
},
"devDependencies": {
"purescript-assert": "^2.0.0",
"purescript-console": "^2.0.0"
"purescript-assert": "^3.0.0",
"purescript-console": "^3.0.0"
}
}
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
"private": true,
"scripts": {
"clean": "rimraf output && rimraf .pulp-cache",
"build": "pulp build --censor-lib --strict",
"build": "pulp build -- --censor-lib --strict",
"test": "pulp test"
},
"devDependencies": {
"pulp": "^9.0.1",
"purescript-psa": "^0.3.9",
"rimraf": "^2.5.0"
"pulp": "^10.0.4",
"purescript-psa": "^0.5.0-rc.1",
"rimraf": "^2.6.1"
}
}
15 changes: 5 additions & 10 deletions src/Data/Enum.purs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ defaultPred toEnum' fromEnum' a = toEnum' (fromEnum' a - 1)

-- | Returns a successive sequence of elements from the lower bound to
-- | the upper bound (inclusive).
enumFromTo :: forall a u. (Enum a, Unfoldable u) => a -> a -> u a
enumFromTo :: forall a u. Enum a => Unfoldable u => a -> a -> u a
enumFromTo from to = unfoldr go (Just from)
where
go mx = do
Expand Down Expand Up @@ -129,10 +129,10 @@ intStepFromTo step from to =
diag :: forall a. a -> Tuple a a
diag a = Tuple a a

upFrom :: forall a u. (Enum a, Unfoldable u) => a -> u a
upFrom :: forall a u. Enum a => Unfoldable u => a -> u a
upFrom = unfoldr (map diag <<< succ)

downFrom :: forall a u. (Enum a, Unfoldable u) => a -> u a
downFrom :: forall a u. Enum a => Unfoldable u => a -> u a
downFrom = unfoldr (map diag <<< pred)

-- | Type class for finite enumerations.
Expand Down Expand Up @@ -165,11 +165,6 @@ instance boundedEnumBoolean :: BoundedEnum Boolean where
fromEnum false = 0
fromEnum true = 1

instance boundedEnumInt :: BoundedEnum Int where
cardinality = Cardinality (top - bottom)
toEnum = Just
fromEnum = id

instance boundedEnumChar :: BoundedEnum Char where
cardinality = Cardinality (toCharCode top - toCharCode bottom)
toEnum = charToEnum
Expand Down Expand Up @@ -227,12 +222,12 @@ instance boundedEnumTuple :: (BoundedEnum a, BoundedEnum b) => BoundedEnum (Tupl
from (Cardinality cb) (Tuple a b) = fromEnum a * cb + fromEnum b

-- | Runs in `O(n)` where `n` is `fromEnum top`
defaultCardinality :: forall a. (Bounded a, Enum a) => Cardinality a
defaultCardinality :: forall a. Bounded a => Enum a => Cardinality a
defaultCardinality = Cardinality $ defaultCardinality' 1 (bottom :: a) where
defaultCardinality' i = maybe i (defaultCardinality' $ i + 1) <<< succ

-- | Runs in `O(n)` where `n` is `fromEnum a`
defaultToEnum :: forall a. (Bounded a, Enum a) => Int -> Maybe a
defaultToEnum :: forall a. Bounded a => Enum a => Int -> Maybe a
defaultToEnum n
| n < 0 = Nothing
| n == 0 = Just bottom
Expand Down

0 comments on commit bf99e6a

Please sign in to comment.