Skip to content

Commit e40287e

Browse files
authored
Merge pull request #10 from purescript-contrib/compiler/0.12
Compiler/0.12
2 parents 8cba25f + 7ddb832 commit e40287e

File tree

4 files changed

+28
-31
lines changed

4 files changed

+28
-31
lines changed

.travis.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,17 @@ 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
8-
- bower install
914
script:
15+
- bower install --production
1016
- npm run -s build
1117
after_success:
1218
- >-

bower.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
"package.json"
1515
],
1616
"dependencies": {
17-
"purescript-prelude": "^3.0.0",
18-
"purescript-globals": "^3.0.0",
19-
"purescript-generics": "^4.0.0",
20-
"purescript-maybe": "^3.0.0",
21-
"purescript-strings": "^3.0.0",
22-
"purescript-tuples": "^4.0.0"
17+
"purescript-globals": "^4.0.0",
18+
"purescript-maybe": "^4.0.0",
19+
"purescript-newtype": "^3.0.0",
20+
"purescript-prelude": "^4.0.0",
21+
"purescript-strings": "^4.0.0",
22+
"purescript-tuples": "^5.0.0"
2323
}
2424
}

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55
"build": "pulp build -- --censor-lib --strict"
66
},
77
"devDependencies": {
8-
"pulp": "^11.0.0",
9-
"purescript-psa": "^0.5.0",
10-
"purescript": "^0.11.1",
11-
"rimraf": "^2.6.1"
8+
"pulp": "^12.2.0",
9+
"purescript-psa": "^0.6.0",
10+
"rimraf": "^2.6.2"
1211
}
1312
}

src/Data/FormURLEncoded.purs

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,15 @@
1-
module Data.FormURLEncoded
2-
( FormURLEncoded(FormURLEncoded)
3-
, fromArray
4-
, toArray
5-
, encode
6-
) where
1+
module Data.FormURLEncoded where
2+
3+
import Prelude
74

8-
import Data.Newtype (class Newtype)
9-
import Data.Generic (class Generic)
105
import Data.Maybe (Maybe(..))
11-
import Data.Monoid (class Monoid)
12-
import Data.Semigroup (class Semigroup)
6+
import Data.Newtype (class Newtype)
137
import Data.String (joinWith) as String
148
import Data.Tuple (Tuple(..))
15-
import Global (encodeURIComponent)
16-
import Prelude (class Show, class Ord, class Eq, map, (<<<), (<>))
9+
import Global.Unsafe (unsafeEncodeURIComponent)
1710

1811
-- | `FormURLEncoded` is an ordered list of key-value pairs with possible duplicates.
19-
newtype FormURLEncoded
20-
= FormURLEncoded
21-
(Array (Tuple String (Maybe String)))
12+
newtype FormURLEncoded = FormURLEncoded (Array (Tuple String (Maybe String)))
2213

2314
-- | Construct `FormURLEncoded` from an `Array` of key-value pairs.
2415
fromArray :: Array (Tuple String (Maybe String)) -> FormURLEncoded
@@ -28,18 +19,19 @@ fromArray = FormURLEncoded
2819
toArray :: FormURLEncoded -> Array (Tuple String (Maybe String))
2920
toArray (FormURLEncoded a) = a
3021

31-
derive instance genericFormUrlEncoded :: Generic FormURLEncoded
3222
derive instance newtypeFormUrlEncoded :: Newtype FormURLEncoded _
3323
derive newtype instance eqFormUrlEncoded :: Eq FormURLEncoded
3424
derive newtype instance ordFormUrlEncoded :: Ord FormURLEncoded
35-
derive newtype instance showFormUrlEncoded :: Show FormURLEncoded
3625
derive newtype instance semigroupFormUrlEncoded :: Semigroup FormURLEncoded
3726
derive newtype instance monoidFormUrlEncoded :: Monoid FormURLEncoded
3827

28+
instance showFormUrlEncoded :: Show FormURLEncoded where
29+
show (FormURLEncoded kvs) = "(FormURLEncoded " <> show kvs <> ")"
30+
3931
-- | Encode `FormURLEncoded` as `application/x-www-form-urlencoded`.
4032
encode :: FormURLEncoded -> String
4133
encode = String.joinWith "&" <<< map encodePart <<< toArray
4234
where
43-
encodePart (Tuple k Nothing) = encodeURIComponent k
44-
encodePart (Tuple k (Just v)) =
45-
encodeURIComponent k <> "=" <> encodeURIComponent v
35+
encodePart = case _ of
36+
Tuple k Nothing -> unsafeEncodeURIComponent k
37+
Tuple k (Just v) -> unsafeEncodeURIComponent k <> "=" <> unsafeEncodeURIComponent v

0 commit comments

Comments
 (0)