coreygirard/elm-zipper/1.0.0

Zipper.StringCharString

A zipper type that is stores a single selected character, with a list of characters on either side. Probably most useful for terminal-like interfaces where the cursor selects a character rather than lying between characters.

A special case of Zipper.ListElemList for when the elements are Char, and some helper functions

Definition

type alias Zipper =
( List Char, Char, List Char )

A list type that must contain at least one element

Create

singleton : Char -> Zipper

Create a new Zipper

singleton 'a' == ( [], 'a', [] )

Move

moveLeft : Zipper -> Maybe Zipper

Attempt to move selection to left

( [ 2, 1 ], 3, [ 4, 5 ] ) |> moveLeft == Ok ( [ 1 ], 2, [ 3, 4, 5 ] )


( [], 3, [ 4, 5 ] ) |> moveLeft == Err ( [], 3, [ 4, 5 ] )