Version française
Home     About     Download     Resources     Contact us    
Browse thread
More cores
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Zheng Li <zheng_li@u...>
Subject: Re: prelude.ml as another standard extension to Pervasives?
Hi,

Alexy Khrabrov wrote:
> I agree its solution to parallelism via a simple forking map/reduce is 
> not universal, but in fact I am wondering about having other functional 

coThreads is comparatively low-level. You might be able to write your 
own schedule on top of it. A no-brainer pmap can be defined as follows:

Toplevel trace:
----
# :load unix.cma;;
# :path +process;;
# :load cothreads.cma;;
# let pmap f a =
   let ea = Array.map (Cothread.spawn f) a in
   Array.map Event.sync ea;;
val pmap : ('a -> 'b) -> 'a array -> 'b array = <fun>
# pmap ((+) 1) (Array.init 10 (fun i -> i));;
- : int array = [|1; 2; 3; 4; 5; 6; 7; 8; 9; 10|]
----

> combinators available in shorthand.  Prelude.ml is a
> superb crash course in FP, and in fact I catch myself reinventing these 
> idioms ad hoc quite often.  I'm very tempted to just include it always, 
> making it my own Pervasives.

Maybe you should also look at some of Haskell's standard lib.
Pros: Haskell guys are really good at naming;
Cons: costs are always hidden and combinators composition can be terse.

Just my 2 cents.

--
Zheng