|
|
|
|
|
by shiandow
305 days ago
|
|
If you're creative about it you can make an interface for what is essentially a sum type. All it takes is a method signature like: Z read<Z>(Func<A,Z> readA, Func<B,Z> readB)
It's a bit of a Yoneda embedding like way of forcing it in to the language, but hey it works. |
|
Presumably, you use a function like this to represent your sum type containing the value "avalue":
The problem I have is that when you create this function you have to reify the return type Z. You can't use this value in arbitrary contexts where the accessors need to return different types.How do you get this to work?