module Sugar:Basic shortcuts and syntactic sugar.sig
..end
val (||) : ('a -> 'b) -> ('b -> 'c) -> 'a -> 'c
val (=>) : 'a -> ('a -> 'b) -> 'b
"ls" => ( SSys.run || fst || SString.toList ) ;;
Working with tuples
val identity : 'a -> 'a
val id : 'a -> 'a
val (@@) : ('a -> 'b) -> ('c -> 'd) -> 'a * 'c -> 'b * 'd
val curry : ('a * 'b -> 'c) -> 'a -> 'b -> 'c
val uncurry : ('a -> 'b -> 'c) -> 'a * 'b -> 'c
let match_pattern pat str : bool =
let string_match (p,s) = (Str.string_match p s 0) in
(pat,str) => ( (Str.regexp@@identity) || string_match ) ;;
In this example, pat is given to Str.regexp and str is given to identity.
Example. Remove the element with the given index:
let rmindex l i =
(l,l) => ((identity@@indexes) || (uncurry List.combine) || (List.filter (fun (x,j) ->j<>i)) || List.split || fst) ;;
'a option
val (|=>) : 'a option -> 'a -> 'a
Example
# let x = Some 4 ;;
val x : int option = Some 4
Now you can write:
# x |=> 7 ;;
: int = 4
instead of write:
match x with Some v -> v | None -> 7;;
val is_none : 'a option -> bool
val is_some : 'a option -> bool
val nothing : unit -> unit
function () -> ()
.val skip : unit
()
.typeidentifier =
int
int
.type'a
filter ='a -> 'a
val raise_when_none : ?msg:string -> 'a option -> 'a
'a option
value and return its content if any. Otherwise fail with the
given error message or a generic one if not provided.