[Haskell-cafe] An example of dependent types [was: Simple GADT parser for the eval example]

2006-11-01 Thread oleg
Greg Buchholz has posed an interesting problem of writing a typechecker. Given untyped terms of the form data Expr = ELit Int | EInc Expr | EIsZ Expr we are to compute typed terms: data Term a where Lit :: Int - Term Int Inc :: Term Int -

[Haskell-cafe] What is the best way to preserve the order of a list

2006-11-01 Thread John Ky
Hi,I have a list of entities. Each entity has a priority field and an order field. The priority field contain the input values to my algorithm, the order fields contain the output value of my algorithm. My algorithm needs to assign 1 to the order field of the entity with the lowest priority value,

Re: [Haskell-cafe] there's a monster in my Haskell!

2006-11-01 Thread Bulat Ziganshin
Hello Andrew, Wednesday, November 1, 2006, 8:14:23 AM, you wrote: produced few results. Inspired by Felleisen, and in the spirit of Halloween, I offer a new alternative: Meet monsters, your computational companions in the land of lazy functional programming. All monsters are capable of

Re: [Haskell-cafe] there's a monster in my Haskell!

2006-11-01 Thread David House
On 01/11/06, Andrew Pimlott [EMAIL PROTECTED] wrote: I present here a gentle introduction to monsters. Absolutely brilliant. This certainly made me laugh! Perhaps a light-hearted candidate for the Monad.Reader? And do we have any artistic Haskellers out there? Could we get drawings of these

Re: [Haskell-cafe] What is the best way to preserve the order of a list

2006-11-01 Thread Stefan Holdermans
John, My question is, how do I preserve the ordering of entities in my list and still be able to assign the proper order values to each entity? Is there an efficient way to do this? How else might I improve my orderByPriority algorithm. Straightforwardly, you could do it like this:

RE: [Haskell-cafe] function types as instances of Num

2006-11-01 Thread Simon Peyton-Jones
Try test' = square . (4 :: a - (Integer,a)) Otherwise, how is the compiler to know that you want 4 to be of that type? S | -Original Message- | From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Greg | Buchholz | Sent: 26 October 2006 18:46 | To: haskell-cafe@haskell.org |

[Haskell-cafe] Re: there's a monster in my Haskell!

2006-11-01 Thread Jón Fairbairn
David House [EMAIL PROTECTED] writes: On 01/11/06, Andrew Pimlott [EMAIL PROTECTED] wrote: I present here a gentle introduction to monsters. Absolutely brilliant. This certainly made me laugh! Perhaps a light-hearted candidate for the Monad.Reader? And do we have any artistic Haskellers

Re: [Haskell-cafe] Re: there's a monster in my Haskell!

2006-11-01 Thread John Meacham
On Wed, Nov 01, 2006 at 10:27:53AM +, Jón Fairbairn wrote: David House [EMAIL PROTECTED] writes: On 01/11/06, Andrew Pimlott [EMAIL PROTECTED] wrote: I present here a gentle introduction to monsters. Absolutely brilliant. This certainly made me laugh! Perhaps a light-hearted

[Haskell-cafe] hmake and ghc-6.6

2006-11-01 Thread Alexey Rodriguez
Hello Haskell people, I have been trying to build hmake 3.12 using ghc-6.6 on a Fedora Core Linux running on a dual 64-bit Opteron machine. However, I had the following error related to the readline library: /home/t-alexer/packages/hmake-3.12/script/hmake -hc=ghc HInteractive

[Haskell-cafe] Post mesg

2006-11-01 Thread Farida Mishra
Hi i would like to post mesg this list Everyone is raving about the all-new Yahoo! Mail. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe]Prime Generator time limit exceeded

2006-11-01 Thread alaiyeshi
Hi I'm new to Haskell. I found this site on the Haskell wiki https://www.spoj.pl. But I got some trouble on trying to solve the problem titled Prime Generator https://www.spoj.pl/problems/PRIME1. The online-judge system tells me time limit excedded Would you be so kind to tell me how to make

[Haskell-cafe] Re: An example of dependent types [was: Simple GADT parser for the eval example]

2006-11-01 Thread Greg Buchholz
[EMAIL PROTECTED] wrote: Greg Buchholz has posed an interesting problem of writing a typechecker. Given untyped terms of the form ...snip... We show the solution that uses no GADTs and no representation types. We retain however the eval function in the previous message that uses GADT. Our

Re: [Haskell-cafe] hmake and ghc-6.6

2006-11-01 Thread Malcolm Wallace
Alexey Rodriguez [EMAIL PROTECTED] wrote: I have been trying to build hmake 3.12 using ghc-6.6 on a Fedora Core Linux running on a dual 64-bit Opteron machine. However, I had the following error related to the readline library: ... I googled for this error and I saw the following thread in

Re: [Haskell-cafe] Simple GADT parser for the eval example

