Skip to content

Instantly share code, notes, and snippets.

@jnape
Last active January 4, 2020 00:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jnape/116cb056fed9acd2c63f759f2642bf19 to your computer and use it in GitHub Desktop.
Save jnape/116cb056fed9acd2c63f759f2642bf19 to your computer and use it in GitHub Desktop.
#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