clarity

所属分类:工具库
开发工具:OCaml
文件大小:0KB
下载次数:0
上传日期:2019-09-18 15:51:23
上 传 者sh-1993
说明:  OCaml的函数编程库,
(Functional programming library for OCaml,)

文件列表:
LICENSE (1531, 2019-09-18)
Makefile (312, 2019-09-18)
clarity.opam (466, 2019-09-18)
descr (187, 2019-09-18)
dune-project (31, 2019-09-18)
lib.odocl (132, 2019-09-18)
lib/ (0, 2019-09-18)
lib/clarity.ml (618, 2019-09-18)
lib/classes/ (0, 2019-09-18)
lib/classes/align.ml (2452, 2019-09-18)
lib/classes/align.mli (2000, 2019-09-18)
lib/classes/applicative.ml (3174, 2019-09-18)
lib/classes/applicative.mli (2495, 2019-09-18)
lib/classes/foldable.ml (1482, 2019-09-18)
lib/classes/foldable.mli (1117, 2019-09-18)
lib/classes/functor.ml (1229, 2019-09-18)
lib/classes/functor.mli (1034, 2019-09-18)
lib/classes/monad.ml (1771, 2019-09-18)
lib/classes/monad.mli (1556, 2019-09-18)
lib/classes/monoid.ml (1191, 2019-09-18)
lib/classes/monoid.mli (552, 2019-09-18)
lib/classes/semigroup.ml (228, 2019-09-18)
lib/classes/semigroup.mli (192, 2019-09-18)
lib/classes/traversable.ml (1419, 2019-09-18)
lib/classes/traversable.mli (1248, 2019-09-18)
lib/dune (201, 2019-09-18)
lib/types/ (0, 2019-09-18)
lib/types/clarity_list.ml (2714, 2019-09-18)
lib/types/clarity_list.mli (1530, 2019-09-18)
lib/types/either.ml (720, 2019-09-18)
lib/types/either.mli (464, 2019-09-18)
lib/types/fn.ml (210, 2019-09-18)
lib/types/fn.mli (381, 2019-09-18)
lib/types/id.ml (84, 2019-09-18)
lib/types/id.mli (81, 2019-09-18)
lib/types/option.ml (617, 2019-09-18)
lib/types/option.mli (408, 2019-09-18)
lib/types/these.ml (1589, 2019-09-18)
... ...

## Clarity - functional programming library for OCaml ### Description The goal of this project is to make pure functional programming idioms as useful as possible given OCaml's absence of higher-kinded types and typeclasses. ### Main features are: * Standard "classes" like Functor-Applicative-Monad * Concrete instances like Reader-Writer-State * Useful data types like Either, These or Vector ### Design notes * All concrete datatypes also have its constructors defined as values where name is prefixed with underscore. Sometimes it's more convenient to use "curried", first-class version of a constructor, e.g. following two are equivalent: ```ocaml let long = List.map (fun x -> Some x) a let short = List.map _Some x ``` * Applicative operator `ap` and its infix version `(<~>)` are "lazy" by its second argument. This allows for an applicative to "fail-fast" and don't compute unneeded values. "Strict" versions are called `ap'` and `(<*>)` respectively. "Laziness" here is just (unit -> 'a) closure, so you can use function combinators from Fn module for convenience: ```ocaml open Clarity open Option (* val (<*>) : ('a -> 'b) t -> 'a t -> 'b t val (<~>) : ('a -> 'b) t -> (unit -> 'a t) -> 'b t val serialize : int -> int -> string -> string val idx : int option val long_computation : int -> int option val title : string option *) open Fn let res : string Option.t = map serialize idx <~> defer long_computation 1024 <*> title ``` * Right folds are also "lazy" by "accumulator" argument of a folding function. Strict right fold is called `foldr'`. This allows for shortcut when function no more needs data. For example, here is `any` function from Foldable module that checks if at least one element of a Foldable satisfies given predicate: ```ocaml let any p = foldr (fun x a -> p x || a ()) (const false) ``` ### Documentation You can find ocamldoc [here](https://indiscriminatecoding.github.io/clarity-docs/). ### Manual installation $ make && make install

近期下载者

相关文件


收藏者