3 ms·
The thing that's great about the typeclass approach, you can do anything you want behind the implementation. you can numerically evaluate the expression, but ev
by jfoutz 11y ago
The thing that's great about the typeclass approach, you can do anything you want behind the implementation. you can numerically evaluate the expression, but even cooler, you can recover the parse tree. I never could sort out how to deal with 'if', because it's not typeclassed. if it was, boy could you do some amazing stuff. partial differentiation, tree rewriting, with the LLVM stuff you could runtime compile arbitrary functions. super neat trick.
- mpweiher 11y agoThat's also what's great about pure dynamic systems like Smalltalk. 'ifTrue:' is just a message-send, the class "False" doesn't evaluate the block parameter, the class "True" does. And yes, you can then recover the parse tree, for example the Gemstone OODB lets you use arbitrary blocks (closures) as queries, recovers the parse tree and then creates an optimized query from it. Quite neat.
- mpweiher 11y agoThat's also what's great about pure dynamic systems like Smalltalk. 'ifTrue:' is just a message-send, the class "False" doesn't evaluate the block parameter, the class "True" does. And yes, you can then recover the parse tree, for example the Gemstone OODB lets you use arbitrary blocks (closures) as queries, recovers the parse tree and then creates an optimized query from it. Quite neat.
- eru 11y agoYou can make a type-classed `if' without any problem. The problems occur when you want to typeclass your lambdas. The difficulties are mostly surmountable, though. Check out http://okmij.org/ftp/tagless-final/course/ http://okmij.org/ftp/tagless-final/course/