3 ms·
This is called the expression problem. http://homepages.inf.ed.ac.uk/wadler/papers/expression/expression.txt http://homepages.inf.ed.ac.uk/wadler/papers/expres
by tjalfi 10y ago
This is called the expression problem.
http://homepages.inf.ed.ac.uk/wadler/papers/expression/expression.txt http://homepages.inf.ed.ac.uk/wadler/papers/expression/expre...
http://stackoverflow.com/a/2079678 http://stackoverflow.com/a/2079678 is a great SO answer on this topic.
- pron 10y agoThe expression problem has a complete and rather elegant solution in mainstream OO languages with generics, invented in 2012 called object algebras: Video: https://www.infoq.com/presentations/object-algebras https://www.infoq.com/presentations/object-algebras Paper: https://www.cs.utexas.edu/~wcook/Drafts/2012/ecoop2012.pdf https://www.cs.utexas.edu/~wcook/Drafts/2012/ecoop2012.pdf I understand that there is a comparable solution in FP languages called finally tagless interpreters: https://oleksandrmanzyuk.wordpress.com/2014/06/18/from-object-algebras-to-finally-tagless-interpreters-2/ https://oleksandrmanzyuk.wordpress.com/2014/06/18/from-objec...
- kvb 10y agoVesa Karvonen posted a complete solution in SML here[1] (but LtU seems to be down so the link doesn't work), which I transliterated (directly, not idiomatically) to F# here[2]. [1] http://lambda-the-ultimate.org/node/2232#comment-31278 http://lambda-the-ultimate.org/node/2232#comment-31278 [2] http://fssnip.net/gn http://fssnip.net/gn