atria::prelude Namespace Reference

Basic functional programming tools in the spirit of those in Clojure core and Haskell's Prelude. More...

Classes

struct  complement_t
 
struct  constantly_t
 
struct  identity_t
 Similar to clojure.core/identity. More...
 
struct  identity_t_
 Similar to identity, but it never returns a reference to the pased in value. More...
 
struct  tracer
 Function object for calling trace. More...
 
struct  tuplify_t
 Function that forwards its argument if only one element passed, otherwise it makes a tuple. More...
 

Functions

template<typename F >
auto comp (F &&f) -> F &&
 Right-to left function composition. More...
 
template<typename Fn , typename... Fns>
auto comp (Fn &&f, Fns &&...fns) -> detail::get_composed_t< estd::decay_t< Fn >, estd::decay_t< Fns >... >
 
template<typename FnT >
auto complement (FnT &&fn) -> complement_t< estd::decay_t< FnT > >
 Similar to clojure.core/complement$1. More...
 
template<typename T >
auto constantly (T &&value) -> constantly_t< estd::decay_t< T > >
 Similar to clojure.core/constantly. More...
 
template<typename T >
auto trace (T &&x, const std::string &message) -> T &&
 Prints "<message> <x>" to std::cerr and returns the value, forwarded. More...
 

Variables

constexpr struct atria::prelude::identity_t identity
 
constexpr struct atria::prelude::identity_t_ identity_
 
constexpr struct atria::prelude::tuplify_t tuplify
 

Detailed Description

Basic functional programming tools in the spirit of those in Clojure core and Haskell's Prelude.

Function Documentation

auto atria::prelude::comp ( F &&  f) -> F&&

Right-to left function composition.

Returns an object g that composes all the given functions \( f_i \), such that

\[ g(x) = f_1(f_2(...f_n(x))) \]

Functions are invoked via standard INVOKE, allowing to compose function pointers, member functions, etc.

Definition at line 80 of file comp.hpp.

auto atria::prelude::complement ( FnT &&  fn) -> complement_t<estd::decay_t<FnT> >

Similar to clojure.core/complement$1.

fn is invoked via standard INVOKE, allowing to negate function pointers, member functions, etc.

Definition at line 55 of file complement.hpp.

auto atria::prelude::constantly ( T &&  value) -> constantly_t<estd::decay_t<T> >

Similar to clojure.core/constantly.

Definition at line 56 of file constantly.hpp.

auto atria::prelude::trace ( T &&  x,
const std::string &  message 
) -> T&&

Prints "<message> <x>" to std::cerr and returns the value, forwarded.

Useful for looking at the value that is returned in the middle of an expression.

See also
tracer
traced

Definition at line 44 of file trace.hpp.

Fork me on GitHub