2006-11-01 Thread Alexey Rodriguez
Hello Greg,It seems that I am late for the party but we used a GADT parser in the tool we built for our Generating Generic Functions paper[1]. It so happens that I made slides for this material so, if you're interested you can have a look at [2]. The motivation for doing this was that we needed to

Re: [Haskell-cafe] What is the best way to preserve the order of a list

2006-11-01 Thread Henk-Jan van Tuyl
On Wed, 01 Nov 2006 10:29:18 +0100, Stefan Holdermans [EMAIL PROTECTED] wrote: sortOnLab = sortBy (\(l, _) (m, _) - compare l m) The following does the same: sortOnLab = sort -- Met vriendelijke groet, Henk-Jan van Tuyl -- http://Van.Tuyl.eu/ -- Using Opera's

Re: [Haskell-cafe]Prime Generator time limit exceeded

2006-11-01 Thread Dan Weston
I didn't see any other replies and didn't want to leave you hanging, so... Three hints: 1) you are testing every integer = 2 as a divisor when you only need to test prime numbers = floor(sqrt(n)) 2) Since for all n 2, floor(sqrt(n)) n, you can use the very primes you are generating in the

Re: [Haskell-cafe]Prime Generator time limit exceeded

2006-11-01 Thread Dan Weston
Two more hints I used in my code: 5) Except for 2, all primes are odd. Don't bother testing the evens. 6) sqrt(n) is (a little) costly, but I used it in my first solution for clarity. You can also create an infinite list of squares of primes, then trim the list of primes to the length of

[Haskell-cafe] Black Haskell Hacker's t-shirt (was Re: there's a monster in my Haskell!

2006-11-01 Thread Fritz Ruehr
I suppose this might be a good time to announce the tentative availability of BLACK t-shirts in the "Haskell Hackers" design, which in fact features a "monster". (Note that I am only responsible for the composition of elements on the shirt: the monster drawing itself comes from a dingbat font.)The

Re: [Haskell-cafe] Accumulating related XML nodes using HXT

2006-11-01 Thread Daniel McAllansmith
Apologies if this is a duplicate, the original appears to have gone astray. On Wednesday 01 November 2006 10:57, Albert Lai wrote: Daniel McAllansmith [EMAIL PROTECTED] writes: Hello. I have some html from which I want to extract records. Each record is represented within a number of tr

[Haskell-cafe] How to improve speed? (MersenneTwister is several times slower than C version)

2006-11-01 Thread isto
Hi all, On HaWiki was an announcement of MersenneTwister made by Lennart Augustsson. On a typical run to find out 1000th rnd num the output is (code shown below): $ time ./testMTla Testing Mersenne Twister. Result is [3063349438] real0m4.925s user0m4.856s I was exercising with

[Haskell-cafe] Class

2006-11-01 Thread Slavomir Kaslev
Hello. I am new to Haskell and I am going through Haskell: The craft of functional programming. I am trying to grasp haskell's classes and instances, so here is slightly modified code from the book: class Show a = Visible a where toString :: a - String toString = show size :: a - Int

[Haskell-cafe] Re: Class

2006-11-01 Thread Slavomir Kaslev
Err, sorry for the meaningless mail subject. Should be 'Newbie class problem' or something like that. -- Slavomir Kaslev ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] How to improve speed? (MersenneTwister is several times slower than C version)

2006-11-01 Thread Donald Bruce Stewart
Now, this will be hard to get close the the highly tuned C. Possibly its doable. The main tricks are documented here: http://haskell.org/haskellwiki/Performance/GHC#Unboxed_types Inspecting the Core to ensure the math is being inlined and unboxed will be the most crucial issue, I'd imagine.

[Haskell-cafe] Basic Binary IO

2006-11-01 Thread Nuno Pinto
Hi all! Todayi was reading System.IO and didn't manage to understand how it works just by reading it. I looked the internet for some help on this, but only "advanced" information is available. Can anyone show me how to use openBinaryFile ? Just an example, like opening file "somefile" and

Re: [Haskell-cafe] Post mesg

2006-11-01 Thread Tom Phoenix
On 11/1/06, Farida Mishra [EMAIL PROTECTED] wrote: i would like to post mesg this list Your wish has been granted. Cheers! --Tom Phoenix ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Basic Binary IO

2006-11-01 Thread Donald Bruce Stewart
nuno: Hi all! Today i was reading System.IO and didn't manage to understand how it works just by reading it. I looked the internet for some help on this, but only advanced information is available. Can anyone show me how to use openBinaryFile ? Just an example, like

Re: [Haskell-cafe] How to improve speed? (MersenneTwister is several times slower than C version)

2006-11-01 Thread Lennart Augustsson
A big problem with the Mersenne Twister is the shifts. As has been noted elsewhere, ghc doesn't do such a great job on those. -- Lennart On Nov 1, 2006, at 20:17 , Donald Bruce Stewart wrote: Now, this will be hard to get close the the highly tuned C. Possibly its doable. The

Re: [Haskell-cafe] Class

