Re: [Haskell-cafe] strict bytestring fun

2007-02-06 Thread Donald Bruce Stewart
bertram.felgenhauer: Donald Bruce Stewart wrote: High performance strings on the shootout: http://shootout.alioth.debian.org/gp4/benchmark.php?test=sumcollang=all interesting alternative programs 0.5 Haskell GHC #5 1.2990,880270 1.0 Clean

[Haskell-cafe] Newbie: generating a truth table

2007-02-06 Thread phiroc
Hello, I would like to create a Haskell function that generates a truth table, for all Boolean values, say, using the following and function : and :: Bool - Bool - Bool and a b = a b I have tried creating a second function called loop, which repeatedly calls and, but it did not work, because,

Re: [Haskell-cafe] Newbie: generating a truth table

2007-02-06 Thread Ketil Malde
[EMAIL PROTECTED] wrote: I would like to create a Haskell function that generates a truth table, for all Boolean values, say, using the following and function : and :: Bool - Bool - Bool and a b = a b What is the type of the resulting table? I have tried creating a second function called

Re: [Haskell-cafe] Newbie: generating a truth table

2007-02-06 Thread phiroc
Ketil, thanks for you help. Here's the code: and2 :: Bool - Bool - Bool and2 a b = a b loop = [ and2 x y | x - [True,False], y - [True,False] ] Now, how do I have Haskell print printStrLn(True and True = ) + result of calling and2 True True printStrLn(True and False = ) + result of

Re: [Haskell-cafe] Newbie: generating a truth table

2007-02-06 Thread Lennart Augustsson
It would be better to produce a triple (as was suggested) loop = [(x, y, xy) | x - [True, False], y - [True, False]] The you can map a function that prints over that. Or even better map a function that generates the strings, and the use one big putStr at the end. Always try to separate IO

Re: [Haskell-cafe] Newbie: generating a truth table

2007-02-06 Thread Ketil Malde
[EMAIL PROTECTED] wrote: Ketil, thanks for you help. Here's the code: and2 :: Bool - Bool - Bool and2 a b = a b loop = [ and2 x y | x - [True,False], y - [True,False] ] Now, how do I have Haskell print printStrLn(True and True = ) + result of calling and2 True True printStrLn(True and

Re: [Haskell-cafe] Newbie: generating a truth table

2007-02-06 Thread Dougal Stanton
Quoth [EMAIL PROTECTED], nevermore, loop = do and True True and True False and False True and False False For this construct to work you'd have to have 'and' as a monadic function - let's say, for argument's sake, in IO. And because there are no results being

Re: [Haskell-cafe] Trouble representing a set of flags

2007-02-06 Thread Duncan Coutts
On Mon, 2007-02-05 at 19:26 -0800, Stefan O'Rear wrote: I have a structure: data Attr = Attr { fg :: !Color, bg :: !Color, bold :: !Bool, blink :: !Bool, rv :: !Bool, halfBright :: !Bool,

[Haskell-cafe] Function Composition

2007-02-06 Thread Chris Witte
Can anyone explain why Shape.Polygon would have a different type to (Shape).Polygon, I thought the brackets would be redundant. Here is the output from a Hugs session Animation :v -- Hugs Version 20050113 Animation :t Shape Shape :: Shape - Region Animation :t Polygon Polygon :: [Vertex] - Shape

Re: [Haskell-cafe] Function Composition

2007-02-06 Thread Andres Loeh
Can anyone explain why Shape.Polygon would have a different type to (Shape).Polygon, I thought the brackets would be redundant. Here is the output from a Hugs session Animation :v -- Hugs Version 20050113 Animation :t Shape Shape :: Shape - Region Animation :t Polygon Polygon ::

Re: [Haskell-cafe] Newbie: generating a truth table

2007-02-06 Thread phiroc
Hello, how would you convert Boolean triples to strings, in the IO function? printStrings :: (Bool,Bool,Bool) - IO () phiroc Quoting Lennart Augustsson [EMAIL PROTECTED]: It would be better to produce a triple (as was suggested) loop = [(x, y, xy) | x - [True, False], y - [True, False]]

[Haskell-cafe] Re: Importance of MonadRandom

