Lib | Creation | TypeCheck | cata | Serialisable |
---|---|---|---|---|
[periodo,paldepind/union-type][union-type-gh] | Type |
✓ | - [^1] | |
[JAForbes/sum-type][sum-type-gh] | ✓ | |||
[fantasyland/daggy][daggy-gh] | tagged , taggedSum |
✓ | ✓ [^2] |
action :: State → Args → State
An Applicative type (e.g. a Maybe) is also a Functor with an ap
method. Thus, for the observations in the table it
can be used everywhere as an example.
Purpose | Function | Signature | Example |
---|---|---|---|
swap types inside out | sequence(TypeRep f) |
t (f a) → f (t a) [^1] |
sequence(M)([Just(1)]) // -> Just [1] |
apply effect + wrap inside out | traverse(TypeRep f) |
(a → f b) → t a → f (t b) [^1] |
traverse(M)(reciprocal, [2]) // -> Just [0.5] |
swap data portion type inside out | lens(identity) |
Functor f ⇒ s → f s |
yLens(identity)({x: 1, y: M.Just(2)}) // -> Just {x:1,y:2} |
apply effect to data portion + wrap inside out | lens |
Functor f ⇒ (a → f a) → s a → f (s a) |
yLens(reciprocal)({x: 1,y: 2}) // -> Just {x:1, y: 0.5} |
Purpose | List | Object | Signature(s) |
---|---|---|---|
update/insert individual | update , assoc* , append , prepend |
assoc* |
Idx → a → {k: v} → {k: v} |
insert range/collection | concat |
merge* |
[a] → [a] → [a] ;{k: v} → {k: v} → {k: v} |
retrieve by key/index | nth , path , prop |
prop , path |
Idx → {a} → a |
retrieve many by key/index | props |
/* Just my current implementation of Sam Miller's answer on Stack Overflow | |
* @see https://stackoverflow.com/questions/7754695/boost-asio-async-write-how-to-not-interleaving-async-write-calls | |
*/ | |
/* | |
* File: NonInterleavingAsyncSocketWrite.hpp | |
* Author: Matthias Seemann <seemann@visisoft.de> | |
* @see https://stackoverflow.com/questions/7754695/boost-asio-async-write-how-to-not-interleaving-async-write-calls | |
* | |
* When using boost::asio::async_write: |
#include <iostream> | |
#include <functional> | |
#include <memory> | |
#include <iterator> | |
#include <algorithm> | |
using namespace std; | |
template<typename T> | |
struct memfun_type |
// Jyt is a REPL for C++ | |
// You can write code interactively | |
// Highlight some code and press alt-enter to execute it | |
// For example: | |
auto x = "hello world"; | |
// Now you can query the value in the terminal on the right | |
// e.g. "x" |