On 26 September 2011 19:11, Marijn <hk...@gentoo.org> wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > > Hi Noah, > > On 09/26/11 00:33, Noah Lavine wrote: >> I thought of another use-case, and I wonder if you think this is >> on-topic or not: >> >> - You write a parallel version of map that is fast, but only >> correct if its argument has no side-effects. You'd like to use this >> parallel map instead of the regular one, but only when it is >> correct. > > This seems to assume that map does its thing one element after > another, but that is not what the spec says it does. Note "The dynamic > order in which proc is applied to the elements of the lists is > unspecified." in the below R5RS quote: > > (map proc list1 list2 . . . ) > > The lists must be lists, and proc must be a procedure taking > as many arguments as there are lists and returning a single > value. If more than one list is given, then they must all > be the same length. Map applies proc element-wise to the > elements of the lists and returns a list of the results, in > order. The dynamic order in which proc is applied to the > elements of the lists is unspecified.
If you want to reason about the interference of effects, you might like the original effect typing paper. They were originally employed as a means to infer accurate principal type in the presence of mutability and type parametrism, which might also be useful to you if you find HM unsuitable, but for reasoning about the /relative purity/ of a call I've found them invaluable. The paper also touches on region types, which may be used to remove heap allocation in many cases, although that application of them is not discussed there. The Type and Effect Discipline. Jean-Pierre Talpin. Pierre Jouvelot, ENS. www.cs.ucla.edu/~palsberg/tba/papers/talpin-jouvelot-iandc94.pdf -- William Leslie