diff --git a/marlowe-playground-client/src/Contrib/Data/Unfoldable.purs b/marlowe-playground-client/src/Contrib/Data/Unfoldable.purs index 024d9c7ceb..6a84a56ffa 100644 --- a/marlowe-playground-client/src/Contrib/Data/Unfoldable.purs +++ b/marlowe-playground-client/src/Contrib/Data/Unfoldable.purs @@ -21,7 +21,7 @@ move -> f a -> Maybe (g a) move { from, to } foldable = do - when (to > length foldable) + when (to < 0 || to > length foldable) Nothing let foldStep idx elem acc @@ -30,17 +30,11 @@ move { from, to } foldable = do { elem, items } = foldrWithIndex foldStep { elem: Nothing, items: List.Nil } foldable - let - unfoldStep seed@{ idx, elem, items } = do - let - idx' = idx + 1 - - result - | idx == to = Just (elem /\ seed { idx = idx' }) - | otherwise = do + unfoldStep seed@{ idx, elem, items } + | idx == to = Just (elem /\ seed { idx = idx + 1 }) + | otherwise = do { head, tail } <- List.uncons items - Just (head /\ seed { idx = idx', items = tail }) - result + Just (head /\ seed { idx = idx + 1, items = tail }) -- | There is no UnfoldableWithIndex unfortunatelly... yet: -- | https://github.com/purescript/purescript-foldable-traversable/issues/84 -- | so we have to carry the index ourselves. diff --git a/marlowe-playground-client/src/Contrib/Halogen/Components/Sortable.purs b/marlowe-playground-client/src/Contrib/Halogen/Components/Sortable.purs index 523dc889ac..7fc5c0fdcd 100644 --- a/marlowe-playground-client/src/Contrib/Halogen/Components/Sortable.purs +++ b/marlowe-playground-client/src/Contrib/Halogen/Components/Sortable.purs @@ -31,8 +31,8 @@ nextVersion :: OrderingVersion -> OrderingVersion nextVersion (OrderingVersion i) = OrderingVersion (i + 1) -- | We have to keep ordering version because sorting can trigger --- | reordering which assynchronously is repainted. If in between --- | we trigger some other reordering it is going to be inconsisten +-- | reordering which asynchronously is repainted. If in between +-- | we trigger some other reordering it is going to be inconsistent -- | with the new one so we have to ignore all events till everything is -- | repainted type State