2006-11-01 Thread Daniel Fischer
Am Donnerstag, 2. November 2006 00:06 schrieb Slavomir Kaslev: Hello. I am new to Haskell and I am going through Haskell: The craft of functional programming. I am trying to grasp haskell's classes and instances, so here is slightly modified code from the book: class Show a = Visible a

Re: [Haskell-cafe] How to improve speed? (MersenneTwister is several times slower than C version)

2006-11-01 Thread Lemmih
On 11/1/06, isto [EMAIL PROTECTED] wrote: Hi all, On HaWiki was an announcement of MersenneTwister made by Lennart Augustsson. On a typical run to find out 1000th rnd num the output is (code shown below): $ time ./testMTla Testing Mersenne Twister. Result is [3063349438] real0m4.925s

Re: [Haskell-cafe] How to improve speed? (MersenneTwister is several times slower than C version)

2006-11-01 Thread Lemmih
On 11/2/06, Lennart Augustsson [EMAIL PROTECTED] wrote: A big problem with the Mersenne Twister is the shifts. As has been noted elsewhere, ghc doesn't do such a great job on those. Actually, the shifts are only evaluated once (hurrah for lazy evaluation) and with -funfolding-use-threshold=16

Re: [Haskell-cafe] How to improve speed? (MersenneTwister is several times slower than C version)

2006-11-01 Thread Lennart Augustsson
The whole point of writing the Mersenne Twister was that I wanted to show how a stateful computation could be encapsulated in the ST monad and none of it showing up outside. This aspect of the code is totally gone now when everything is in the IO monad. Is there some good reason to have

Re: [Haskell-cafe] How to improve speed? (MersenneTwister is several times slower than C version)

2006-11-01 Thread Donald Bruce Stewart
lemmih: On 11/1/06, isto [EMAIL PROTECTED] wrote: Hi all, On HaWiki was an announcement of MersenneTwister made by Lennart Augustsson. On a typical run to find out 1000th rnd num the output is (code shown below): $ time ./testMTla Testing Mersenne Twister. Result is [3063349438]

Re: [Haskell-cafe] Accumulating related XML nodes using HXT

2006-11-01 Thread Daniel McAllansmith
On Wednesday 01 November 2006 10:57, Albert Lai wrote: Daniel McAllansmith [EMAIL PROTECTED] writes: Hello. I have some html from which I want to extract records. Each record is represented within a number of tr nodes, and all records tr nodes are contained by the same parent node.

Re: [Haskell-cafe] What is the best way to preserve the order of a list (RESOLVED)

2006-11-01 Thread John Ky
Thanks Stefan,-JohnOn 11/1/06, Stefan Holdermans [EMAIL PROTECTED] wrote: John, My question is, how do I preserve the ordering of entities in my list and still be able to assign the proper order values to each entity?Is there an efficient way to do this?How else might I improve my orderByPriority

Re: [Haskell-cafe]Prime Generator time limit exceeded

2006-11-01 Thread alaiyeshi
Thanks a lot. (you really spoil me;-)) What a stupid mistake I've made!(flush) I'll rewrite my code later. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe]Prime Generator time limit exceeded

2006-11-01 Thread Spencer Janssen
The problem with your approach is the gratuitous use of division, which tends to be very slow. In my solution, I first generate a list of seed primes, all primes less than sqrt 10. Then, for each input m and n, I generate all multiples of the seed primes between m and n. I then

[Haskell-cafe] Very Small Program

2006-11-01 Thread Jason Dagit
Hello, I just found it (in ghci and hugs) that this is a valid haskell program: let 0 = 1 in 0 This program evaluates to 0 (to my surprise). I expected something similar to how this works: let { 1 + 1 = 3; 3 + 1 = 7 } in 1 + 1 + 1 Where you get 7. So, if the 0 is not used as an identifier

Re: [Haskell-cafe] Very Small Program

2006-11-01 Thread Bernie Pope
On 02/11/2006, at 4:45 PM, Jason Dagit wrote: Hello, I just found it (in ghci and hugs) that this is a valid haskell program: let 0 = 1 in 0 This program evaluates to 0 (to my surprise). This is a weird example of a pattern binding, and it is surprising (to me) that the syntax is

Re: [Haskell-cafe] How to improve speed? (MersenneTwister is several times slower than C version)

2006-11-01 Thread isto
Hi, When writing IO version, I wasn't aware of other twister versions, and the only reason is/was that it was easiest to me and that I knew (believed) that plain lists would have been inefficient. I just wanted to see and learn, how close to C version this can be made. (And still do.) There

Re[2]: [Haskell-cafe] Basic Binary IO

2006-11-01 Thread Bulat Ziganshin
Hello Donald, Thursday, November 2, 2006, 4:31:31 AM, you wrote: Just an example, like opening file somefile and separating it into something that can be edited in the code (like 8 bit words) then go to word nr12 and edit the last bit? http://haskell.org/haskellwiki/Binary_IO For