From 88826690a292c255d8ed7260e0118bad40eb9607 Mon Sep 17 00:00:00 2001 From: 8084 Date: Thu, 4 Apr 2019 05:48:58 +0300 Subject: [PATCH] applied suggestions --- src/Data/Array/ST.js | 4 ++-- src/Data/Array/ST.purs | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Data/Array/ST.js b/src/Data/Array/ST.js index 4dc6f484..38487691 100644 --- a/src/Data/Array/ST.js +++ b/src/Data/Array/ST.js @@ -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; }; }; }; @@ -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; }; }; }; diff --git a/src/Data/Array/ST.purs b/src/Data/Array/ST.purs index cda10a06..0113a990 100644 --- a/src/Data/Array/ST.purs +++ b/src/Data/Array/ST.purs @@ -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 @@ -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.