Skip to content

Update to v0.14.0-rc3 #181

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 5 commits into from
Nov 6, 2020
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
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ node_js: stable
env:
- PATH=$HOME/purescript:$PATH
install:
- TAG=$(basename $(curl --location --silent --output /dev/null -w %{url_effective} https://github.com/purescript/purescript/releases/latest))
# - TAG=$(basename $(curl --location --silent --output /dev/null -w %{url_effective} https://github.com/purescript/purescript/releases/latest))
- TAG=v0.14.0-rc3
- curl --location --output $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
Expand Down
30 changes: 15 additions & 15 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@
"package.json"
],
"dependencies": {
"purescript-bifunctors": "^4.0.0",
"purescript-control": "^4.0.0",
"purescript-foldable-traversable": "^4.0.0",
"purescript-maybe": "^4.0.0",
"purescript-nonempty": "^5.0.0",
"purescript-partial": "^2.0.0",
"purescript-prelude": "^4.0.0",
"purescript-st": "^4.0.0",
"purescript-tailrec": "^4.0.0",
"purescript-tuples": "^5.0.0",
"purescript-unfoldable": "^4.0.0",
"purescript-unsafe-coerce": "^4.0.0"
"purescript-bifunctors": "master",
"purescript-control": "master",
"purescript-foldable-traversable": "master",
"purescript-maybe": "master",
"purescript-nonempty": "master",
"purescript-partial": "master",
"purescript-prelude": "master",
"purescript-st": "master",
"purescript-tailrec": "master",
"purescript-tuples": "master",
"purescript-unfoldable": "master",
"purescript-unsafe-coerce": "master"
},
"devDependencies": {
"purescript-assert": "^4.0.0",
"purescript-console": "^4.0.0",
"purescript-const": "^4.0.0"
"purescript-assert": "master",
"purescript-console": "master",
"purescript-const": "master"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"devDependencies": {
"eslint": "^4.19.1",
"pulp": "^15.0.0",
"purescript-psa": "^0.6.0",
"purescript-psa": "^0.8.0",
"rimraf": "^2.6.2"
}
}
12 changes: 11 additions & 1 deletion src/Data/Array/NonEmpty/Internal.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
"use strict";

exports.fold1Impl = function (f) {
exports.foldr1Impl = function (f) {
return function (xs) {
var acc = xs[xs.length - 1];
for (var i = xs.length - 2; i >= 0; i--) {
acc = f(xs[i])(acc);
}
return acc;
};
};

exports.foldl1Impl = function (f) {
return function (xs) {
var acc = xs[0];
var len = xs.length;
Expand Down
7 changes: 5 additions & 2 deletions src/Data/Array/NonEmpty/Internal.purs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ derive newtype instance foldableWithIndexNonEmptyArray :: FoldableWithIndex Int

instance foldable1NonEmptyArray :: Foldable1 NonEmptyArray where
foldMap1 = foldMap1Default
fold1 = fold1Impl (<>)
fold1 = foldl1Impl (<>)
foldr1 = foldr1Impl
foldl1 = foldl1Impl

derive newtype instance unfoldable1NonEmptyArray :: Unfoldable1 NonEmptyArray
derive newtype instance traversableNonEmptyArray :: Traversable NonEmptyArray
Expand All @@ -56,7 +58,8 @@ derive newtype instance monadNonEmptyArray :: Monad NonEmptyArray
derive newtype instance altNonEmptyArray :: Alt NonEmptyArray

-- we use FFI here to avoid the unncessary copy created by `tail`
foreign import fold1Impl :: forall a. (a -> a -> a) -> NonEmptyArray a -> a
foreign import foldr1Impl :: forall a. (a -> a -> a) -> NonEmptyArray a -> a
foreign import foldl1Impl :: forall a. (a -> a -> a) -> NonEmptyArray a -> a

foreign import traverse1Impl
:: forall m a b
Expand Down
4 changes: 3 additions & 1 deletion src/Data/Array/ST.purs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module Data.Array.ST
import Prelude

import Control.Monad.ST as ST
import Control.Monad.ST (ST, kind Region)
import Control.Monad.ST (ST, Region)
import Data.Maybe (Maybe(..))

-- | A reference to a mutable array.
Expand All @@ -43,6 +43,8 @@ import Data.Maybe (Maybe(..))
-- | except that mutation is allowed.
foreign import data STArray :: Region -> Type -> Type

type role STArray nominal representational

-- | An element and its index.
type Assoc a = { value :: a, index :: Int }

Expand Down
18 changes: 14 additions & 4 deletions test/Test/Data/Array/NonEmpty.purs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Data.FunctorWithIndex (mapWithIndex)
import Data.Maybe (Maybe(..), fromJust)
import Data.Monoid.Additive (Additive(..))
import Data.NonEmpty ((:|))
import Data.Semigroup.Foldable (foldMap1)
import Data.Semigroup.Foldable (foldMap1, foldr1, foldl1)
import Data.Semigroup.Traversable (traverse1)
import Data.Tuple (Tuple(..))
import Data.Unfoldable1 as U1
Expand Down Expand Up @@ -305,12 +305,22 @@ testNonEmptyArray = do
log "Unfoldable instance"
assert $ U1.range 0 9 == NEA.range 0 9

log "foldl should work"
log "foldMap1 should work"
assert $ foldMap1 Additive (fromArray [1, 2, 3, 4]) == Additive 10

log "fold1 should work"
-- test through sum
assert $ sum (fromArray [1, 2, 3, 4]) == 10

log "foldMap1 should work"
assert $ foldMap1 Additive (fromArray [1, 2, 3, 4]) == Additive 10
log "foldr1 should work"
assert $ foldr1 (\l r -> "(" <> l <> r <> ")") (fromArray ["a", "b", "c", "d"]) == "(a(b(cd)))"
assert $ foldr1 (\l r -> "(" <> l <> r <> ")") (fromArray ["a", "b"]) == "(ab)"
assert $ foldr1 (\l r -> "(" <> l <> r <> ")") (fromArray ["a"]) == "a"

log "foldl1 should work"
assert $ foldl1 (\l r -> "(" <> l <> r <> ")") (fromArray ["a", "b", "c", "d"]) == "(((ab)c)d)"
assert $ foldl1 (\l r -> "(" <> l <> r <> ")") (fromArray ["a", "b"]) == "(ab)"
assert $ foldl1 (\l r -> "(" <> l <> r <> ")") (fromArray ["a"]) == "a"

log "traverse1 should work"
assert $ traverse1 Just (fromArray [1, 2, 3, 4]) == NEA.fromArray [1, 2, 3, 4]
Expand Down