Re: [Haskell-cafe] STM and random numbers

2007-01-13 Thread Tomasz Zielonka
On Sat, Jan 13, 2007 at 01:49:36PM +1000, Matthew Brecknell wrote: Rather than having a separate thread computing the random numbers using IO, why not just stick an StdGen in a TVar and write a function like: type RandomVar = TVar StdGen rnd :: RandomVar - STM a rnd var = do g

[Haskell-cafe] Are GADTs expressive? Simple proof-carrying code in Haskell98

2007-01-13 Thread oleg
Inspired by the recent post by Jim Apple, we demonstrate a datatype `Terminates' that can hold only an assuredly terminating (strongly normalizable) term in untyped lambda-calculus. Furthermore, the values of the datatype `Terminates' contain all and only those untyped lambda-calculus terms with

[Haskell-cafe] strange performance of expression evaluators

2007-01-13 Thread Alexander Vodomerov
On Sat, Jan 13, 2007 at 11:44:38AM +1000, Matthew Brecknell wrote: So my advice here would be: always try the optimiser before you worry too much about strange performance! Thanks for help! I've done some more experiments. The following program defines simple arithmetic expression with indexed

[Haskell-cafe] Re: different performance of equivalent expression

2007-01-13 Thread apfelmus
I've run into strange effect that I can not explain. I have simple expression that can be written by two equivalent ways. However one way give much performance gain over another. Here is an example: -- apply function many times (tail-recursive) many n f x = if n == 0 then x else many (n-1)

[Haskell-cafe] Re: strange performance of expression evaluators

2007-01-13 Thread apfelmus
I've done some more experiments. The following program defines simple arithmetic expression with indexed variables. I've written four different ways to evaluate them: - eval1 is simple monadic evaluator - eval2 is the obvious straight-forward implentation - compile1 is attempt to perform

RE: [Haskell-cafe] Are GADTs expressive? Simple proof-carrying code inHaskell98

2007-01-13 Thread Meng Wang
Hi, Oleg. It is nice to see how the eval function is encoded with type classes. I always wonder whether the HOAS example from Xi's POPL 03 paper can be programmed this way. In particular, it appears to me that the Fix clause requires non-inductive derivation of the form instance Eval (f e) a =

Re: [Haskell-cafe] mapTuple

2007-01-13 Thread Grady Lemoine
I knew there must be a way in GHC to do that second example! As for the third example, it might be a slick way to do some super-hyper-refactoring, but I admit I can't think of anything it would be actually necessary for offhand. --Grady On 1/12/07, Cale Gibbard [EMAIL PROTECTED] wrote: On

Re: [Haskell-cafe] Are GADTs expressive? Simple proof-carrying code in Haskell98

2007-01-13 Thread Jim Apple
On 1/13/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: The shown GADT encoding seems to be of the kind that is convertible to typeclasses in the straightforward way, see for example, http://pobox.com/~oleg/ftp/Haskell/GADT-interpreter.hs See also Conor McBride's Faking It: Simulating

[Haskell-cafe] Meaning abbreviations stat file GHC

2007-01-13 Thread Ron
Dear, I made a profile[1] of a test program: Where can I find documentation for the meaning of everything mentioned below? Or alternatively, can anyone explain them? Where can I see the effect of using the -xt option in this profile? Ron [1] /Main +RTS -p -s -xt -hc 1,372,408,024 bytes