3 ms·
I don't know what you mean by "fully exploit", and maybe there are other, nicer, solutions, but object algebras were specifically designed for Java/C# type syst
by pron 11y ago
I don't know what you mean by "fully exploit", and maybe there are other, nicer, solutions, but object algebras were specifically designed for Java/C# type systems. The entire idea is predicated on that:
This paper presents a new solution to the expression problem that works in OO languages with simple generics (including Java or C#). A key novelty of this solution is that advanced typing features, including F-bounded quantification, wildcards and variance annotations, are not needed.
- platz 11y agoit can be easily implemented in mainstream languages like Java and C#." https://oleksandrmanzyuk.wordpress.com/2014/06/18/from-object-algebras-to-finally-tagless-interpreters-2/ https://oleksandrmanzyuk.wordpress.com/2014/06/18/from-objec...
- naasking 11y ago> I don't know what you mean by "fully exploit", If the return type of one of your overloads is itself a generic type, you can't represent that in the type of the method. Consider the IntBoolFactory from the paper, and then add two operations for lambda abstraction and function application: public Exp lambda(Exp=>Exp body); public Exp apply(Exp lambda, Exp arg); Where Exp=>Exp represents a Java lambda taking an Exp and returnin an Exp. Notice how the type of the lambda and its argument must now be dynamically type checked to ensure that 'arg' has the same type as the parameter for the lambda. With higher kinded types, you could write something like this instead: public <T0, T1> Exp lambda(Exp<T0>=>Exp<T1> body); public <T0, T1> Exp<T1> apply(Exp<T0,T1> lambda, Exp<T0> arg); And now everything is statically type checked by the Java compiler. Without higher kinded types, you gain extensibility in every direction using object algebras, but you lose some type checking.
- naasking 11y agoThat actually should read: public <T0, T1> Exp<T0, T1> lambda(Exp<T0>=>Exp<T1> body) But you get the idea.