Skip to content

Commit

Permalink
Merge pull request #108 from purescript/compiler/0.12
Browse files Browse the repository at this point in the history
Updates for PureScript 0.12
  • Loading branch information
garyb authored May 23, 2018
2 parents 6fce657 + b1d4446 commit 80dcf7e
Show file tree
Hide file tree
Showing 37 changed files with 3,463 additions and 2,058 deletions.
38 changes: 22 additions & 16 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
The MIT License (MIT)
Copyright 2018 PureScript

Copyright (c) 2014 PureScript
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
57 changes: 57 additions & 0 deletions bench/Main.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
module Bench.Main where

import Prelude

import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Console (CONSOLE, log)
import Data.Array.NonEmpty (fromArray)
import Data.Maybe (fromJust)
import Data.String (toCharArray)
import Data.String.NonEmpty (fromFoldable1, fromNonEmptyCharArray)
import Partial.Unsafe (unsafePartial)
import Performance.Minibench (benchWith)

main :: Eff (console :: CONSOLE) Unit
main = do
log "NonEmpty conversions"
log "======"
log ""
benchNonEmptyConversions

benchNonEmptyConversions :: Eff (console :: CONSOLE) Unit
benchNonEmptyConversions = do
log "fromNonEmptyCharArray: short"
log "---"
benchFromNonEmptyCharArray
log ""

log "fromFoldable1"
log "---"
benchFromFoldable1
log ""

where

benchFromNonEmptyCharArray = do
log "short string"
bench \_ -> fromNonEmptyCharArray shortStringArr

log "long string"
bench \_ -> fromNonEmptyCharArray longStringArr

benchFromFoldable1 = do
log "short string"
bench \_ -> fromFoldable1 shortStringArr

log "long string"
bench \_ -> fromFoldable1 longStringArr

shortStringArr = unsafePartial fromJust $ fromArray
$ toCharArray "supercalifragilisticexpialidocious"
longStringArr = unsafePartial fromJust $ fromArray
$ toCharArray loremIpsum

bench = benchWith 100000

