Re: [Haskell-cafe] Made me smile

2007-05-19 Thread Andrew Coppin
Dan Piponi wrote: If you allow me to play Devil's advocate for a moment...just don't let this guy ask you how long the Haskell version takes. In fact, you can borrow a trick from the C++ version. Try this instead: import Data.Set main = interact $ unlines . toList . fromList . words Yes - I

Re: [Haskell-cafe] Short and sweet

2007-05-19 Thread Andrew Coppin
Rodrigo Queiro wrote: group collects equal elements in sublists. Thus, unique can be implemented as: unique = map head . group i.e. taking the first of each group of equal elements. (Yet) another way of doing this, is a modified quicksort: qsort [] = [] qsort (x:xs) = qsort (filter (x) xs) ++

[Haskell-cafe] Who lives in a heap like this?

2007-05-19 Thread Andrew Coppin
Greetings. I have just implemented a heap. But... um... I can't acutally figure out *which kind* of heap it is! LOL. Any ideas? (Seems to work really well, whatever it is. Oh, and I discovered that you can sort data just by shoving it all into a heap, and then taking it all out again.

Re: [Haskell-cafe] What really happens

2007-05-19 Thread Donald Bruce Stewart
andrewcoppin: Hi everybody. Is there any circumstances under which an expression like map (2*) would perform an in-place update rather than generating a new list? (Obviously Yes, should be fine, if the result is consumed. We have fusion frameworks that do this. this depends on which

[Haskell-cafe] Accepted by Hugs, not by GHC

2007-05-19 Thread Hans van Thiel
Hello All, Defining a partially ordered set as: data Porder = HI | LW | NT deriving (Eq) class (Eq a) = Poset a where pcompare :: a - a - Porder and defining an instance for type synonym RuRe: type RuRe = ([Int],[Int]) instance Poset RuRe where pcompare (x1,y1) (x2,y2)

Re: [Haskell-cafe] Accepted by Hugs, not by GHC

2007-05-19 Thread Hans van Thiel
On Sat, 2007-05-19 at 15:30 +0100, David House wrote: On 19/05/07, Hans van Thiel [EMAIL PROTECTED] wrote: causes no problems in Hugs (-98 flag) but compiling with GHC produces: There's the solution to your problem: type synonym instances aren't Haskell98, so you have to pass the -98 flag

Re: [Haskell-cafe] A small error

2007-05-19 Thread David House
On 19/05/07, Andrew Coppin [EMAIL PROTECTED] wrote: Um... why doesn't this work? my_fn x = do if x 0 then do let y = 5 return () else do let y = 8 return () print y (Error: y is not in scope.) let-blocks only scope over the do-block they're contained in.

Re: [Haskell-cafe] A small error

2007-05-19 Thread Andrew Coppin
David House wrote: On 19/05/07, Andrew Coppin [EMAIL PROTECTED] wrote: Um... why doesn't this work? my_fn x = do if x 0 then do let y = 5 return () else do let y = 8 return () print y (Error: y is not in scope.) let-blocks only scope over the do-block

Re: [Haskell-cafe] A small error

2007-05-19 Thread David House
On 19/05/07, Andrew Coppin [EMAIL PROTECTED] wrote: How about this? do y - if x 0 then do ... else do ... As with many other things in Haskell, the rule is Give it a go and see if it works! You should find that the above code runs fine. -- -David House, [EMAIL PROTECTED]

[Haskell-cafe] Re: Debunking tail recursion

2007-05-19 Thread Jon Fairbairn
David House [EMAIL PROTECTED] writes: On 18/05/07, Albert Y. C. Lai [EMAIL PROTECTED] wrote: Lazy evaluation says, to evaluate x, call f first, then x is the last call. x may be the last to be evaluated, but you still have to pass through f's call context 'on the way out'. Not exactly,

Re: [Haskell-cafe] Re: Debunking tail recursion

2007-05-19 Thread Ilya Tsindlekht
On Sat, May 19, 2007 at 04:10:29PM +0100, Jon Fairbairn wrote: [...] foldl f z l = case l of (x:xs) - foldl f (f z x) xs [] - z which reveals that foldl in the RHS isn't really the leftmost outermost function, but case is -- the tail call is to case. It

[Haskell-cafe] Haskell on OS X

2007-05-19 Thread Johan Tibell
I just switched to OS X and was wondering if someone would like to share their setup. Install binaries from haskell.org or Mac Ports? Which emacs build? etc Johan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Haskell on OS X

2007-05-19 Thread Tom Harper
I use Aquamacs with the haskell mode from haskell.org. MacPorts wasn't being useful with ghc, I downloaded binaries, and they work fine. On 5/19/07, Johan Tibell [EMAIL PROTECTED] wrote: I just switched to OS X and was wondering if someone would like to share their setup. Install binaries from

Re: [Haskell-cafe] Haskell on OS X

2007-05-19 Thread Johan Tibell
Is there a nice way to install the binaries and get the dependencies while still being able to easily uninstall the stuff (without a package manager)? What are the dependencies? On 5/19/07, Tom Harper [EMAIL PROTECTED] wrote: I use Aquamacs with the haskell mode from haskell.org. MacPorts

Re: [Haskell-cafe] Haskell on OS X

2007-05-19 Thread Pepe Iborra
MacPorts works fine here, and the maintainer, Gregory Wright, is very supportive. If it works for you, I really recommend MacPorts. The only downside are the lengthy compile times, but this is not a big deal, you can just leave it installing overnight. Carbon Emacs flavour here instead of

[Haskell-cafe] Pesky monads...

2007-05-19 Thread Andrew Coppin
I've been getting some pretty weird complaints from the type checker. And I just figured out why! Grr... Is there any function that does the same thing as until, but in a monad? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Pesky monads...

2007-05-19 Thread Matthew Cox
You can define one: untilM :: Monad m = (a - Bool) - (a - m a) - a - m a untilM pred f x | pred x = return x | otherwise = f x = untilM pred f Matthew Cox - Original Message - From: Andrew Coppin To: haskell-cafe@haskell.org Sent: Sat, 19 May 2007 19:49:40 +0100

Re: [Haskell-cafe] Pesky monads...

2007-05-19 Thread Andrew Coppin
Matthew Cox wrote: You can define one: untilM :: Monad m = (a - Bool) - (a - m a) - a - m a untilM pred f x | pred x = return x | otherwise = f x = untilM pred f Matthew Cox Hey, neat! :-D Mmm, I wonder if one could use fail to exit the loop instead... Oh, wait, for some

Re: [Haskell-cafe] Pesky monads...

2007-05-19 Thread Matthew Cox
It occurred to me that the predicate will generally be a monadic function itself, so here's a refined version: :: Monad m = (a - m Bool) - (a - m a) - a - m a untilM pred f x = do c - pred x if c then return x else f x = untilM pred f Think of a

[Haskell-cafe] Profiling, measuring time

2007-05-19 Thread Steffen Mazanek
Hello, I have written a function f, that performs a quite complex operation on its argument. Furthermore I have another function genInput that takes a number and constructs an argument for f of this size. What I want now is a list [(n,time)] that gives me for every size of input n the time, f

[Haskell-cafe] Scope of type variables in associated types

2007-05-19 Thread Matthew Sackman
The following doesn't seem to work. Is this a limitation of the current implementation or will it never work? Are there any work arounds without introducing extra type params into the data type E? class G a b | a - b where data E a :: * wrap :: b - E a unwrap :: E a - b instance

Re: [Haskell-cafe] Haskell on OS X

2007-05-19 Thread Aaron Tomb
I use the MacPorts package of GHC and Aquamacs (with haskell-mode). It works quite nicely for me. Fink also seems to have a GHC package, in case you prefer it. Aaron On May 19, 2007, at 11:24 AM, Johan Tibell wrote: I just switched to OS X and was wondering if someone would like to share

Re: [Haskell-cafe] Pesky monads...

2007-05-19 Thread haskell
I previously worked out how to use the monad transformers to make a when / repeat control structure that admitted both break and continue statements. It uses a ContT monad transformer to provide the escape semantics and the Reader to store the continuation. I'll paste the code here: -- By

Re: [Haskell-cafe] Haskell on OS X

2007-05-19 Thread Dan Piponi
On 5/19/07, Pepe Iborra [EMAIL PROTECTED] wrote: If it works for you, I really recommend MacPorts. The only downside are the lengthy compile times, but this is not a big deal, you can just leave it installing overnight. Ah, I'm glad you said that. I was wondering if some kind of bit rot was

[Haskell-cafe] idlelog

2007-05-19 Thread Leandro Lisboa Penz
Hi I made a program that detects user presence in a linux box by checking for keyboard interruptions in /proc/interrupts. Problem is, it is supposed to run for a long time, and it keeps about 40MB for itself. Yeah, this is one more help me with this memory problem mails... The code can

[Haskell-cafe] A special function

2007-05-19 Thread Andrew Coppin
I'd like to share something with you. I call it the evil *** function from hell: (Results xss) = f = Results $ map concat $ diagonalise $ map (foldr longZip [] . map (unpack . f)) xss If you attempt to comprehend how this function works, you WILL in fact loose your mind! However, it

[Haskell-cafe] Re: Debunking tail recursion

2007-05-19 Thread Jon Fairbairn
Ilya Tsindlekht [EMAIL PROTECTED] writes: On Sat, May 19, 2007 at 04:10:29PM +0100, Jon Fairbairn wrote: [...] foldl f z l = case l of (x:xs) - foldl f (f z x) xs [] - z which reveals that foldl in the RHS isn't really the leftmost outermost

[Haskell-cafe] idlelog

2007-05-19 Thread Leandro Lisboa Penz
Hi I made a program that detects user presence in a linux box by checking for keyboard interruptions in /proc/interrupts. Problem is, it is supposed to run for a long time, and it keeps about 40MB for itself. Yeah, this is one more help me with this memory problem mails... The code can

[Haskell-cafe] How do I insert an element in HaXml?

2007-05-19 Thread Jeremy Shaw
Hello, How do I create a HaXml filter that adds a new element as a child of an existing element. For example, let's say I have the XML document: a b/ c/ /a How do I add a new element under a / so that I have the document: a newElement/ b/ c/ /a The following works, but it seems very

Re: [Haskell-cafe] Who lives in a heap like this?

2007-05-19 Thread Rodrigo Queiro
I think (although I am far from an expert) that it is a skew heap, based on this: http://www.palgrave.com/pdfs/0333992857.pdf On 19/05/07, Andrew Coppin [EMAIL PROTECTED] wrote: Greetings. I have just implemented a heap. But... um... I can't acutally figure out *which kind* of heap it is!

Re: [Haskell-cafe] Re: Debunking tail recursion

2007-05-19 Thread Ilya Tsindlekht
On Sat, May 19, 2007 at 09:16:46PM +0100, Jon Fairbairn wrote: Ilya Tsindlekht [EMAIL PROTECTED] writes: By definition, tail recursive function is recursive function in which the value returned from a recursive call is immediately returned without modification as value of the top-level

Re: [Haskell-cafe] idlelog

2007-05-19 Thread Stefan O'Rear
On Sat, May 19, 2007 at 05:33:22PM -0300, Leandro Lisboa Penz wrote: Hi I made a program that detects user presence in a linux box by checking for keyboard interruptions in /proc/interrupts. Problem is, it is supposed to run for a long time, and it keeps about 40MB for itself.

[Haskell-cafe] Re: Scope of type variables in associated types

2007-05-19 Thread Matthew Sackman
On Sat, May 19, 2007 at 08:40:46PM +0100, Matthew Sackman wrote: The following doesn't seem to work. Is this a limitation of the current implementation or will it never work? Are there any work arounds without introducing extra type params into the data type E? class G a b | a - b where

Re: [Haskell-cafe] Pesky monads...

2007-05-19 Thread Donald Bruce Stewart
matt: It occurred to me that the predicate will generally be a monadic function itself, so here's a refined version: :: Monad m = (a - m Bool) - (a - m a) - a - m a untilM pred f x = do c - pred x if c then return x else f x = untilM pred f

Re: [Haskell-cafe] idlelog

2007-05-19 Thread Donald Bruce Stewart
lpenz: Hi I made a program that detects user presence in a linux box by checking for keyboard interruptions in /proc/interrupts. Problem is, it is supposed to run for a long time, and it keeps about 40MB for itself. Yeah, this is one more help me with this memory problem mails...

Re: [Haskell-cafe] Profiling, measuring time

2007-05-19 Thread Matthew Brecknell
Steffen Mazanek: I have written a function f, that performs a quite complex operation on its argument. Furthermore I have another function genInput that takes a number and constructs an argument for f of this size. What I want now is a list [(n,time)] that gives me for every size of

[Haskell-cafe] New YAHT maintainer

2007-05-19 Thread Eric Y. Kow
Hi, I just wanted to announce that Sam Hughes will be taking over as Keeper of the YAHT. YAHT is the venerable Yet Another Haskell Tutorial. It is available both as a wikibook and as a PDF (*). The Keeper of the YAHT has the grave duty of synchronising the YAHT wikibook and tex source, and