kudzu-forest/elm-zipper-pull/4.0.0

NOTE: the latest version is 5.0.0

ZipperPull.Stiff

This module provides a 'stiff' list zipper interface, meaning that the motion may fail. The failue results from two reasons: 1.the pull already comes at the left or right end. 2.the data conversion between focused and stored data fails. In order to express this fact, some methods provided by interface made with Zipper.Stiff.create returns Results.

INTERFACE TYPE

type alias Interface g stock model output =
{ focusLeft : model -> Result (Err g) model
, focusRight : model -> Result (Err g) model
, focusLeftWhile : (stock -> Bool) -> model -> Result (Err g) model
, focusRightWhile : (stock -> Bool) -> model -> Result (Err g) model
, focusLeftEnd : model -> Result (Err g) model
, focusRightEnd : model -> Result (Err g) model
, isLeftEnd : model -> Bool
, isRightEnd : model -> Bool
, indexFromLeft : model -> Int
, indexFromRight : model -> Int
, map : (stock -> stock) -> model -> Result (Err g) model
, toLeftHeadList : model -> Result (Err g) (List stock)
, toRightHeadList : model -> Result (Err g) (List stock)
, foldl :
(stock -> output -> output) -> output -> model -> Result (Err g) output
, foldr :
(stock -> output -> output) -> output -> model -> Result (Err g) output
, mapToLeftHeadList :
(stock -> output) -> model -> Result (Err g) (List output)
, mapToRightHeadList :
(stock -> output) -> model -> Result (Err g) (List output)
}

A record containing functions for manipulating specified data type as list zipper. The type parameter output should not be specifide.

CREATION

{ getRightList : model -> List a
, getLeftList : model -> List a
, getFocus : model -> Result g a
, setRightList : List a -> model -> model
, setLeftList : List a -> model -> model
, setFocus : a -> model -> model
}
-> Interface g a model b

The way you can attach stiff list zipper interface on ordinary record.

Error

type Err g
= FailedToGetFocus g
| BumpsLeftEnd
| BumpsRightEnd

Represents failure reason in moving focus.