Skip to content

Commit 87f8809

Browse files
authored
Merge pull request #23 from jasonzoladz/master
Updates for psc 0.9.1 and dependencies.
2 parents ff4ee78 + 7dd7510 commit 87f8809

File tree

10 files changed

+90
-84
lines changed

10 files changed

+90
-84
lines changed

.travis.yml

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
language: node_js
22
dist: trusty
33
sudo: required
4-
node_js: 5
4+
node_js: 6
55
install:
6-
- npm install
76
- npm install -g bower
8-
- bower install
7+
- npm install
98
script:
10-
- npm run build
9+
- bower install --production
10+
- npm run -s build
11+
- bower install
12+
- npm -s test
1113
after_success:
1214
- >-
1315
test $TRAVIS_TAG &&
14-
node_modules/.bin/psc-publish > .pursuit.json &&
15-
curl -X POST http://pursuit.purescript.org/packages \
16-
-d @.pursuit.json \
17-
-H 'Accept: application/json' \
18-
-H "Authorization: token ${GITHUB_TOKEN}"
16+
echo $GITHUB_TOKEN | pulp login &&
17+
echo y | pulp publish --no-push

bower.json

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,22 @@
2424
"package.json"
2525
],
2626
"dependencies": {
27-
"purescript-aff": "^0.16.0",
28-
"purescript-dom": "^0.2.6",
29-
"purescript-eff": "^0.1.1",
30-
"purescript-either": "^0.2.2",
31-
"purescript-globals": "^0.2.1",
32-
"purescript-lists": "^0.7.4",
33-
"purescript-maps": "^0.5.0",
34-
"purescript-maybe": "^0.3.4",
35-
"purescript-prelude": "^0.1.2",
36-
"purescript-semirings": "^0.2.0",
37-
"purescript-tuples": "^0.4.0",
38-
"purescript-validation": "^0.2.0"
27+
"purescript-dom": "^1.1.0",
28+
"purescript-eff": "^1.0.0",
29+
"purescript-either": "^1.0.0",
30+
"purescript-globals": "^1.0.0",
31+
"purescript-lists": "^1.0.1",
32+
"purescript-maps": "^1.1.0",
33+
"purescript-maybe": "^1.0.0",
34+
"purescript-prelude": "^1.0.1",
35+
"purescript-semirings": "^1.0.0",
36+
"purescript-tuples": "^1.0.0",
37+
"purescript-validation": "^1.0.0",
38+
"purescript-aff": "^1.0.0",
39+
"purescript-control": "^1.0.0",
40+
"purescript-console": "^1.0.0"
3941
},
4042
"devDependencies": {
41-
"purescript-console": "^0.1.0"
43+
"purescript-console": "^1.0.0"
4244
}
4345
}

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
"private": true,
33
"scripts": {
44
"clean": "rimraf output && rimraf .pulp-cache",
5-
"build": "pulp build",
6-
"test": "pulp build --include test --to public/test.js"
5+
"build": "pulp build --censor-lib --strict",
6+
"test": "pulp test"
77
},
88
"devDependencies": {
9-
"pulp": "^8.1.0",
10-
"purescript": "^0.7.6",
11-
"rimraf": "^2.5.2"
9+
"pulp": "^9.0.1",
10+
"purescript-psa": "^0.3.9",
11+
"purescript": "^0.9.1",
12+
"rimraf": "^2.5.0"
1213
}
1314
}

src/Routing.purs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ module Routing (
99
matchesAff'
1010
) where
1111

12-
import Prelude
12+
import Prelude (Unit, unit, pure, const, ($))
1313
import Control.Monad.Eff (Eff())
1414
import Control.Monad.Aff (Aff(), makeAff)
1515
import Data.Maybe (Maybe(..))
16-
import Data.Either (Either(), either)
16+
import Data.Either (Either(..), either)
1717
import Data.Tuple (Tuple(..))
18-
import qualified Data.String.Regex as R
18+
import Data.String.Regex as R
1919

20-
import Routing.Parser
21-
import Routing.Match
20+
import Routing.Parser (parse)
21+
import Routing.Match (Match, runMatch)
2222

2323

2424
foreign import decodeURIComponent :: String -> String
@@ -30,7 +30,10 @@ hashes :: forall e. (String -> String -> Eff e Unit) -> Eff e Unit
3030
hashes cb =
3131
hashChanged $ \old new -> do
3232
cb (dropHash old) (dropHash new)
33-
where dropHash h = R.replace (R.regex "^[^#]*#" R.noFlags) "" h
33+
where dropHash h =
34+
case R.regex "^[^#]*#" R.noFlags of
35+
Right regX -> R.replace regX "" h
36+
Left _ -> h
3437

3538

3639
-- | Stream of hash changed, callback called when new hash can be matched

src/Routing/Hash.purs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Routing.Hash where
22

