Re: [Haskell] factoring `if'

2004-10-11 Thread Colin Runciman
Serge, How do you think, is the program (1) equivalent to (2) in the meaning of Haskell-98 ? (1) (\ x -> (if p x then foo (g x) else foo (h x)) where p ... g ... h ... foo ... ) (2) (\ x -> foo ((if p x then g x else h x) where

concurrent assertions [was re: awaitEval etc]

2003-02-19 Thread Colin Runciman
Dean Herrington has mailed me to point out that the metatype is unnecessary: class Assert a where assertW :: MVar a -> a -> a assertR :: MVar a -> a instance Assert a => Assert [a] where assertW mv [] = unsafePerformIO $ do putMVar mv []; return [] assertW mv (x:xs) = unsafePerformIO $ do

Re: awaitEval in Concurrent Haskell

2003-02-19 Thread Colin Runciman
Claus, The need to shadow the data types is a bit annoying, but then the whole generic bit would preferably be generated anyway. Template Haskell to the rescue, or Drift?-) Agreed. Current plan is to use Drift There is still something I don't understand about your specification: the assertio

Re: awaitEval in Concurrent Haskell

2003-02-17 Thread Colin Runciman
Simon, Does this mean you can womble along with Claus's suggestion? I'm feeling a bit swamped at the moment, and not keen to undertake another open-ended implementation exercise. So if you can manage without, and perhaps use the experience to refine the specification of a Really Useful Feature,

Re: awaitEval in Concurrent Haskell

2003-02-17 Thread Colin Runciman
y to avoid the problems with types is to use a multi-parameter type class. Little example attached. So, thanks again Claus! Regards Colin R -- A mini-experiment in concurrent data-driven assertions. -- Colin Runciman after Claus Reinke after Andy Gill after ... -- February 2003 import Control.

Re: awaitEval in Concurrent Haskell

2003-02-17 Thread Colin Runciman
Claus, It may be possible to get the two representations together by applying the predicate to a "reader" for x, generated from x, which would complement something like Hood's "writer" for x, generated from x. Just as the context demanding parts of x isn't aware of triggering observations, the p

Re: awaitEval in Concurrent Haskell

2003-02-11 Thread Colin Runciman
C.Reinke wrote: I'm not sure whether I understand what you have in mind later on, but this first part sounds so remarkably like something I've seen before, that I'll take my chances. Do you remember Andy Gill's Hood from long ago? Inside its implementation, it had a very similar problem: writin

Re: awaitEval in Concurrent Haskell

2003-02-06 Thread Colin Runciman
Simon, Next idea is to have a function await :: a -> b -> b which is rather like 'seq' except that it waits for its first argument to be evaluated, whereas 'seq' evaluates it. Then you could write a new version of 'length' which used await before every case expression. Is that what you had in m

Re: Weird profiling behaviour

2002-06-27 Thread Colin Runciman
Ketil Z. Malde wrote: >>5.02 uses quicksort, >> >That's funny, since I see quadratic scaling, I must be hitting worst >case both times? 'sort' and 'sortBy' *are* implemented in the same >way, right? > Implementations of QuickSort on lists usually take the easy option of using the head of the li

Re: Weird profiling behaviour

2002-06-26 Thread Colin Runciman
Ketil Z. Malde wrote: >I have what I think is a really strange problem. I have a fair sized >problem, which involves sorting a data set, first on labels (which are >Strings) and then on scores (which are Ints). > >The strange thing is that string sorting is *vastly* faster than int >scoring! No