
What would preOrder foldr/foldl mean? What about preOrder (reverse . map) and preOrder (map . reverse) ? Another option would be for map to take a "strategy" as a parameter, sort of like Control.Parallel.Strategies. Peter Verswyvelen wrote:
Well, in DDC I believe the order is left to right.
But you guys are right, many orders exist.
On the other hand, a language might offer primitives to convert pure-to-effectfull functions no, in which you indicate the order you want.
e.g. preOrder map
No?
(anyway Oleg's reply seems to give a definite answer to this thread no? :-)
On Thu, Aug 13, 2009 at 11:06 AM, Heinrich Apfelmus
wrote: Russell O'Connor wrote:
Peter Verswyvelen wrote:
I kind of agree with the DDC authors here; in Haskell as soon as a function has a side effect, and you want to pass that function to a pure higher order function, you're stuck, you need to pick the monadic version of the higher order function, if it exists. So Haskell doesn't really solve the modularity problem, you need two versions of each higher order function really,
Actually you need five versions: The pure version, the pre-order traversal, the post-order traversal, the in-order traversal, and the reverse in-order traversal. And that is just looking at syntax. If you care about your semantics you could potentially have more (or less).
Exactly! There is no unique choice for the order of effects when lifting a pure function to an effectful one.
For instance, here two different versions of an effectful map :
mapM f [] = return [] mapM f (x:xs) = do y <- f x ys <- mapM f xs return (y:ys)
mapM2 f [] = return [] mapM2 f (x:xs) = do ys <- mapM2 f xs y <- f x return (y:ys)
Which one will the DCC compiler chose, given
map f [] = [] map f (x:xs) = f x : map f xs
? Whenever I write a pure higher order function, I'd also have to document the order of effects.
Regards, apfelmus
-- http://apfelmus.nfshost.com
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
=============================================================================== Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html ===============================================================================