3-
import Prelude
3+
import Prelude (Unit, (>>=), (<$>))
44
import Control.Monad.Eff (Eff())
55
import DOM (DOM())
66

@@ -9,4 +9,4 @@ foreign import setHash :: forall e. String -> Eff (dom :: DOM |e) Unit
99
foreign import getHash :: forall e. Eff (dom :: DOM |e) String
1010

1111
modifyHash :: forall e. (String -> String) -> Eff (dom :: DOM|e) Unit
12-
modifyHash fn = (fn <$> getHash) >>= setHash
12+
modifyHash fn = (fn <$> getHash) >>= setHash

src/Routing/Hash/Aff.purs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
module Routing.Hash.Aff where
22

3-
import Prelude
3+
import Prelude (($), Unit)
44
import DOM (DOM())
55
import Control.Monad.Aff (Aff())
66
import Control.Monad.Eff.Class (liftEff)
7-
import qualified Routing.Hash as R
7+
import Routing.Hash as R
88

9-
modifyHash :: forall e. (String -> String) -> Aff (dom :: DOM|e) Unit
10-
modifyHash func = liftEff $ R.modifyHash func
9+
modifyHash :: forall e. (String -> String) -> Aff (dom :: DOM|e) Unit
10+
modifyHash func = liftEff $ R.modifyHash func
1111

12-
setHash :: forall e. String -> Aff (dom :: DOM|e) Unit
12+
setHash :: forall e. String -> Aff (dom :: DOM|e) Unit
1313
setHash hash = liftEff $ R.setHash hash
14-

src/Routing/Match.purs

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
module Routing.Match where
22

3-
import Prelude
3+
4+
import Prelude (class Applicative, class Apply, class Functor, pure, bind, const, one, id, unit, ($), (<<<), (<$>), (<>), (*), (==))
45
import Data.Either (Either(..))
56
import Data.Tuple (Tuple(..), snd)
67
import Data.Maybe (Maybe(..))
78
import Data.List (List(..), reverse)
8-
import Control.Alt (Alt, (<|>))
9-
import Control.Plus (Plus)
10-
import Control.Alternative (Alternative)
9+
import Control.Alt (class Alt, (<|>))
10+
import Control.Plus (class Plus)
11+
import Control.Alternative (class Alternative)
1112
import Global (readFloat, isNaN)
1213
import Data.Semiring.Free (Free(), free, runFree)
13-
import Data.Foldable
14-
import Data.Validation.Semiring
14+
import Data.Foldable (foldl)
15+
import Data.Validation.Semiring (V, invalid, unV)
1516

1617

17-
import qualified Data.Map as M
18+
import Data.Map as M
1819

19-
import Routing.Types
20-
import Routing.Match.Class
21-
import Routing.Match.Error
20+
import Routing.Types (Route, RoutePart(..))
21+
import Routing.Match.Class (class MatchClass)
22+
import Routing.Match.Error (MatchError(..), showMatchError)
2223

2324
newtype Match a = Match (Route -> V (Free MatchError) (Tuple Route a))
2425
unMatch :: forall a. Match a -> (Route -> V (Free MatchError) (Tuple Route a))
@@ -84,7 +85,7 @@ instance matchMatchClass :: MatchClass Match where
8485

8586
instance matchFunctor :: Functor Match where
8687
map fn (Match r2e) = Match $ \r ->
87-
runV invalid (\(Tuple rs a) -> pure $ Tuple rs (fn a)) $ r2e r
88+
unV invalid (\(Tuple rs a) -> pure $ Tuple rs (fn a)) $ r2e r
8889

8990
instance matchAlt :: Alt Match where
9091
alt (Match r2e1) (Match r2e2) = Match $ \r -> do
@@ -97,11 +98,11 @@ instance matchAlternative :: Alternative Match
9798

9899
instance matchApply :: Apply Match where
99100
apply (Match r2a2b) (Match r2a) =
100-
Match $ (\r -> runV (processFnErr r) processFnRes (r2a2b r))
101+
Match $ (\r -> unV (processFnErr r) processFnRes (r2a2b r))
101102
where processFnErr r err =
102-
invalid $ err * runV id (const one) (r2a r)
103+
invalid $ err * unV id (const one) (r2a r)
103104
processFnRes (Tuple rs a2b) =
104-
runV invalid (\(Tuple rss a) -> pure $ Tuple rss (a2b a)) (r2a rs)
105+
unV invalid (\(Tuple rss a) -> pure $ Tuple rss (a2b a)) (r2a rs)
105106

