module Gamgine.Zipper where
import qualified Data.List as L
import qualified Data.List.Zipper as LZ
before :: LZ.Zipper a -> LZ.Zipper a
before (LZ.Zip [] _) = LZ.empty
before (LZ.Zip (a:ls) _) = LZ.Zip ls [a]
after :: LZ.Zipper a -> LZ.Zipper a
after (LZ.Zip _ []) = LZ.empty
after (LZ.Zip _ (a:rs)) = LZ.Zip [] rs
current :: LZ.Zipper a -> a
current = LZ.cursor
previous :: LZ.Zipper a -> a
previous (LZ.Zip (p:ls) _) = p
next :: LZ.Zipper a -> a
next (LZ.Zip _ (c:n:_)) = n
atLast :: LZ.Zipper a -> Bool
atLast (LZ.Zip _ (a:[])) = True
atLast _ = False
atFirst :: LZ.Zipper a -> Bool
atFirst (LZ.Zip [] (a:ls)) = True
atFirst _ = False