Skip to content

Commit

Permalink
Improve coding style
Browse files Browse the repository at this point in the history
Co-authored-by: Pablo Lamela  <pablo.lamela@iohk.io>
  • Loading branch information
paluh and palas committed Jan 18, 2022
1 parent 5c956c3 commit 1160b30
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
16 changes: 5 additions & 11 deletions marlowe-playground-client/src/Contrib/Data/Unfoldable.purs
Expand Up @@ -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
Expand All @@ -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.
Expand Down
Expand Up @@ -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
Expand Down

0 comments on commit 1160b30

Please sign in to comment.