-- | Seek to the left for a location matching a predicate, starting from the
-- current one.
--
-- -- /Tip:/ Use `break`
--
-- prop> findLeft (const True) -<< fromList xs == fromList xs
--
-- prop> findLeft (const False) (zipper l x r) == IsNotZ
--
-- >>> findLeft (== 1) (zipper [2, 1] 3 [4, 5])
-- [] >1< [2,3,4,5]
--
-- >>> findLeft (== 1) (zipper [2, 1] 1 [4, 5])
-- [] >1< [2,1,4,5]
findLeft :: (a -> Bool) -> ListZipper a -> MaybeListZipper a
findLeft p (ListZipper l x r) =
case break p l of
(_,Nil) -> IsNotZ
(l',h :. t) ->
IsZ $
ListZipper t
h
(reverse l' ++ x :. r)