Last active
January 4, 2020 00:32
-
-
Save jnape/116cb056fed9acd2c63f759f2642bf19 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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