2007-02-06 Thread Yitzchak Gale
I wrote: Cale Gibbard's MonadRandom... I would like to suggest a change to the interface... class (Monad m) = MonadRandom m where nextR :: m Int splitR :: m (m ()) rangeR :: m (Int, Int) getR :: (forall g . RandomGen g = g - a) - m a I see that I have inadvertently done two things

Re: [Haskell-cafe] Final issues to fix for the shootout entries (Was: no subject)

2007-02-06 Thread Tomasz Zielonka
On Tue, Feb 06, 2007 at 12:12:09PM +1100, Donald Bruce Stewart wrote: And note that strings aren't a bottleneck anymore! http://shootout.alioth.debian.org/gp4/benchmark.php?test=sumcollang=all I think Haskell GHC #2 doesn't play by the rules: diff program output for this 6KB

[Haskell-cafe] blog: Is C# becoming a functional language?

2007-02-06 Thread Bulat Ziganshin
Hello haskell-cafe, this seems like a comprehensive overview of FP facilities in C# 3.0: http://blogs.msdn.com/madst/archive/2007/01/23/is-c-becoming-a-functional-language.aspx -- Best regards, Bulat mailto:[EMAIL PROTECTED]

Re: [Haskell-cafe] Newbie: generating a truth table

2007-02-06 Thread Martin DeMello
On 2/6/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hello, how would you convert Boolean triples to strings, in the IO function? printStrings :: (Bool,Bool,Bool) - IO () Take a look at 'show': Prelude show True True martin ___ Haskell-Cafe

Re: [Haskell-cafe] Re: Generalizing three programs

2007-02-06 Thread Yitzchak Gale
apfelmus wrote: I'm unsure whether it's a good idea to simulate the situations, I'd prefer a more denotational approach... Queuing theory is a very large and mature area of research, with many important applications in industry. It is not a coincidence that a certain telephone company named a

Re: [Haskell-cafe] Re: Generalizing three programs

2007-02-06 Thread Bjorn Lisper
Queuing theory is a very large and mature area of research, with many important applications in industry. It is not a coincidence that a certain telephone company named a functional programming language after Erlang, the founder of queuing theory. Erlang actually stands for Ericsson Language. I

Re: [Haskell-cafe] Re: Generalizing three programs

2007-02-06 Thread Ketil Malde
Bjorn Lisper wrote: Erlang actually stands for Ericsson Language. I think the alternative interpretation is intentional, though. According to this: http://www.erlang.org/pipermail/erlang-questions/1999-February/98.html A.K.E. was the actual origin, but with an intentional ambiguity.

[Haskell-cafe] haskell and releasing resources

2007-02-06 Thread Fawzi Mohamed
I am just coming to haskell, and I wrote a simple command to get some input from a pdf file I just wanted the output of the command so I did something like import System.Process (runInteractiveCommand) import IO (hGetContents) -- | returns the text of the first page of the pdf at the given

Re: [Haskell-cafe] haskell and releasing resources

2007-02-06 Thread Donald Bruce Stewart
fmohamed: I am just coming to haskell, and I wrote a simple command to get some input from a pdf file I just wanted the output of the command so I did something like import System.Process (runInteractiveCommand) import IO (hGetContents) -- | returns the text of the first page of the

Re: [Haskell-cafe] haskell and releasing resources

2007-02-06 Thread Fawzi Mohamed
[...] Wait for the process to terminate, using waitForProcess pid Thanks fro the prompt response Don, I should have said it, but I knew about waitForProcess pid but I did not want to use it. The reason is the following, if I do getTextOfPdf pdfPath = do (inp,out,err,pid) -

Re: [Haskell-cafe] haskell and releasing resources

2007-02-06 Thread Fawzi Mohamed
I am replying to myself, but anyway with it seems (from the documentation) that forkIO (do{ waitForProcess pid; return () }) is the best solution, and does not seem to lead to wasted resources. Anyway I am still interested in knowing if there are better solutions, or other places where

[Haskell-cafe] Portable implementation of unsafeCoerce

2007-02-06 Thread Alfonso Acosta
Hi all, Reading the sources of Lava (a Haskell Hardware Description DSL) I run into this definition ... unsafeCoerce :: a - b unsafeCoerce a = unsafePerformIO $ do writeIORef ref a readIORef ref where ref = unsafePerformIO $ do newIORef undefined Is this actually equivalent to the

