signature BASICS = sig (*functions*) val |> : 'a * ('a -> 'b) -> 'b val |-> : ('c * 'a) * ('c -> 'a -> 'b) -> 'b val |>> : ('a * 'c) * ('a -> 'b) -> 'b * 'c val ||> : ('c * 'a) * ('a -> 'b) -> 'c * 'b val ||>> : ('c * 'a) * ('a -> 'd * 'b) -> ('c * 'd) * 'b val #> : ('a -> 'b) * ('b -> 'c) -> 'a -> 'c val #-> : ('a -> 'c * 'b) * ('c -> 'b -> 'd) -> 'a -> 'd val #>> : ('a -> 'c * 'b) * ('c -> 'd) -> 'a -> 'd * 'b val ##> : ('a -> 'c * 'b) * ('b -> 'd) -> 'a -> 'c * 'd val ##>> : ('a -> 'c * 'b) * ('b -> 'e * 'd) -> 'a -> ('c * 'e) * 'd val ` : ('b -> 'a) -> 'b -> 'a * 'b val tap: ('b -> 'a) -> 'b -> 'b
(*options*) val is_some: 'a option -> bool val is_none: 'a option -> bool val the: 'a option -> 'a val these: 'a list option -> 'a list val the_list: 'a option -> 'a list val the_default: 'a -> 'a option -> 'a val perhaps: ('a -> 'a option) -> 'a -> 'a val merge_options: 'a option * 'a option -> 'a option val join_options: ('a * 'a -> 'a) -> 'a option * 'a option -> 'a option val eq_option: ('a * 'b -> bool) -> 'a option * 'b option -> bool
(*partiality*) valtry: ('a -> 'b) -> 'a -> 'b option val can: ('a -> 'b) -> 'a -> bool
(*lists*) val cons: 'a -> 'a list -> 'a list val append: 'a list -> 'a list -> 'a list val fold: ('a -> 'b -> 'b) -> 'a list -> 'b -> 'b val fold_rev: ('a -> 'b -> 'b) -> 'a list -> 'b -> 'b val fold_map: ('a -> 'b -> 'c * 'b) -> 'a list -> 'b -> 'c list * 'b val fold_maps: ('a -> 'b -> 'c list * 'b) -> 'a list -> 'b -> 'c list * 'b end;
structure Basics: BASICS = struct
(* functions *)
(*application and structured results*) fun x |> f = f x; fun (x, y) |-> f = f x y; fun (x, y) |>> f = (f x, y); fun (x, y) ||> f = (x, f y); fun (x, y) ||>> f = letval (z, y') = f y in ((x, z), y') end;
(*composition and structured results*) fun (f #> g) x = x |> f |> g; fun (f #-> g) x = x |> f |-> g; fun (f #>> g) x = x |> f |>> g; fun (f ##> g) x = x |> f ||> g; fun (f ##>> g) x = x |> f ||>> g;
(*result views*) fun `f = fn x => (f x, x); fun tap f = fn x => (f x; x);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.