loremIpsum :: String
loremIpsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut aliquet euismod ligula, vitae lacinia lorem imperdiet nec. Nulla volutpat ullamcorper mollis. Proin interdum quam a sem auctor, id tempus nisl pretium. Suspendisse potenti. Quisque ut libero consequat, suscipit sem a, malesuada nisi. Aliquam dictum odio mi, eu laoreet felis scelerisque non. Ut in odio vehicula, cursus augue sed, tincidunt lorem. Vestibulum consequat lectus eu commodo vulputate. Nam vitae faucibus ipsum. Curabitur sit amet neque sed est sagittis vehicula nec nec risus. Phasellus consectetur cursus malesuada. Vestibulum commodo lorem ut mauris mollis faucibus. Integer ut massa auctor, scelerisque nisi nec, rutrum nisl. Integer vel ex sem. Sed purus felis, molestie eget cursus vel, maximus ut augue. Curabitur nunc ligula, lobortis vitae vehicula a, volutpat nec sem. Phasellus non sapien ipsum. Mauris dolor justo, mollis at elit a, sollicitudin commodo quam. Curabitur posuere felis at nunc pharetra, eu convallis lectus dapibus. Aliquam ullamcorper porta fermentum. Donec at tellus metus. Donec pharetra tempor odio sit amet viverra. Nam vel metus libero. Vivamus maximus quis lacus id pharetra. Duis sed diam molestie, sodales leo id, pulvinar justo. In non augue tempor risus consectetur hendrerit. In libero nulla, elementum non ultrices eu, vehicula non ipsum. Maecenas in hendrerit tellus, sodales dignissim turpis. Ut odio diam, convallis in elit non, consequat gravida nisi. Cras egestas metus eleifend sapien efficitur, vel vulputate est porta. Aliquam posuere, magna nec bibendum luctus, quam risus efficitur sapien, id volutpat metus ex non lorem. Praesent velit eros, efficitur sed tortor quis, lobortis eleifend ligula. Sed tellus quam, aliquet vitae sagittis a, egestas eget massa. Etiam odio elit, hendrerit vel dui vel, fermentum pharetra neque. Curabitur quis mauris id lacus consectetur rhoncus non nec mauris. Mauris blandit tempor pretium. Donec non nisi finibus, lobortis dolor vitae, euismod arcu. Nullam scelerisque lacus in dolor volutpat mollis. Nunc vitae consectetur ligula, quis laoreet quam.Proin sit amet nisi eu orci hendrerit imperdiet vitae sit amet leo. Donec sodales id ante eget viverra. Nullam vitae elit in mauris accumsan feugiat id a velit. Nulla facilisi. Cras in turpis efficitur, consectetur justo quis, suscipit tortor. Sed tincidunt pellentesque sapien, in ultricies eros rhoncus sit amet. Integer blandit ornare lobortis. Duis dictum sit amet mauris sit amet cursus. Nullam nec nisl mauris. Praesent cursus imperdiet mi mattis luctus. Donec in tortor fermentum, efficitur turpis vel, facilisis augue. Integer egestas nisl et magna volutpat ornare. Donec pulvinar risus elit, eget viverra est feugiat in.Ut nec ante vestibulum neque pulvinar pretium sit amet eu nisi. Aliquam erat volutpat. Maecenas egestas nisi et mi congue, sed ultricies nibh posuere. Suspendisse potenti. Donec a nulla et velit elementum pretium. Pellentesque gravida imperdiet sem et varius. Praesent ac diam diam. Donec iaculis risus ex, ac eleifend sapien luctus ut. Fusce aliquet, lacus tincidunt porta malesuada, massa augue commodo nulla, ac malesuada tortor est sed eros. Praesent mattis, nisi eget ullamcorper vestibulum, lacus ante placerat metus, ac ullamcorper ante tellus vel nulla. Praesent vehicula in est sit amet varius. Sed facilisis felis sed sem porttitor rutrum. Etiam sollicitudin erat neque, id gravida metus scelerisque quis. Proin venenatis pharetra lectus ac auctor."
31 changes: 20 additions & 11 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"name": "purescript-strings",
"homepage": "https://github.com/purescript/purescript-strings",
"description": "String and char utility functions, regular expressions.",
"license": "MIT",
"license": "BSD-3-Clause",
"repository": {
"type": "git",
"url": "git://github.com/purescript/purescript-strings.git"
Expand All @@ -17,16 +16,26 @@
"package.json"
],
"dependencies": {
"purescript-either": "^3.0.0",
"purescript-gen": "^1.1.0",
"purescript-maybe": "^3.0.0",
"purescript-partial": "^1.2.0",
"purescript-unfoldable": "^3.0.0",
"purescript-arrays": "^4.0.1",
"purescript-integers": "^3.2.0"
"purescript-arrays": "^5.0.0",
"purescript-control": "^4.0.0",
"purescript-either": "^4.0.0",
"purescript-enums": "^4.0.0",
"purescript-foldable-traversable": "^4.0.0",
"purescript-gen": "^2.0.0",
"purescript-integers": "^4.0.0",
"purescript-maybe": "^4.0.0",
"purescript-newtype": "^3.0.0",
"purescript-nonempty": "^5.0.0",
"purescript-partial": "^2.0.0",
"purescript-prelude": "^4.0.0",
"purescript-tailrec": "^4.0.0",
"purescript-tuples": "^5.0.0",
"purescript-unfoldable": "^4.0.0",
"purescript-unsafe-coerce": "^4.0.0"
},
"devDependencies": {
"purescript-assert": "^3.0.0",
"purescript-console": "^3.0.0"
"purescript-assert": "^4.0.0",
"purescript-console": "^4.0.0",
"purescript-minibench": "^2.0.0"
}
}
13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
"scripts": {
"clean": "rimraf output && rimraf .pulp-cache",
"build": "eslint src && pulp build -- --censor-lib --strict",
"test": "pulp test"
"test": "pulp test",
"bench:build": "purs compile 'bench/**/*.purs' 'src/**/*.purs' 'bower_components/*/src/**/*.purs'",
"bench:run": "node --expose-gc -e 'require(\"./output/Bench.Main/index.js\").main()'",
"bench": "npm run bench:build && npm run bench:run"
},
"devDependencies": {
"eslint": "^3.17.1",
"pulp": "^10.0.4",
"purescript-psa": "^0.5.0-rc.1",
"rimraf": "^2.6.1"
"eslint": "^4.19.1",
"pulp": "^12.2.0",
"purescript-psa": "^0.6.0",
"rimraf": "^2.6.2"
}
}
17 changes: 0 additions & 17 deletions src/Data/Char.js