Re: [Haskell-cafe] Re: nested maybes

2007-02-06 Thread Yitzchak Gale
J. Garrett Morris wrote: Again, from the earlier example, I'm not sure how typing: apply :: (MonadCont m, MonadState Blargh m, MonadError Fzzt m, MonadIO m) = Handle - Attribute a - m a is simpler than apply :: Handle - Attribute a - m a Well, no, but it is at least no worse than apply

Re: [Haskell-cafe] Portable implementation of unsafeCoerce

2007-02-06 Thread Neil Mitchell
Hi Alfonso, Reading the sources of Lava (a Haskell Hardware Description DSL) I run into this definition ... unsafeCoerce :: a - b Is this actually equivalent to the infamous unsafeCoerce# ? Yes, see the comment in the haddock documentation for unsafePerformIO:

[Haskell-cafe] Re: Importance of MonadRandom

2007-02-06 Thread Cale Gibbard
The splittable idea isn't mine, it looks like perhaps Remi Turk did it. One thing which I'd recommend is including getRandom, getRandomR as implemented in terms of getR and the ordinary random operations, simply because they're the two most common uses, it's probably worth it to define them

Re: [Haskell-cafe] blog: Is C# becoming a functional language?

2007-02-06 Thread Sebastian Sylvan
On 2/6/07, Bulat Ziganshin [EMAIL PROTECTED] wrote: Hello haskell-cafe, this seems like a comprehensive overview of FP facilities in C# 3.0: http://blogs.msdn.com/madst/archive/2007/01/23/is-c-becoming-a-functional-language.aspx If it ain't pure, it ain't functional! ;-) -- Sebastian

[Haskell-cafe] External Core

2007-02-06 Thread Ricky Barefield
Dear All, For the last year I've been working on a program to translate between Haskell and Java. Originally this was for my third year dissertation to contribute towards my Masters in computer science at Sheffield University, UK. I have been given the opportunity to continue this project and

Re: [Haskell-cafe] External Core

2007-02-06 Thread Neil Mitchell
Hi Ricky, For the last year I've been working on a program to translate between Haskell and Java. Originally this was for my third year dissertation to contribute towards my Masters in computer science at Sheffield University, UK. I have been given the opportunity to continue this project and

Re: [Haskell-cafe] External Core

2007-02-06 Thread Kirsten Chevalier
On 2/6/07, Ricky Barefield [EMAIL PROTECTED] wrote: I've tried running Happy on these files but get the error `Not enough type arguments for the type synonym P' when I try to run the resultant Parser.hs in Hugs and similar errors when run in GHC. What I'm trying to achieve is to read the

[Haskell-cafe] Re: How did you stumble on Haskell?

2007-02-06 Thread Jesse Tov
Mikael Johansson wrote: I read sigfpe and got interested. I read sigsegv and got interested :) Jesse ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] haskell and releasing resources

2007-02-06 Thread Fawzi Mohamed
On Feb 6, 2007, at 8:39 PM, David Waern wrote: Wait for the process to terminate, using waitForProcess pid I've a sketch for a nice wrapper for the low level process code here, http://www.cse.unsw.edu.au/~dons/code/newpopen/ What's missing? I'd like to use it, but I don't like

Re: [Haskell-cafe] Re: How did you stumble on Haskell?

2007-02-06 Thread Dan Piponi
I've always found recursive solutions to problems elegant and I've always been fed up of people telling me that I should rewrite recursive solutions iteratively. (Annoying as it is, many people do that.) I complained about this on K5 and solicited some opinions from others on whether or not they

Re: [Haskell-cafe] Newbie: generating a truth table

2007-02-06 Thread Philippe de Rochambeau
Hello, the following code --- import Stdm -- From Discrete Mathematics Using a Computer, by Cordelia Hall and John O'Donnell. pImpliesQAndR :: [Bool] - Bool pImpliesQAndR (p:q:r:[]) = p == ( q /\ r )

Re: [Haskell-cafe] Newbie: generating a truth table

