Skip to content

Commit

Permalink
Add semantic documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
pfultz2 committed Sep 28, 2015
1 parent e8dc67d commit 2296dbe
Show file tree
Hide file tree
Showing 20 changed files with 111 additions and 0 deletions.
10 changes: 10 additions & 0 deletions doc/src/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,13 @@ A decorator is a function that returns a function adaptor. The function adaptor
template<class... Ts>
FunctionAdaptor Decorator(Ts...);
```
Semantics
---------
Some parts of the documentation provides the meaning(or equivalence) of an expression. Here is a guide of thos symbols:
* `f`, `g`, `fs`, `gs`, `p` are functions
* `x`, `y`, `xs`, `xs` are parameters to a function
* `T` represents some type
* `...` are parameter packs
5 changes: 5 additions & 0 deletions fit/always.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
/// template<class T>
/// constexpr /* unspecified */ always_ref(T& value);
///
/// Semantics
/// ---------
///
/// assert(always(x)(xs...) == x);
///
/// Requirements
/// ------------
///
Expand Down
5 changes: 5 additions & 0 deletions fit/apply.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
/// template<class F, class... Ts>
/// constexpr auto apply(F&& f, Ts&&... xs);
///
/// Semantics
/// ---------
///
/// assert(apply(f)(xs...) == f(xs...));
///
/// Requirements
/// ------------
///
Expand Down
5 changes: 5 additions & 0 deletions fit/apply_eval.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
/// template<class F, class... Ts>
/// constexpr auto apply_eval(F&& f, Ts&&... xs);
///
/// Semantics
/// ---------
///
/// assert(apply_eval(f)(xs...) == f(eval(xs)...));
///
/// Requirements
/// ------------
///
Expand Down
5 changes: 5 additions & 0 deletions fit/by.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
/// template<class Projection>
/// constexpr by_adaptor<Projection> by(Projection p);
///
/// Semantics
/// ---------
///
/// assert(by(p, f)(xs...) == f(p(xs)...));
///
/// Requirements
/// ------------
///
Expand Down
5 changes: 5 additions & 0 deletions fit/capture.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
/// template<class... Ts>
/// constexpr auto capture_decay(Ts&&... xs);
///
/// Semantics
/// ---------
///
/// assert(capture(xs...)(f)(ys...) == f(xs..., ys...));
///
///
/// Example
/// -------
Expand Down
5 changes: 5 additions & 0 deletions fit/combine.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
/// template<class F, class... Gs>
/// constexpr combine_adaptor<F, Gs...> combine(F f, Gs... gs);
///
/// Semantics
/// ---------
///
/// assert(combine(f, gs...)(xs...) == f(gs(xs)...));
///
/// Requirements
/// ------------
///
Expand Down
5 changes: 5 additions & 0 deletions fit/compose.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
/// template<class... Fs>
/// constexpr compose_adaptor<Fs...> compose(Fs... fs);
///
/// Semantics
/// ---------
///
/// assert(compose(f, g)(xs...) == f(g(xs...)));
///
/// Requirements
/// ------------
///
Expand Down
8 changes: 8 additions & 0 deletions fit/compress.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@
/// template<class F>
/// constexpr compress_adaptor<F> compress(F f);
///
/// Semantics
/// ---------
///
/// assert(compress(f, z)() == z);
/// assert(compress(f, z)(x, xs...) == compress(f, f(z, x))(xs...));
/// assert(compress(f)(x) == x);
/// assert(compress(f)(x, y, xs...) == compress(f)(f(x, y), xs...));
///
/// Requirements
/// ------------
///
Expand Down
5 changes: 5 additions & 0 deletions fit/construct.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
/// template<template<class...> class Template>
/// constexpr auto construct();
///
/// Semantics
/// ---------
///
/// assert(construct<T>()(xs...) == T(xs...));
///
/// Requirements
/// ------------
///
Expand Down
5 changes: 5 additions & 0 deletions fit/decorate.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
/// template<class F>
/// constexpr decorate_adaptor<F> decorate(F f);
///
/// Semantics
/// ---------
///
/// assert(decorate(f)(x)(g)(xs...) == f(x, g, xs...));
///
/// Requirements
/// ------------
///
Expand Down
5 changes: 5 additions & 0 deletions fit/fix.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
/// template<class F>
/// constexpr fix_adaptor<F> fix(F f);
///
/// Semantics
/// ---------
///
/// assert(fix(f)(xs...) == f(f, xs...));
///
/// Requirements
/// ------------
///
Expand Down
5 changes: 5 additions & 0 deletions fit/flip.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
/// template<class F>
/// flip_adaptor<F> flip(F f);
///
/// Semantics
/// ---------
///
/// assert(flip(f)(x, y, xs...) == f(y, x, xs...));
///
/// Requirements
/// ------------
///
Expand Down
5 changes: 5 additions & 0 deletions fit/flow.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
/// template<class... Fs>
/// constexpr flow_adaptor<Fs...> flow(Fs... fs);
///
/// Semantics
/// ---------
///
/// assert(flow(f, g)(xs...) == g(f(xs...)));
///
/// Requirements
/// ------------
///
Expand Down
5 changes: 5 additions & 0 deletions fit/identity.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
///
/// The `identity` function is a unary function object that returns whats given to it.
///
/// Semantics
/// ---------
///
/// assert(idenity(x) == x);
///
/// Synopsis
/// --------
///
Expand Down
5 changes: 5 additions & 0 deletions fit/infix.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
/// template<class F>
/// constexpr infix_adaptor<F> infix(F f);
///
/// Semantics
/// ---------
///
/// assert((x <infix(f)> y) == f(x, y));
///
/// Requirements
/// ------------
///
Expand Down
5 changes: 5 additions & 0 deletions fit/partial.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
/// template<class F>
/// constexpr partial_adaptor<F> partial(F f);
///
/// Semantics
/// ---------
///
/// assert(partial(f)(xs...)(ys...) == f(xs..., ys...));
///
/// Requirements
/// ------------
///
Expand Down
5 changes: 5 additions & 0 deletions fit/pipable.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@
/// template<class F>
/// constexpr pipable_adaptor<F> pipable(F f);
///
/// Semantics
/// ---------
///
/// assert(x | pipable(f)(ys...) == f(x, ys...));
///
/// Requirements
/// ------------
///
Expand Down
8 changes: 8 additions & 0 deletions fit/reverse_compress.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@
/// template<class F>
/// constexpr reverse_compress_adaptor<F> reverse_compress(F f);
///
/// Semantics
/// ---------
///
/// assert(reverse_compress(f, z)() == z);
/// assert(reverse_compress(f, z)(x, xs...) == f(reverse_compress(f, z)(xs...), x));
/// assert(reverse_compress(f)(x) == x);
/// assert(reverse_compress(f)(x, xs...) == f(reverse_compress(f)(xs...), x));
///
/// Requirements
/// ------------
///
Expand Down
5 changes: 5 additions & 0 deletions fit/rotate.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
/// template<class F>
/// rotate_adaptor<F> rotate(F f);
///
/// Semantics
/// ---------
///
/// assert(rotate(f)(x, xs...) == f(xs..., x));
///
/// Requirements
/// ------------
///
Expand Down

0 comments on commit 2296dbe

Please sign in to comment.