module Sugar:Basic shortcuts and syntactic sugar.sig..end
val (||) : ('a -> 'b) -> ('b -> 'c) -> 'a -> 'cval (=>) : 'a -> ('a -> 'b) -> 'b
"ls" => ( SSys.run || fst || SString.toList ) ;;
Working with tuples
val identity : 'a -> 'aval id : 'a -> 'aval (@@) : ('a -> 'b) -> ('c -> 'd) -> 'a * 'c -> 'b * 'dval curry : ('a * 'b -> 'c) -> 'a -> 'b -> 'cval 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 optionval (|=>) : 'a option -> 'a -> 'aExample
# 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 -> boolval is_some : 'a option -> boolval nothing : unit -> unitfunction () -> ().val skip : unit().typeidentifier =int
int.type'afilter ='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.