2007-02-06 Thread Yitzchak Gale
Philippe de Rochambeau wrote: I have tried map (putStrLn) pImpliesQAndRLoopShow but that results in the following error message: Try mapM_ putStrLn pImpliesQAndRLoopShow or putStrLn $ unlines pImpliesQAndRLoopShow Regards, Yitz ___ Haskell-Cafe

Re: [Haskell-cafe] Re: How did you stumble on Haskell?

2007-02-06 Thread Andrew Wagner
Heh. I still remember in my first Comp Sci class, in C, I had to take a 2-line recursive tree traversal...and write it iteratively (in like 50 lines). On 2/6/07, Dan Piponi [EMAIL PROTECTED] wrote: I've always found recursive solutions to problems elegant and I've always been fed up of people

Re: [Haskell-cafe] haskell and releasing resources

2007-02-06 Thread David Waern
6 feb 2007 kl. 22.33 skrev Fawzi Mohamed: On Feb 6, 2007, at 8:39 PM, David Waern wrote: Wait for the process to terminate, using waitForProcess pid I've a sketch for a nice wrapper for the low level process code here, http://www.cse.unsw.edu.au/~dons/code/newpopen/ What's

Re: [Haskell-cafe] How did you stumble on Haskell?

2007-02-06 Thread Paul Brown
On 1/28/07, Alexy Khrabrov [EMAIL PROTECTED] wrote: How do people stumble on Haskell? I came at it from two angles: General interest in actor languages led me to Io (http://www.iolanguage.com), which used Darcs for its RCS at the time, which led me to look at the source code for it, which got

Re: [Haskell-cafe] haskell and releasing resources

2007-02-06 Thread Donald Bruce Stewart
davve: Wait for the process to terminate, using waitForProcess pid I've a sketch for a nice wrapper for the low level process code here, http://www.cse.unsw.edu.au/~dons/code/newpopen/ What's missing? I'd like to use it, but I don't like unreleased libraries :) Last time I

Re: [Haskell-cafe] haskell and releasing resources

2007-02-06 Thread Joachim Breitner
Hi, Am Dienstag, den 06.02.2007, 15:56 +0100 schrieb Fawzi Mohamed: I am replying to myself, but anyway with it seems (from the documentation) that forkIO (do{ waitForProcess pid; return () }) is the best solution, and does not seem to lead to wasted resources. This does not work

Re: [Haskell-cafe] haskell and releasing resources

2007-02-06 Thread Donald Bruce Stewart
mail: Hi, Am Dienstag, den 06.02.2007, 15:56 +0100 schrieb Fawzi Mohamed: I am replying to myself, but anyway with it seems (from the documentation) that forkIO (do{ waitForProcess pid; return () }) is the best solution, and does not seem to lead to wasted resources.

[Haskell-cafe] Re: Re: nested maybes

2007-02-06 Thread Benjamin Franksen
Udo Stenzel wrote: Benjamin Franksen wrote: Udo Stenzel wrote: Sure, you're right, everything flowing in the same direction is usually nicer, and in central Europe, that order is from the left to the right. What a shame that the Haskell gods chose to give the arguments to (.) and ($) the

Re: [Haskell-cafe] IO is not a monad

2007-02-06 Thread Aaron McDaid
Hi, Apologies for referring to this old thread... I rearranged the code a little bit while experimenting but retained the same behaviour: Prelude let f = undefined :: Int - IO Int Prelude (f 3 f 3) `seq` 42 42 Prelude (f 3) `seq` 42 *** Exception: Prelude.undefined I think

Re: [Haskell-cafe] External Core

2007-02-06 Thread Aaron Tomb
I am still working on it. Some external events have slowed me down a little (research, classes, appendicitis), and it has involved more changes to the innards of GHC than anticipated, but it is still moving along. If you can wait a little while, it should be possible to use GHC. A slight

Re: [Haskell-cafe] Re: nested maybes

2007-02-06 Thread J. Garrett Morris
On 2/6/07, Yitzchak Gale [EMAIL PROTECTED] wrote: J. Garrett Morris wrote: Well, no, but it is at least no worse than apply :: Handle - Attribute a - ContT (StateT Blargh (ErrorT Fzzt IO)) a I find that in general, many functions do not need all of the capabilities. If they do, you can alias