{-# LANGUAGE TypeFamilies #-}

module Cursor.Simple.List.NonEmpty
  ( NonEmptyCursor,
    NEC.nonEmptyCursorPrev,
    NEC.nonEmptyCursorCurrent,
    NEC.nonEmptyCursorNext,
    makeNonEmptyCursor,
    makeNonEmptyCursorWithSelection,
    NEC.singletonNonEmptyCursor,
    rebuildNonEmptyCursor,
    mapNonEmptyCursor,
    NEC.nonEmptyCursorElemL,
    nonEmptyCursorSelectPrev,
    nonEmptyCursorSelectNext,
    nonEmptyCursorSelectFirst,
    nonEmptyCursorSelectLast,
    NEC.nonEmptyCursorSelection,
    nonEmptyCursorSelectIndex,
    NEC.nonEmptyCursorInsert,
    NEC.nonEmptyCursorAppend,
    nonEmptyCursorInsertAndSelect,
    nonEmptyCursorAppendAndSelect,
    NEC.nonEmptyCursorInsertAtStart,
    NEC.nonEmptyCursorAppendAtEnd,
    nonEmptyCursorInsertAtStartAndSelect,
    nonEmptyCursorAppendAtEndAndSelect,
    nonEmptyCursorRemoveElemAndSelectPrev,
    nonEmptyCursorDeleteElemAndSelectNext,
    nonEmptyCursorRemoveElem,
    nonEmptyCursorDeleteElem,
    nonEmptyCursorSearch,
    nonEmptyCursorSelectOrAdd,
  )
where

import qualified Cursor.List.NonEmpty as NEC
import Cursor.Types
import Data.List.NonEmpty (NonEmpty (..))

-- | A 'nonempty list' cursor
type NonEmptyCursor a = NEC.NonEmptyCursor a a

makeNonEmptyCursor :: NonEmpty a -> NonEmptyCursor a
makeNonEmptyCursor :: NonEmpty a -> NonEmptyCursor a
makeNonEmptyCursor = (a -> a) -> NonEmpty a -> NonEmptyCursor a
forall b a. (b -> a) -> NonEmpty b -> NonEmptyCursor a b
NEC.makeNonEmptyCursor a -> a
forall a. a -> a
id

makeNonEmptyCursorWithSelection :: Int -> NonEmpty a -> Maybe (NonEmptyCursor a)
makeNonEmptyCursorWithSelection :: Int -> NonEmpty a -> Maybe (NonEmptyCursor a)
makeNonEmptyCursorWithSelection = (a -> a) -> Int -> NonEmpty a -> Maybe (NonEmptyCursor a)
forall b a.
(b -> a) -> Int -> NonEmpty b -> Maybe (NonEmptyCursor a b)
NEC.makeNonEmptyCursorWithSelection a -> a
forall a. a -> a
id

rebuildNonEmptyCursor :: NonEmptyCursor a -> NonEmpty a
rebuildNonEmptyCursor :: NonEmptyCursor a -> NonEmpty a
rebuildNonEmptyCursor = (a -> a) -> NonEmptyCursor a -> NonEmpty a
forall a b. (a -> b) -> NonEmptyCursor a b -> NonEmpty b
NEC.rebuildNonEmptyCursor a -> a
forall a. a -> a
id

mapNonEmptyCursor :: (a -> b) -> NonEmptyCursor a -> NonEmptyCursor b
mapNonEmptyCursor :: (a -> b) -> NonEmptyCursor a -> NonEmptyCursor b
mapNonEmptyCursor a -> b
f = (a -> b) -> (a -> b) -> NonEmptyCursor a -> NonEmptyCursor b
forall a c b d.
(a -> c) -> (b -> d) -> NonEmptyCursor a b -> NonEmptyCursor c d
NEC.mapNonEmptyCursor a -> b
f a -> b
f

nonEmptyCursorSelectPrev :: NonEmptyCursor a -> Maybe (NonEmptyCursor a)
nonEmptyCursorSelectPrev :: NonEmptyCursor a -> Maybe (NonEmptyCursor a)
nonEmptyCursorSelectPrev = (a -> a)
-> (a -> a) -> NonEmptyCursor a -> Maybe (NonEmptyCursor a)
forall a b.
(a -> b)
-> (b -> a) -> NonEmptyCursor a b -> Maybe (NonEmptyCursor a b)
NEC.nonEmptyCursorSelectPrev a -> a
forall a. a -> a
id a -> a
forall a. a -> a
id

nonEmptyCursorSelectNext :: NonEmptyCursor a -> Maybe (NonEmptyCursor a)
nonEmptyCursorSelectNext :: NonEmptyCursor a -> Maybe (NonEmptyCursor a)
nonEmptyCursorSelectNext = (a -> a)
-> (a -> a) -> NonEmptyCursor a -> Maybe (NonEmptyCursor a)
forall a b.
(a -> b)
-> (b -> a) -> NonEmptyCursor a b -> Maybe (NonEmptyCursor a b)
NEC.nonEmptyCursorSelectNext a -> a
forall a. a -> a
id a -> a
forall a. a -> a
id

nonEmptyCursorSelectFirst :: NonEmptyCursor a -> NonEmptyCursor a
nonEmptyCursorSelectFirst :: NonEmptyCursor a -> NonEmptyCursor a
nonEmptyCursorSelectFirst = (a -> a) -> (a -> a) -> NonEmptyCursor a -> NonEmptyCursor a
forall a b.
(a -> b) -> (b -> a) -> NonEmptyCursor a b -> NonEmptyCursor a b
NEC.nonEmptyCursorSelectFirst a -> a
forall a. a -> a
id a -> a
forall a. a -> a
id

nonEmptyCursorSelectLast :: NonEmptyCursor a -> NonEmptyCursor a
nonEmptyCursorSelectLast :: NonEmptyCursor a -> NonEmptyCursor a
nonEmptyCursorSelectLast = (a -> a) -> (a -> a) -> NonEmptyCursor a -> NonEmptyCursor a
forall a b.
(a -> b) -> (b -> a) -> NonEmptyCursor a b -> NonEmptyCursor a b
NEC.nonEmptyCursorSelectLast a -> a
forall a. a -> a
id a -> a
forall a. a -> a
id

nonEmptyCursorSelectIndex :: Int -> NonEmptyCursor a -> Maybe (NonEmptyCursor a)
nonEmptyCursorSelectIndex :: Int -> NonEmptyCursor a -> Maybe (NonEmptyCursor a)
nonEmptyCursorSelectIndex = (a -> a)
-> (a -> a) -> Int -> NonEmptyCursor a -> Maybe (NonEmptyCursor a)
forall a b.
(a -> b)
-> (b -> a)
-> Int
-> NonEmptyCursor a b
-> Maybe (NonEmptyCursor a b)
NEC.nonEmptyCursorSelectIndex a -> a
forall a. a -> a
id a -> a
forall a. a -> a
id

nonEmptyCursorInsertAndSelect :: a -> NonEmptyCursor a -> NonEmptyCursor a
nonEmptyCursorInsertAndSelect :: a -> NonEmptyCursor a -> NonEmptyCursor a
nonEmptyCursorInsertAndSelect = (a -> a) -> a -> NonEmptyCursor a -> NonEmptyCursor a
forall a b.
(a -> b) -> a -> NonEmptyCursor a b -> NonEmptyCursor a b
NEC.nonEmptyCursorInsertAndSelect a -> a
forall a. a -> a
id

nonEmptyCursorAppendAndSelect :: a -> NonEmptyCursor a -> NonEmptyCursor a
nonEmptyCursorAppendAndSelect :: a -> NonEmptyCursor a -> NonEmptyCursor a
nonEmptyCursorAppendAndSelect = (a -> a) -> a -> NonEmptyCursor a -> NonEmptyCursor a
forall a b.
(a -> b) -> a -> NonEmptyCursor a b -> NonEmptyCursor a b
NEC.nonEmptyCursorAppendAndSelect a -> a
forall a. a -> a
id

nonEmptyCursorInsertAtStartAndSelect :: a -> NonEmptyCursor a -> NonEmptyCursor a
nonEmptyCursorInsertAtStartAndSelect :: a -> NonEmptyCursor a -> NonEmptyCursor a
nonEmptyCursorInsertAtStartAndSelect = (a -> a) -> (a -> a) -> a -> NonEmptyCursor a -> NonEmptyCursor a
forall a b.
(a -> b)
-> (b -> a) -> b -> NonEmptyCursor a b -> NonEmptyCursor a b
NEC.nonEmptyCursorInsertAtStartAndSelect a -> a
forall a. a -> a
id a -> a
forall a. a -> a
id

nonEmptyCursorAppendAtEndAndSelect :: a -> NonEmptyCursor a -> NonEmptyCursor a
nonEmptyCursorAppendAtEndAndSelect :: a -> NonEmptyCursor a -> NonEmptyCursor a
nonEmptyCursorAppendAtEndAndSelect = (a -> a) -> (a -> a) -> a -> NonEmptyCursor a -> NonEmptyCursor a
forall a b.
(a -> b)
-> (b -> a) -> b -> NonEmptyCursor a b -> NonEmptyCursor a b
NEC.nonEmptyCursorAppendAtEndAndSelect a -> a
forall a. a -> a
id a -> a
forall a. a -> a
id

nonEmptyCursorRemoveElemAndSelectPrev ::
  NonEmptyCursor a -> Maybe (DeleteOrUpdate (NonEmptyCursor a))
nonEmptyCursorRemoveElemAndSelectPrev :: NonEmptyCursor a -> Maybe (DeleteOrUpdate (NonEmptyCursor a))
nonEmptyCursorRemoveElemAndSelectPrev = (a -> a)
-> NonEmptyCursor a -> Maybe (DeleteOrUpdate (NonEmptyCursor a))
forall b a.
(b -> a)
-> NonEmptyCursor a b
-> Maybe (DeleteOrUpdate (NonEmptyCursor a b))
NEC.nonEmptyCursorRemoveElemAndSelectPrev a -> a
forall a. a -> a
id

nonEmptyCursorDeleteElemAndSelectNext ::
  NonEmptyCursor a -> Maybe (DeleteOrUpdate (NonEmptyCursor a))
nonEmptyCursorDeleteElemAndSelectNext :: NonEmptyCursor a -> Maybe (DeleteOrUpdate (NonEmptyCursor a))
nonEmptyCursorDeleteElemAndSelectNext = (a -> a)
-> NonEmptyCursor a -> Maybe (DeleteOrUpdate (NonEmptyCursor a))
forall b a.
(b -> a)
-> NonEmptyCursor a b
-> Maybe (DeleteOrUpdate (NonEmptyCursor a b))
NEC.nonEmptyCursorDeleteElemAndSelectNext a -> a
forall a. a -> a
id

nonEmptyCursorRemoveElem :: NonEmptyCursor a -> DeleteOrUpdate (NonEmptyCursor a)
nonEmptyCursorRemoveElem :: NonEmptyCursor a -> DeleteOrUpdate (NonEmptyCursor a)
nonEmptyCursorRemoveElem = (a -> a) -> NonEmptyCursor a -> DeleteOrUpdate (NonEmptyCursor a)
forall b a.
(b -> a)
-> NonEmptyCursor a b -> DeleteOrUpdate (NonEmptyCursor a b)
NEC.nonEmptyCursorRemoveElem a -> a
forall a. a -> a
id

nonEmptyCursorDeleteElem :: NonEmptyCursor a -> DeleteOrUpdate (NonEmptyCursor a)
nonEmptyCursorDeleteElem :: NonEmptyCursor a -> DeleteOrUpdate (NonEmptyCursor a)
nonEmptyCursorDeleteElem = (a -> a) -> NonEmptyCursor a -> DeleteOrUpdate (NonEmptyCursor a)
forall b a.
(b -> a)
-> NonEmptyCursor a b -> DeleteOrUpdate (NonEmptyCursor a b)
NEC.nonEmptyCursorDeleteElem a -> a
forall a. a -> a
id

nonEmptyCursorSearch :: (a -> Bool) -> NonEmptyCursor a -> Maybe (NonEmptyCursor a)
nonEmptyCursorSearch :: (a -> Bool) -> NonEmptyCursor a -> Maybe (NonEmptyCursor a)
nonEmptyCursorSearch = (a -> a)
-> (a -> a)
-> (a -> Bool)
-> NonEmptyCursor a
-> Maybe (NonEmptyCursor a)
forall a b.
(a -> b)
-> (b -> a)
-> (a -> Bool)
-> NonEmptyCursor a b
-> Maybe (NonEmptyCursor a b)
NEC.nonEmptyCursorSearch a -> a
forall a. a -> a
id a -> a
forall a. a -> a
id

nonEmptyCursorSelectOrAdd :: (a -> Bool) -> a -> NonEmptyCursor a -> NonEmptyCursor a
nonEmptyCursorSelectOrAdd :: (a -> Bool) -> a -> NonEmptyCursor a -> NonEmptyCursor a
nonEmptyCursorSelectOrAdd = (a -> a)
-> (a -> a)
-> (a -> Bool)
-> a
-> NonEmptyCursor a
-> NonEmptyCursor a
forall a b.
(a -> b)
-> (b -> a)
-> (a -> Bool)
-> a
-> NonEmptyCursor a b
-> NonEmptyCursor a b
NEC.nonEmptyCursorSelectOrAdd a -> a
forall a. a -> a
id a -> a
forall a. a -> a
id