diff --git a/.gitignore b/.gitignore index 05b31c8..38d9e05 100644 --- a/.gitignore +++ b/.gitignore @@ -14,5 +14,7 @@ yarn.lock /node_modules/ /output/ /tmp/ +/.psc-package/ .psc-ide-port + diff --git a/bower.json b/bower.json index ba0167a..9fb0b06 100644 --- a/bower.json +++ b/bower.json @@ -20,17 +20,17 @@ "url": "git://github.com/purescript-contrib/purescript-string-extras.git" }, "dependencies": { - "purescript-strings": "^3.3.1", - "purescript-prelude": "^3.1.0", - "purescript-maybe": "^3.0.0", - "purescript-partial": "^1.2.1", - "purescript-either": "^3.1.0", - "purescript-foldable-traversable": "^3.6.1", - "purescript-unicode": "^3.0.1", - "purescript-arrays": "^4.2.0" + "purescript-strings": "^4.0.0", + "purescript-prelude": "^4.0.0", + "purescript-maybe": "^4.0.0", + "purescript-partial": "^2.0.0", + "purescript-either": "^4.0.0", + "purescript-foldable-traversable": "^4.0.0", + "purescript-unicode": "^4.0.0", + "purescript-arrays": "^5.0.0" }, "devDependencies": { - "purescript-assert": "^3.0.0", - "purescript-console": "^3.0.0" + "purescript-assert": "^4.0.0", + "purescript-console": "^4.1.0" } } diff --git a/package.json b/package.json index 7daf55a..cfd3acf 100644 --- a/package.json +++ b/package.json @@ -6,9 +6,9 @@ "test": "pulp test" }, "devDependencies": { - "pulp": "^12.0.1", - "purescript": "^0.11.6", - "purescript-psa": "^0.5.1", + "pulp": "^12.3.0", + "purescript": "^0.12.0", + "purescript-psa": "^0.6.0", "rimraf": "^2.6.2" } } diff --git a/psc-package.json b/psc-package.json new file mode 100644 index 0000000..746e75d --- /dev/null +++ b/psc-package.json @@ -0,0 +1,17 @@ +{ + "name": "purescript-strings-extra", + "set": "psc-0.12.0", + "source": "https://github.com/purescript/package-sets.git", + "depends": [ + "console", + "assert", + "arrays", + "unicode", + "foldable-traversable", + "either", + "partial", + "maybe", + "strings", + "prelude" + ] +} diff --git a/src/Data/String/Extra.purs b/src/Data/String/Extra.purs index 01ad36f..e2895de 100644 --- a/src/Data/String/Extra.purs +++ b/src/Data/String/Extra.purs @@ -7,10 +7,12 @@ module Data.String.Extra ) where import Data.Array as Array +import Data.Array.NonEmpty as NonEmptyArray import Data.Char.Unicode as Unicode import Data.Either (fromRight) import Data.Foldable (foldMap) import Data.String as String +import Data.String.CodeUnits as SCU import Data.String.Regex (Regex) import Data.String.Regex as Regex import Data.String.Regex.Flags as Flags @@ -66,8 +68,8 @@ words string = upfirst :: String -> String upfirst = - String.uncons >>> foldMap \{ head, tail } -> - String.singleton (Unicode.toUpper head) <> toUnicodeLower tail + SCU.uncons >>> foldMap \{ head, tail } -> + SCU.singleton (Unicode.toUpper head) <> toUnicodeLower tail regexGlobal :: String -> Regex regexGlobal regexStr = @@ -76,7 +78,7 @@ regexGlobal regexStr = asciiWords :: String -> Array String asciiWords = Regex.match (regexGlobal "[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+") - >>> foldMap Array.catMaybes + >>> foldMap NonEmptyArray.catMaybes hasUnicodeWords :: String -> Boolean hasUnicodeWords = @@ -84,15 +86,15 @@ hasUnicodeWords = toUnicodeLower :: String -> String toUnicodeLower = - String.toCharArray >>> map Unicode.toLower >>> String.fromCharArray + SCU.toCharArray >>> map Unicode.toLower >>> SCU.fromCharArray toUnicodeUpper :: String -> String toUnicodeUpper = - String.toCharArray >>> map Unicode.toUpper >>> String.fromCharArray + SCU.toCharArray >>> map Unicode.toUpper >>> SCU.fromCharArray unicodeWords :: String -> Array String unicodeWords = - Regex.match (regexGlobal regexStr) >>> foldMap Array.catMaybes + Regex.match (regexGlobal regexStr) >>> foldMap NonEmptyArray.catMaybes where -- https://github.com/lodash/lodash/blob/master/.internal/unicodeWords.js -- Used to compose unicode character classes. diff --git a/test/Main.purs b/test/Main.purs index c8e964f..f4e3ff6 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -1,12 +1,12 @@ module Test.Main where -import Control.Monad.Eff (Eff) -import Control.Monad.Eff.Console (CONSOLE, log) import Data.String.Extra as String +import Effect (Effect) +import Effect.Console (log) import Prelude (Unit, ($), (==), (*>), discard) -import Test.Assert (ASSERT, assert) +import Test.Assert (assert) -main :: forall eff. Eff (assert :: ASSERT, console :: CONSOLE | eff) Unit +main :: Effect Unit main = do log "camelCase" *> do assert $ String.camelCase "" == ""