Skip to content

Instantly share code, notes, and snippets.

@jnape
Last active Jan 4, 2020
Embed
What would you like to do?
#include <thread>
#include <iostream>
#include <functional>
template<typename T> using Id = T&;
template<typename A, typename B>
struct Phi {
template<typename R>
R match(std::function<R(A)>, std::function<R(B)>) {
}
};
template<typename A, typename B, template<typename, typename> typename Subject, template<typename, typename> typename P> concept Coproduct = requires (Subject<A,B> s) {
{ s.phi() } -> P<A,B>;
{ P<A, B>::match };
};
template<typename A, typename B>
struct Either {
Phi<A,B> phi() {
}
};
template<typename A, typename B>
requires Coproduct<A, B, Either, Phi>
void witnessEither() {
}
int main() {
Either<int, double> e;
witnessEither<int, int>();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment