Skip to content

Instantly share code, notes, and snippets.

@goofballLogic
Created October 5, 2023 10:01
Show Gist options
  • Save goofballLogic/9c58346448b6f6f21f59e307859bf259 to your computer and use it in GitHub Desktop.
Save goofballLogic/9c58346448b6f6f21f59e307859bf259 to your computer and use it in GitHub Desktop.
// Set up:
// - dotnet new console
// - dotnet add package OneOf
// Implement each of the methods below so that they all compile
// There only one valid implementation for each function (apart from f5 & f6)
using OneOf;
A F1<A>(A a) {
/* TODO */
}
B F2<A, B>(A a, B b) {
/* TODO */
}
B F3<A, B>(A a, Func<A, B> a2b) {
/* TODO */
}
C F4<A, B, C>(Func<B, C> b2c, Func<A, B> a2b, A a) {
/* TODO */
}
// two possible solutions
A F5<A>(A? optionalA, A a) {
/* TODO */
}
// two possible solutions
OneOf<A, B> F6<A, B>(A? optionalA, B b) {
/* TODO */
}
B F7<A, B>(Func<A, B> a2b, Func<Func<A, B>, B> a2b2b) {
/* TODO */
}
C F8<A, B, C>(Func<A, B, C> ab2c, Func<Func<A, C>, C> a2c2c, B b) {
/* TODO */
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment