Skip to content

Compiler/0.12 #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@ language: node_js
dist: trusty
sudo: required
node_js: stable
env:
- PATH=$HOME/purescript:$PATH
install:
- npm install -g bower
- 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')
- wget -O $HOME/purescript.tar.gz https://github.com/purescript/purescript/releases/download/$TAG/linux64.tar.gz
- tar -xvf $HOME/purescript.tar.gz -C $HOME/
- chmod a+x $HOME/purescript
- npm install
- bower install
- bower install --production
script:
- npm run -s build
- bower install
- npm run -s test
after_success:
- >-
test $TRAVIS_TAG &&
Expand Down
14 changes: 7 additions & 7 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
"package.json"
],
"dependencies": {
"purescript-maybe": "^3.0.0",
"purescript-foldable-traversable": "^3.0.0",
"purescript-strings": "^3.0.0"
"purescript-maybe": "^4.0.0",
"purescript-foldable-traversable": "^4.0.0",
"purescript-strings": "^4.0.0"
},
"devDependencies": {
"purescript-console": "^3.0.0",
"purescript-spec": "^0.13.0",
"purescript-random": "^3.0.0",
"purescript-quickcheck": "^4.0.0"
"purescript-console": "^4.0.0",
"purescript-spec": "^3.0.0",
"purescript-random": "^4.0.0",
"purescript-quickcheck": "^5.0.0"
}
}
10 changes: 5 additions & 5 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 && pulp test"
"build": "pulp build -- --censor-lib --strict",
"test": "pulp test"
},
"devDependencies": {
"pulp": "^11.0.0",
"purescript-psa": "^0.5.0",
"purescript": "^0.11.1",
"rimraf": "^2.5.4"
"pulp": "^12.2.0",
"purescript-psa": "^0.6.0",
"rimraf": "^2.6.2"
}
}
5 changes: 5 additions & 0 deletions src/Data/Char/Unicode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
exports.withCharCode = function(f) {
return function (c) {
return String.fromCharCode(f(c.charCodeAt()));
}
}
67 changes: 48 additions & 19 deletions src/Data/Char/Unicode.purs
Original file line number Diff line number Diff line change
@@ -1,22 +1,45 @@

module Data.Char.Unicode where
module Data.Char.Unicode
( -- Predicates
isAscii
, isAsciiLower
, isAsciiUpper
, isLatin1
, isLower
, isUpper
, isAlpha
, isAlphaNum
, isLetter
, isDigit
, isOctDigit
, isHexDigit
, isControl
, isPrint
, isSpace
, isSymbol
, isSeparator
, isPunctuation
, isMark
, isNumber

, digitToInt

-- Case conversion
, toLower
, toUpper
, toTitle

-- Unicode General Categories
, GeneralCategory(..)
, unicodeCatToGeneralCat
, generalCatToInt
, generalCatToUnicodeCat
, generalCategory
) where

import Prelude

import Data.Char (fromCharCode, toCharCode)
import Data.Char.Unicode.Internal ( UnicodeCategory(..)
, uTowtitle
, uTowlower
, uTowupper
, uIswalnum
, uIswalpha
, uIswlower
, uIswupper
, uIswspace
, uIswprint
, uIswcntrl
, uGencat
)
import Data.Char (toCharCode)
import Data.Char.Unicode.Internal (UnicodeCategory(..), uTowtitle, uTowlower, uTowupper, uIswalnum, uIswalpha, uIswlower, uIswupper, uIswspace, uIswprint, uIswcntrl, uGencat)
import Data.Maybe (Maybe(..))

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

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

-- | Convert a letter to the corresponding title-case or upper-case
-- | letter, if any. (Title case differs from upper case only for a small
-- | number of ligature letters.)
-- | Any other character is returned unchanged.
toTitle :: Char -> Char
toTitle = fromCharCode <<< uTowtitle <<< toCharCode
toTitle = withCharCode uTowtitle

-- | We define this via the FFI because we want to avoid the
-- | dictionary overhead of going via Enum, and because we're certain
-- | that the Unicode table we used to generate these conversions
-- | doesn't generate char codes outside the valid range.
foreign import withCharCode :: (Int -> Int) -> Char -> Char

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