Skip to content

Commit

Permalink
applied suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
klntsky committed Apr 4, 2019
1 parent 6567bb8 commit 8882669
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Data/Array/ST.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ exports.popImpl = function (just) {
return function (nothing) {
return function (xs) {
return function () {
return xs.length ? just(xs.pop()) : nothing;
return xs.length > 0 ? just(xs.pop()) : nothing;
};
};
};
Expand All @@ -50,7 +50,7 @@ exports.shiftImpl = function (just) {
return function (nothing) {
return function (xs) {
return function () {
return xs.length ? just(xs.shift()) : nothing;
return xs.length > 0 ? just(xs.shift()) : nothing;
};
};
};
Expand Down
14 changes: 12 additions & 2 deletions src/Data/Array/ST.purs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,12 @@ sort = sortBy compare
shift :: forall h a. STArray h a -> ST h (Maybe a)
shift = shiftImpl Just Nothing

foreign import shiftImpl :: forall h a. (a -> Maybe a) -> Maybe a -> STArray h a -> ST h (Maybe a)
foreign import shiftImpl
:: forall h a
. (forall b. b -> Maybe b)
-> (forall b. Maybe b)
-> STArray h a
-> ST h (Maybe a)

-- | Sort a mutable array in place using a comparison function.
sortBy
Expand Down Expand Up @@ -150,7 +155,12 @@ foreign import poke :: forall h a. Int -> a -> STArray h a -> ST h Boolean
pop :: forall h a. STArray h a -> ST h (Maybe a)
pop = popImpl Just Nothing

foreign import popImpl :: forall h a. (a -> Maybe a) -> Maybe a -> STArray h a -> ST h (Maybe a)
foreign import popImpl
:: forall h a
. (forall b. b -> Maybe b)
-> (forall b. Maybe b)
-> STArray h a
-> ST h (Maybe a)

-- | Append an element to the end of a mutable array. Returns the new length of
-- | the array.
Expand Down

0 comments on commit 8882669

Please sign in to comment.