Skip to content

Commit 84b77fb

Browse files
authored
Merge pull request #18 from purescript-contrib/compiler/0.12
Compiler/0.12
2 parents bdaf3a8 + ff1c20d commit 84b77fb

File tree

7 files changed

+143
-128
lines changed

7 files changed

+143
-128
lines changed

.travis.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,20 @@ language: node_js
22
dist: trusty
33
sudo: required
44
node_js: stable
5+
env:
6+
- PATH=$HOME/purescript:$PATH
57
install:
68
- npm install -g bower
9+
- 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')
10+
- wget -O $HOME/purescript.tar.gz https://github.com/purescript/purescript/releases/download/$TAG/linux64.tar.gz
11+
- tar -xvf $HOME/purescript.tar.gz -C $HOME/
12+
- chmod a+x $HOME/purescript
713
- npm install
8-
- bower install
14+
- bower install --production
915
script:
1016
- npm run -s build
17+
- bower install
18+
- npm run -s test
1119
after_success:
1220
- >-
1321
test $TRAVIS_TAG &&

bower.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
"package.json"
2020
],
2121
"dependencies": {
22-
"purescript-maybe": "^3.0.0",
23-
"purescript-foldable-traversable": "^3.0.0",
24-
"purescript-strings": "^3.0.0"
22+
"purescript-maybe": "^4.0.0",
23+
"purescript-foldable-traversable": "^4.0.0",
24+
"purescript-strings": "^4.0.0"
2525
},
2626
"devDependencies": {
27-
"purescript-console": "^3.0.0",
28-
"purescript-spec": "^0.13.0",
29-
"purescript-random": "^3.0.0",
30-
"purescript-quickcheck": "^4.0.0"
27+
"purescript-console": "^4.0.0",
28+
"purescript-spec": "^3.0.0",
29+
"purescript-random": "^4.0.0",
30+
"purescript-quickcheck": "^5.0.0"
3131
}
3232
}

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
"private": true,
33
"scripts": {
44
"clean": "rimraf output && rimraf .pulp-cache",
5-
"build": "pulp build && pulp test"
5+
"build": "pulp build -- --censor-lib --strict",
6+
"test": "pulp test"
67
},
78
"devDependencies": {
8-
"pulp": "^11.0.0",
9-
"purescript-psa": "^0.5.0",
10-
"purescript": "^0.11.1",
11-
"rimraf": "^2.5.4"
9+
"pulp": "^12.2.0",
10+
"purescript-psa": "^0.6.0",
11+
"rimraf": "^2.6.2"
1212
}
1313
}

src/Data/Char/Unicode.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
exports.withCharCode = function(f) {
2+
return function (c) {
3+
return String.fromCharCode(f(c.charCodeAt()));
4+
}
5+
}

src/Data/Char/Unicode.purs

Lines changed: 48 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,45 @@
1-
2-
module Data.Char.Unicode where
1+
module Data.Char.Unicode
2+
( -- Predicates
3+
isAscii
4+
, isAsciiLower
5+
, isAsciiUpper
6+
, isLatin1
7+
, isLower
8+
, isUpper
9+
, isAlpha
10+
, isAlphaNum
11+
, isLetter
12+
, isDigit
13+
, isOctDigit
14+
, isHexDigit
15+
, isControl
16+
, isPrint
17+
, isSpace
18+
, isSymbol
19+
, isSeparator
20+
, isPunctuation
21+
, isMark
22+
, isNumber
23+
24+
, digitToInt
25+
26+
-- Case conversion
27+
, toLower
28+
, toUpper
29+
, toTitle
30+
31+
-- Unicode General Categories
32+
, GeneralCategory(..)
33+
, unicodeCatToGeneralCat
34+
, generalCatToInt
35+
, generalCatToUnicodeCat
36+
, generalCategory
37+
) where
338

439
import Prelude
540

6-
import Data.Char (fromCharCode, toCharCode)
7-
import Data.Char.Unicode.Internal ( UnicodeCategory(..)
8-
, uTowtitle
9-
, uTowlower
10-
, uTowupper
11-
, uIswalnum
12-
, uIswalpha
13-
, uIswlower
14-
, uIswupper
15-
, uIswspace
16-
, uIswprint
17-
, uIswcntrl
18-
, uGencat
19-
)
41+
import Data.Char (toCharCode)
42+
import Data.Char.Unicode.Internal (UnicodeCategory(..), uTowtitle, uTowlower, uTowupper, uIswalnum, uIswalpha, uIswlower, uIswupper, uIswspace, uIswprint, uIswcntrl, uGencat)
2043
import Data.Maybe (Maybe(..))
2144

2245
-- | Unicode General Categories (column 2 of the UnicodeData table) in
@@ -479,19 +502,25 @@ isSymbol c =
479502
-- | Convert a letter to the corresponding upper-case letter, if any.
480503
-- | Any other character is returned unchanged.
481504
toUpper :: Char -> Char
482-
toUpper = fromCharCode <<< uTowupper <<< toCharCode
505+
toUpper = withCharCode uTowupper
483506

484507
-- | Convert a letter to the corresponding lower-case letter, if any.
485508
-- | Any other character is returned unchanged.
486509
toLower :: Char -> Char
487-
toLower = fromCharCode <<< uTowlower <<< toCharCode
510+
toLower = withCharCode uTowlower
488511

489512
-- | Convert a letter to the corresponding title-case or upper-case
490513
-- | letter, if any. (Title case differs from upper case only for a small
491514
-- | number of ligature letters.)
492515
-- | Any other character is returned unchanged.
493516
toTitle :: Char -> Char
494-
toTitle = fromCharCode <<< uTowtitle <<< toCharCode
517+
toTitle = withCharCode uTowtitle
518+
519+
-- | We define this via the FFI because we want to avoid the
520+
-- | dictionary overhead of going via Enum, and because we're certain
521+
-- | that the Unicode table we used to generate these conversions
522+
-- | doesn't generate char codes outside the valid range.
523+
foreign import withCharCode :: (Int -> Int) -> Char -> Char
495524

496525
-- | Convert a single digit `Char` to the corresponding `Just Int` if its argument
497526
-- | satisfies `isHexDigit`, if it is one of `0..9, A..F, a..f`. Anything else

0 commit comments

Comments
 (0)