#haskell - Wed 14 Mar 2007 between 05:24 and 05:33

NY Lost Funds



encryptio:> ?
quicksilverhowever, the deeper problem is 'referentially transparent languages ought to be able to automatically memoise'
nmessengerthat works!
encryptioyay!
naraindata Kiss = Person :-* Person
quicksilverwhich is true
but it's a hard rpoblem to right a compiler which can automatically work out which bits to memoise :)
s/right/write/
dmwitDecorators!
dolioghc might automatically rewrite things for some sharing.
dmwitHumans know which bits should be memoized... ;-)
nmessengerpragmas?
DRMacIverWell, automatically memoising would be nice, but isn't really the problem here. The problem is that it's so hard to *manually* memoise. :)
dolioBut there are examples of spots where memoizing causes worse performance.
quicksilverDRMacIver: I don't think it is hard to manually memoise
we've discussed half a dozen ways of doing it in the last 5 minutes :)
dolioIt's not hard to manually memoize, either.
http://haskell.org/haskellwiki/Haskell_Quiz/Happy_Numbers/Solution_Dolio
lambdabotTitle: Haskell Quiz/Happy Numbers/Solution Dolio - HaskellWiki, http://tinyurl.com/yqwvr3
DRMacIverYes. And they all involve some flavour of either breaking module encapsulation or wrapping everything in a state monad. :)
dolioThe stuff at the bottom is based on stuff on the older wiki.
nmessengerf = ...; ftable range = map (id &&& f) range; fmemo = (ftable !)
quicksilvertop level defeinitions, shared 'where' clauses, arrays, hashes, state monads...
narainDRMacIver: how about f x = let memo = fmap f domain in lookup x memo -- pseudocode
that should be f' (the pure function) in the fmap
DRMacIverI guess the where clauses are relatively inoffensive.
Assuming they really do get only calculated once.
dolioThat is how laziness works.
As opposed to call by name.
DRMacIverExcept when it doesn't.
narainhmm, i like the solution i just wrote... seems pretty general too, and you can use it as a regular function. are there any disadvantages?
dolioWhen would it not?
Isn't the definition of laziness that a term is left unevaluated until it's needed, and then is memoized (in case it's used multiple times)?
beelsebobnope
DRMacIverNo. It's only the first half.
beelseboball it is is left-most-outer-most evaluation
narain?src Array fmap
lambdabotSource not found. I can't hear you -- I'm using the scrambler.
nmessengerbeelsebob: plus sharing
beelsebobnmessenger: yes, indeed

Page: 2 9 16 23 30 37 44 51 58 65 72 79 86 93 100 107 114 121 128 135 

IrcArchive

NY Lost Funds