Variants/case classes/algebraic data types/sums/oh my!
org.openjdk at io7m.com
org.openjdk at io7m.com
Fri Jun 17 17:12:52 UTC 2016
On 2016-06-17T15:43:23 +0200
Remi Forax <forax at univ-mlv.fr> wrote:
> Thinking a little bit more about that ...
> I we want to represent something like this,
> Expr = Value(int value) | Add(Expr left, Expr right)
> instead of using an interface wich is wrong because we want Value and Add to be Exprs and not subtypes of Expr,
> we can use the __Where clause to disambiguate between the Add and the Value.
I think there's some merit to this.
As JB Giraudeau pointed out in the original github thread:
> btw, another problem of sealed hierarchies, often encountered in
> scala, is that they expose subtyping relationships, which often ruin
> type inference.
I think this is something that anyone coming from Haskell or OCaml has
experienced. You write what would be a perfectly reasonable monadic
expression and the compiler decides that all of the types are Any and
gets upset.
M
More information about the valhalla-dev
mailing list