5 ms·
This is not relevant directly to the subject but perhaps someone in formal langs can help me. I'm interested in optimisation of (necessarily) pure functional la
by tempguy9999 7y ago
This is not relevant directly to the subject but perhaps someone in formal langs can help me. I'm interested in optimisation of (necessarily) pure functional langs. Starting with deforesting (the elimination of intermediate structures) eg.
map(f, map(g, list(1, 2, 3)))
can be optimised trivially by a human to
map(f.g, list(1, 2, 3))
(where f.g is functional composition) but I want to do this automatically, and the first step is to play with it. I've defined defined stuff on paper then started substituting but it's slow and, being me, error prone, when done with paper and pen.
Does anyone know of a symbolic manipulation software for haskell, or similar syntax (prefer to avoid lisp syntax if poss, but ok if nothing else) which will allow me to do this easily and get a feel for it?
Thanks
- empath75 7y agoThe compiler will generally do that sort of optimization.
- tempguy9999 7y agoLord, that's an unhelpful comment. Some compilers do not do that eg. scala, and the cost is high hence my request.
- bontaq 7y agoYou could use uniplate and a small AST to play more with it, the paper has examples of transformations the paper: https://ndmitchell.com/downloads/paper-uniform_boilerplate_and_list_processing-30_sep_2007.pdf https://ndmitchell.com/downloads/paper-uniform_boilerplate_a... small tutorial: https://www.cs.york.ac.uk/fp/darcs/uniplate/uniplate.htm https://www.cs.york.ac.uk/fp/darcs/uniplate/uniplate.htm
- tempguy9999 7y agoThis seems (AFAICT) a bit higher what I'm after, but very interesting nonetheless, I'll have a play, thanks.
- wvlia5 7y agoSounds like you are in need of transducers
- tempguy9999 7y agoCould you elaborate? A bit searching throws up some very interesting stuff but AFAICS a transducer is roughly comparable to a partial function, which doesn't relate to my request for manual expression manipulation support. If I'm missing something, please say.
- wvlia5 7y agoI'm referring to transducers as in clojure. You can compose 2 'map' transducers, and that results in a single 'map' of the composed mapping-functions. That's to say that the two expressions you wrote would result in the same computations if you expressed them in terms of transducers.
- tempguy9999 7y ago5 mins looking at https://stackoverflow.com/questions/26317325/can-someone-explain-clojure-transducers-to-me-in-simple-terms https://stackoverflow.com/questions/26317325/can-someone-exp... I think I'm getting it. Ops accumulated and composed until they actually have to be evaluated. That's very interesting indeed, thanks, and I'll spend a couple of hours on it. However, I was using my my example exactly as an example; I was after a symbolic manips app. The issue of the cost of naively compiled functional languages matters to me as bad performance will kill a good thing.