package acgtk

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Focused_list.Focused_listSource

Sourcetype 'a t =
  1. | List_zip of 'a list * 'a * 'a list
    (*

    This type aims to implement a zipper for lists. The context is the first parameter. It represents the list of the elements in reverse order that has been traversed to reach the focused element (the second parameter). The last element is the remaining elements of the list.

    *)
Sourceexception Empty_list
Sourceexception End_of_list
Sourceval init : 'a list -> 'a t

init l inits a focused list. It raises an exception Empty_list if l is empty, hence has no element to focus on.

Sourceval forward : ?step:int -> 'a t -> 'a t

forward z returns a the new focused_list where the focused element is the step steps (default to 1) next to the current one in the initial list. It raises End_of_list if no such element is available

Sourceval backward : 'a t -> 'a t

backward z returns a the new focused_list where the focuses element is the previous one in the initial list. It raises End_of_list if no such element is available

Sourceval fold : ('b -> ('a list * 'a * 'a list) -> 'b) -> 'b -> 'a t -> 'b

fold f a z returns f (... (f (f a z1) z2) ...) z_n where z_1=z and z_{i+1}=forward z_i and forward z_n would raise an exception End_of_list.

Sourceval fold_forward : ?include_focus:bool -> ('b -> 'a -> 'b) -> 'b -> 'a t -> 'b

fold_forward ~include_focus f a z returns f (... (f (f a z1) z2) ...) z_n where z_1=focus z if include_focus is true (default) and z_1=focus (forward z) otherwise (returns a if forward z raises End_of_list) and z_{i+1}=focus (forward z_i) and forward z_n would raise an exception End_of_list.

Sourceval focus : 'a t -> 'a

focus l returns the focus element of the focused list l

Sourceval zip : 'a t -> 'a list
OCaml

Innovation. Community. Security.