module Slice:Underlying API for Slice operatorssig
..end
This module is inteded to be used by people implementing slices over new
data types. Most people should be using the Sliceoper
module instead.
Please see the Sliceoper
module for a basic description of what slices are
and how they work. This module implements the layer underlying
Sliceoper
and is generally of interest only if you wish to extend
the Slice system yourself.
type
slice_finish_t =
| |
EndOfList |
(* | Signifies no endpoint; go to the end of the items | *) |
| |
EndingOffset of |
(* | Signifies a specific offset from the end of a
list. Note this is given as a positive number
here even though it is given as a negative number
in | *) |
| |
Position of |
(* | Signifies a position from the start of the list | *) |
typeslice_t =
int * slice_finish_t
val slice_end : int
Slice.slice_of_pair
function.val slice_of_pair : int * int -> slice_t
Slice.slice_end
, it is taken as an EndOfList. Otherwise, it is taken as
a Position.
These functions apply the slice to a data object and return the result.
val string_slice : string -> slice_t -> string
val list_slice : 'a list -> slice_t -> 'a list
val array_slice : 'a array -> slice_t -> 'a array
val generic_slice : ('a -> int -> int -> 'a) -> ('a -> int) -> 'a -> slice_t -> 'a
string_slice
:
let string_slice = generic_slice String.sub String.length;;
The function takes four parameters: a "sub" function, a "length" function,
an item, and a slice.