106107
instance matchApplicative :: Applicative Match where
107108
pure a = Match \r -> pure $ Tuple r a
@@ -113,7 +114,7 @@ list (Match r2a) =
113114
Match $ go Nil
114115
where go :: List a -> Route -> V (Free MatchError) (Tuple Route (List a))
115116
go accum r =
116-
runV
117+
unV
117118
(const $ pure (Tuple r (reverse accum)))
118119
(\(Tuple rs a) -> go (Cons a accum) rs)
119120
(r2a r)
@@ -125,7 +126,7 @@ list (Match r2a) =
125126
-- [[String]] -fold with semicolon-> [String] -fold with newline-> String
126127
runMatch :: forall a. Match a -> Route -> Either String a
127128
runMatch (Match fn) route =
128-
runV foldErrors (Right <<< snd) $ fn route
129+
unV foldErrors (Right <<< snd) $ fn route
129130
where
130131
foldErrors errs =
131132
Left $ foldl (\b a -> a <> "\n" <> b) "" do
@@ -151,7 +152,7 @@ runMatch (Match fn) route =
151152
-- | ```
152153
eitherMatch :: forall a b. Match (Either a b) -> Match b
153154
eitherMatch (Match r2eab) = Match $ \r ->
154-
runV invalid runEither $ (r2eab r)
155+
unV invalid runEither $ (r2eab r)
155156
where
156157
runEither (Tuple rs eit) =
157158
case eit of

src/Routing/Match/Class.purs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Routing.Match.Class where
22

3-
import Prelude
4-
import Control.Alternative (Alternative)
3+
import Prelude (Unit)
4+
import Control.Alternative (class Alternative)
55
import Data.Map as M
66

77
class (Alternative f) <= MatchClass f where

src/Routing/Parser.purs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@ module Routing.Parser (
22
parse
33
) where
44

5-
import Prelude
5+
import Prelude (map, bind, (>>>), ($), (<<<), (==), (<*>), (<$>), (<=))
6+
import Routing.Types (Route, RoutePart(..))
7+
import Data.Array as A
8+
import Data.Map as M
9+
import Data.String as S
610
import Control.MonadPlus (guard)
7-
import Data.Maybe (Maybe(), fromMaybe)
8-
import Data.Tuple (Tuple(..))
9-
import Data.List (toList, List())
11+
import Data.List (fromFoldable, List)
12+
import Data.Maybe (Maybe, fromMaybe)
1013
import Data.Traversable (traverse)
11-
import qualified Data.Map as M
12-
import qualified Data.String as S
13-
import qualified Data.Array as A
14-
15-
import Routing.Types
14+
import Data.Tuple (Tuple(..))
1615

1716
-- | Parse part of hash. Will return `Query (Map String String)` for query
1817
-- | i.e. `"?foo=bar&bar=baz"` -->
@@ -24,7 +23,7 @@ parsePart str = fromMaybe (Path str) do
2423
$ traverse part2tuple parts
2524
where
2625
parts :: List String
27-
parts = toList $ S.split "&" $ S.drop 1 str
26+
parts = fromFoldable $ S.split "&" $ S.drop 1 str
2827

2928
part2tuple :: String -> Maybe (Tuple String String)
3029
part2tuple input = do
@@ -37,4 +36,4 @@ parsePart str = fromMaybe (Path str) do
3736
-- | applied to every hash part (usually `decodeURIComponent`)
3837
parse :: (String -> String) -> String -> Route
3938
parse decoder hash =
40-
map ( decoder >>> parsePart ) $ toList (S.split "/" hash)
39+
map ( decoder >>> parsePart ) $ fromFoldable (S.split "/" hash)

test/Test/Main.purs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
module Test.Main where
22

3-
import Prelude
4-
import Control.Monad.Eff
5-
import Control.Monad.Eff.Console
6-
import Control.Alt
7-
import Control.Apply
8-
import Data.List
3+
import Prelude (class Show, Unit, show, ($), (<$>), (*>), (<*>), (<>))
4+
import Control.Monad.Eff (Eff)
5+
import Control.Monad.Eff.Console (CONSOLE(), logShow)
6+
import Control.Alt ((<|>))
7+
import Data.List (List)
98
import Data.Map as M
109

1110

12-
import Routing
13-
import Routing.Match
14-
import Routing.Match.Class
11+
import Routing (matchHash)
12+
import Routing.Match (Match, list)
13+
import Routing.Match.Class (num, param, bool, lit, params)
1514

1615
data FooBar = Foo Number (M.Map String String) | Bar Boolean String | Baz (List Number)
1716

@@ -29,7 +28,10 @@ routing =
2928

3029
main :: Eff (console :: CONSOLE) Unit
3130
main = do
32-
print $ matchHash routing "foo/12/?welp='hi'&b=false"
33-
matches routing $ \old new -> void do
34-
print old
35-
print new
31+
logShow $ matchHash routing "foo/12/?welp='hi'&b=false"
32+
33+
-- (minimal test for browser)
34+
35+
-- matches routing $ \old new -> void do
36+
-- logShow old
37+
-- logShow new

0 commit comments

Comments
 (0)