This file was deleted.

21 changes: 9 additions & 12 deletions src/Data/Char.purs
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
-- | A type and functions for single characters.
module Data.Char
( fromCharCode
, toCharCode
, toLower
, toUpper
( toCharCode
, fromCharCode
) where

import Data.Enum (fromEnum, toEnum)
import Data.Maybe (Maybe)

-- | Returns the numeric Unicode value of the character.
foreign import toCharCode :: Char -> Int
toCharCode :: Char -> Int
toCharCode = fromEnum

-- | Constructs a character from the given Unicode numeric value.
foreign import fromCharCode :: Int -> Char

-- | Converts a character to lowercase.
foreign import toLower :: Char -> Char

-- | Converts a character to uppercase.
foreign import toUpper :: Char -> Char
fromCharCode :: Int -> Maybe Char
fromCharCode = toEnum
14 changes: 7 additions & 7 deletions src/Data/Char/Gen.purs
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,33 @@ module Data.Char.Gen where
import Prelude

import Control.Monad.Gen (class MonadGen, chooseInt, oneOf)
import Data.Char as C
import Data.Enum (toEnumWithDefaults)
import Data.NonEmpty ((:|))

-- | Generates a character of the Unicode basic multilingual plane.
genUnicodeChar :: forall m. MonadGen m => m Char
genUnicodeChar = C.fromCharCode <$> chooseInt 0 65536
genUnicodeChar = toEnumWithDefaults bottom top <$> chooseInt 0 65536

-- | Generates a character in the ASCII character set, excluding control codes.
genAsciiChar :: forall m. MonadGen m => m Char
genAsciiChar = C.fromCharCode <$> chooseInt 32 127
genAsciiChar = toEnumWithDefaults bottom top <$> chooseInt 32 127

-- | Generates a character in the ASCII character set.
genAsciiChar' :: forall m. MonadGen m => m Char
genAsciiChar' = C.fromCharCode <$> chooseInt 0 127
genAsciiChar' = toEnumWithDefaults bottom top <$> chooseInt 0 127

-- | Generates a character that is a numeric digit.
genDigitChar :: forall m. MonadGen m => m Char
genDigitChar = C.fromCharCode <$> chooseInt 48 57
genDigitChar = toEnumWithDefaults bottom top <$> chooseInt 48 57

-- | Generates a character from the basic latin alphabet.
genAlpha :: forall m. MonadGen m => m Char
genAlpha = oneOf (genAlphaLowercase :| [genAlphaUppercase])

-- | Generates a lowercase character from the basic latin alphabet.
genAlphaLowercase :: forall m. MonadGen m => m Char
genAlphaLowercase = C.fromCharCode <$> chooseInt 97 122
genAlphaLowercase = toEnumWithDefaults bottom top <$> chooseInt 97 122

-- | Generates an uppercase character from the basic latin alphabet.
genAlphaUppercase :: forall m. MonadGen m => m Char
genAlphaUppercase = C.fromCharCode <$> chooseInt 65 90
genAlphaUppercase = toEnumWithDefaults bottom top <$> chooseInt 65 90
Loading

0 comments on commit 80dcf7e

Please sign in to comment.