Re: [Haskell-cafe] Spurious program crashes

2005-11-22 Thread Joel Reymont
I was under the impression that STM code needed to be in its own monad. I was looking at Control.Concurrent.STM.TChan, for example, where signatures like this exist: newTChan :: STM (TChan a) readTChan :: TChan a - STM a writeTChan :: TChan a - a - STM () and then

[Haskell-cafe] Re: Frag: a First Person Shooting game

2005-11-22 Thread Joel Reymont
Mun, I hope this ushers the era of Haskell games! I, for one, was certainly looking for something like this. Did you encounter any difficulties in your development because of Haskell? Was lazy evaluation ever a problem? Why did you choose Yampa to program the game entities? Did this

Re: [Haskell-cafe] Records

2005-11-22 Thread Antti-Juhani Kaijanaho
Tomasz Zielonka wrote: Aren't C and C++ space insensitive (except the preprocessor)? Literally, yes, because the C and C++ compilers proper take preprocessor tokens, not strings, as input, and hence do not see the whitespace at all; the whitespace-sensitive tokenization having been completed by

Re: [Haskell-cafe] Spurious program crashes

2005-11-22 Thread Tomasz Zielonka
On Tue, Nov 22, 2005 at 08:30:33AM +, Joel Reymont wrote: I was under the impression that STM code needed to be in its own monad. I was looking at Control.Concurrent.STM.TChan, for example, where signatures like this exist: newTChan :: STM (TChan a) readTChan :: TChan a - STM a

Re: [Haskell-cafe] Records

2005-11-22 Thread Tomasz Zielonka
On Tue, Nov 22, 2005 at 10:39:22AM +0200, Antti-Juhani Kaijanaho wrote: Tomasz Zielonka wrote: Aren't C and C++ space insensitive (except the preprocessor)? (In a totally space insensitive language, andy and and y would be tokenized the same way.) Ah, I was wrong, here are some examples:

Re: [Haskell-cafe] Spurious program crashes

2005-11-22 Thread Joel Reymont
Tomasz, I think it's much simpler than that. I just changed the trace function to send Just String down the channel. Whenever I send Nothing (from waitForChildren) the logger just exits. Simple change in two places, no need for MVars. Did I miss anything? The program became much

Re: [Haskell-cafe] Spurious program crashes

2005-11-22 Thread Tomasz Zielonka
On Tue, Nov 22, 2005 at 09:03:55AM +, Joel Reymont wrote: I think it's much simpler than that. I just changed the trace function to send Just String down the channel. Whenever I send Nothing (from waitForChildren) the logger just exits. Simple change in two places, no need for MVars.

Re: [Haskell-cafe] Spurious program crashes

2005-11-22 Thread Joel Reymont
Yes in the sense that more than a few lines of code are now printed on Windows. Not in the sense of the topic of this thread but then it seems to be a Mac OSX-only issue. Thanks, Joel On Nov 22, 2005, at 9:14 AM, Tomasz Zielonka wrote: The program became much snappier, btw. Did

Re[2]: [Haskell-cafe] Spurious program crashes

2005-11-22 Thread Bulat Ziganshin
Hello Joel, Tuesday, November 22, 2005, 1:41:38 AM, you wrote: JR logger h die = JR do empty - isEmptyChan parent JR unless empty $ do x - readChan parent JR putStrLn x JR hPutStrLn h x JR alive - isEmptyMVar die JR

Re[2]: [Haskell-cafe] re-definition of '.'

2005-11-22 Thread Bulat Ziganshin
Hello Max, Tuesday, November 22, 2005, 2:30:23 AM, you wrote: 2) sequential functions application in OOP style: [1..100] .map (2*) .sum ME Great proposal! And the only feature haskell will lack is computable go to! ME And if we add both haskell would become the most expressive and ME

Re: [Haskell-cafe] Records (was Re: [Haskell] Improvements to GHC)

2005-11-22 Thread Wolfgang Jeltsch
Am Montag, 21. November 2005 20:51 schrieb Henning Thielemann: On Mon, 21 Nov 2005, Wolfgang Jeltsch wrote: [...] Hmm, printing code on paper isn't good for the environment. But is quite the same argument for e-paper. :-) I already thought about this. But if your computer is turned on

Re[2]: [Haskell-cafe] Spurious program crashes

2005-11-22 Thread Bulat Ziganshin
Hello Joel, Tuesday, November 22, 2005, 12:03:55 PM, you wrote: JR I think it's much simpler than that. I just changed the trace JR function to send Just String down the channel. Whenever I send JR Nothing (from waitForChildren) the logger just exits. Simple change JR in two places, no need

Re: [Haskell-cafe] records proposals list

2005-11-22 Thread Wolfgang Jeltsch
Am Dienstag, 22. November 2005 07:33 schrieb David Menendez: Keean Schupke writes: Haskell already has static records (in H98) Dynamic records are addressed by the HList library, which uses extensions already present in GHC and Hugs (namely Multi-parameter type-classes and

Re: [Haskell-cafe] records proposals list

2005-11-22 Thread Wolfgang Jeltsch
Am Montag, 21. November 2005 20:34 schrieb Max Eronin: On 11/21/05, David Roundy [EMAIL PROTECTED] wrote: class Coord a where get_x :: a - Double get_y :: a - Double set_x :: Double - a - a set_y :: Double - a - a I'd say this is a typical OO solution to the problem that

Re: Re[2]: [Haskell-cafe] Spurious program crashes

2005-11-22 Thread Joel Reymont
This is the approach that I went with, thanks. On Nov 22, 2005, at 9:26 AM, Bulat Ziganshin wrote: can you just send Die message through the same Chan? it will be best solution. you can even write: -- http://wagerlabs.com/ ___ Haskell-Cafe

[Haskell-cafe] GHCi always optimizes?

2005-11-22 Thread Dusan Kolar
Hello all, My question is rather strange, maybe, even if simple: Does ghci always translates with -O option set on? I've done some measurements on an application using ghc and ghci. ghc compiled with no opmitization = program running real988m59.260s user989m1.325s sys 0m0.704s

[Haskell-cafe] Existential quantification of environments.

2005-11-22 Thread Keean Schupke
If I have a function: f x y = add x y and I want to type the function in isolation, then the type of 'add' is essentially carried in the environment... Lets say I want to make this type explicit in the type signature (where f is valid for any a where there is an add function on a -

Re: [Haskell-cafe] records proposals list

2005-11-22 Thread Keean Schupke
The HList code does not need overlapping-instances, however it does use undecidable instances. This is not however bad like overlapping instances is. Overlapping instances can break module independance (as in defining a new instance can change the meaning of an existing class in modules that

Re: [Haskell-cafe] records proposals list

2005-11-22 Thread Keean Schupke
My mistake, what you want is: ( mything .=. something .*. value .=. (27::Int) .*. logic .=. True .*. HNil ) Admittedly the label creation would benefit from some syntactic sugar to reduce typing... Keean. Bulat Ziganshin wrote: Hello Keean, Monday, November 21, 2005, 6:56:06

Re: [Haskell-cafe] Records

2005-11-22 Thread Ketil Malde
Cale Gibbard [EMAIL PROTECTED] writes: This really isn't so bad in practice though. I've certainly never been confused by it. Well, what can I say? Good for you? You'd have to go out of your way to construct a situation in which it's potentially confusing No. There are much more

Re: [Haskell-cafe] records proposals list

2005-11-22 Thread Keean Schupke
Just a follow up to my last post ... The HList paper also presents a way of removing overlapping instances from _any_ class. So infact support for overlapping instances is no longer required - and this removes all the messy problems with overlapping instances and functional dependancies. The

Re: [Haskell-cafe] Records

2005-11-22 Thread Keean Schupke
Just my 2p worth... If I were designing a language I would not have used the '.' like Haskell does. One problem is that ascii does not support enough symbols (Hmm, PL1 here we come). I guess my vote would go to keeping the '.' as is to not break existing programs, and using a different symbol

Re: [Haskell-cafe] Existential quantification of environments.

2005-11-22 Thread Adrian Hey
On Tuesday 22 Nov 2005 10:39 am, Keean Schupke wrote: If I have a function: f x y = add x y and I want to type the function in isolation, then the type of 'add' is essentially carried in the environment... I am no expert in type theory so I'm probably about to get way out of my depth,

Re: [Haskell-cafe] Existential quantification of environments.

2005-11-22 Thread Keean Schupke
Excellent link thanks! Not quite what I was thinking of - but definitely related. I'll give it a read and see if they want to existentially quantify environments... Keean. Adrian Hey wrote: On Tuesday 22 Nov 2005 10:39 am, Keean Schupke wrote: If I have a function: f x y = add x y

Re: [Haskell-cafe] How to use notFollowedBy function in Parsec

2005-11-22 Thread Daniel Fischer
Am Montag, 21. November 2005 03:27 schrieb Sara Kenedy: May I suggest endBy anyToken semi ? -- optionally replace semi by char ';', if you don't want to skip whitespace I think this is what you want --- stop at the first semicolon. If you want to ignore just a final semicolon, you might use

Re: [Haskell-cafe] How to use notFollowedBy function in Parsec

2005-11-22 Thread Daniel Fischer
Am Dienstag, 22. November 2005 14:51 schrieben Sie: Am Montag, 21. November 2005 03:27 schrieb Sara Kenedy: May I suggest endBy anyToken semi ? -- optionally replace semi by char ';', if you Oops, I confused endBy and manyTill !! Also below. And since maybe there isn't any

Re: [Haskell-cafe] How to use notFollowedBy function in Parsec

2005-11-22 Thread Sara Kenedy
Hello, I run as follows: simple::Parser String simple = do manyTill anyToken (semi | eof) run:: Show a = Parser a - String - IO() run p input = case (parse p input) of Left err - do {putStr parse error at ;print err} Right x - print x

Re: [Haskell-cafe] How to use notFollowedBy function in Parsec

2005-11-22 Thread Daniel Fischer
Am Dienstag, 22. November 2005 15:58 schrieben Sie: Hello, I run as follows: simple::Parser String simple = do manyTill anyToken (semi | eof) run:: Show a = Parser a - String - IO() run p input = case (parse p input) of Left err - do {putStr parse error at ;print

Re: [Haskell-cafe] Existential quantification of environments.

2005-11-22 Thread Wolfgang Jeltsch
Am Dienstag, 22. November 2005 11:39 schrieb Keean Schupke: [...] This seems to suggest: Add a == exists (add :: a - a - a) Doesn't exists normally quantify over types and not over values? [...] Best wishes, Wolfgang ___ Haskell-Cafe mailing

Re: [Haskell-cafe] Re: Pickling HList

2005-11-22 Thread Keean Schupke
This function is already in the HList library (well early versions anyway)... I dont think this is in the current distribution. Its a generic constructor wrapper. For example: hMarkAll Just hlist class HList l = HMarkAll c l m | c l - m where hMarkAll :: (forall a . a - c a) -

[Haskell-cafe] using of data types as kinds

2005-11-22 Thread Bulat Ziganshin
Hello , in the HCAR GHC team wrote On the type system front, we hope to ... Allow you to use data types as kinds, in a manner similar to Tim Sheardâ–“s Omega language. can someone point me where i can read about this? -- Best regards, Bulat mailto:[EMAIL PROTECTED]

Re: [Haskell-cafe] Existential quantification of environments.

2005-11-22 Thread Keean Schupke
Wolfgang Jeltsch wrote: This seems to suggest: Add a == exists (add :: a - a - a) Doesn't exists normally quantify over types and not over values? It is quantifying over types, it is saying there exists a type a - a - a that has at least one value we will call add... I think

Re: [Haskell-cafe] Re: Pickling HList

2005-11-22 Thread Joel Reymont
Keean, I sort of gave up on HList for the time being since I found easier ways to solve my problem. Mainly, I could not estimate the impact it would have on run-time performance of my code and GHC not being able to compile the code was not a good indication. Simon PJ fixed that error

Re: [Haskell-cafe] Re: Pickling HList

2005-11-22 Thread Keean Schupke
That all depends... In theory all the HList stuff happens at compile time, and what you are left with is normal function application... Of course compilers arn't that good yet, but as a reasonable idea, consider just that value level... Most of the extra work is the packing/unpacking of pairs

RE: [Haskell-cafe] using of data types as kinds

2005-11-22 Thread Simon Peyton-Jones
Read about Omega! I have not written anything about what I plan to do in GHC, but basically it amounts to allowing you to use a data type as a kind. Busy doing GADTs and impredicativity at the moment though Simon | -Original Message- | From: [EMAIL PROTECTED] [mailto:[EMAIL

RE: [Haskell-cafe] using of data types as kinds

2005-11-22 Thread Greg Woodhouse
--- Simon Peyton-Jones [EMAIL PROTECTED] wrote: Read about Omega! I will. Busy doing GADTs and impredicativity at the moment though Impredicativity? === Gregory Woodhouse [EMAIL PROTECTED] Interaction is the mind-body problem of computing. --Philip Wadler

Re: [Haskell-cafe] GHCi always optimizes?

2005-11-22 Thread Tomasz Zielonka
On Tue, Nov 22, 2005 at 11:07:07AM +0100, Dusan Kolar wrote: To be honest, I don't mind ghci optimizes always but saying it uses the same options as ghc is not entirely true and, for optimization, it's quite painful because one searches error where it is not. I think the real source of your

[Haskell-cafe] Shortening if-then-else

2005-11-22 Thread Joel Reymont
Is there a shorter way to write the if-then-else part below? -- tryTakeSeat :: [Word8] - Word8 - ScriptState (Maybe Word8) tryTakeSeat _ _ = do ... if (cmdType cmd) /= (CmdSitError Server) then return $ Just seat_num else return Nothing -- Thanks, Joel --

Re: [Haskell-cafe] Shortening if-then-else

2005-11-22 Thread Arjan van IJzendoorn
Is there a shorter way to write the if-then-else part below? if (cmdType cmd) /= (CmdSitError Server) then return $ Just seat_num else return Nothing return $ if cmdType cmd /= CmdSitError Serv then Just seat_num else Nothing Arjan

Re: [Haskell-cafe] Records

2005-11-22 Thread Sven Panne
I think this discussion has reached a point where it is of utmost importance to re-read Wadler's Law of Language Design, a law so fundamental to computer science that it can only be compared to quantum dynamics in physics: http://www.informatik.uni-kiel.de/~mh/curry/listarchive/0017.html

Re: [Haskell-cafe] Shortening if-then-else

2005-11-22 Thread Matthias Neubauer
Arjan van IJzendoorn [EMAIL PROTECTED] writes: Is there a shorter way to write the if-then-else part below? if (cmdType cmd) /= (CmdSitError Server) then return $ Just seat_num else return Nothing return $ if cmdType cmd /= CmdSitError Serv then

Re: [Haskell-cafe] Records

2005-11-22 Thread Greg Woodhouse
--- Sven Panne [EMAIL PROTECTED] wrote: I think this discussion has reached a point where it is of utmost importance to re-read Wadler's Law of Language Design, a law so fundamental to computer science that it can only be compared to quantum dynamics in physics:

Re: [Haskell-cafe] Shortening if-then-else

2005-11-22 Thread Henning Thielemann
On Tue, 22 Nov 2005, Matthias Neubauer wrote: Arjan van IJzendoorn [EMAIL PROTECTED] writes: Is there a shorter way to write the if-then-else part below? if (cmdType cmd) /= (CmdSitError Server) then return $ Just seat_num else return Nothing return $ if cmdType

Re: [Haskell-cafe] Records

2005-11-22 Thread Sven Panne
Am Dienstag, 22. November 2005 19:30 schrieb Greg Woodhouse: To be honest, I haven't followed the entire records thread (at least not yet), but I don't know that it's fair to say that we've been focusing entirely (or nearly so) on lexical issues. I'll grant you that there's an awful lot of

Re: [Haskell-cafe] Existential quantification of environments.

2005-11-22 Thread Wolfgang Jeltsch
Am Dienstag, 22. November 2005 17:19 schrieben Sie: Wolfgang Jeltsch wrote: This seems to suggest: Add a == exists (add :: a - a - a) Doesn't exists normally quantify over types and not over values? It is quantifying over types, it is saying there exists a type a - a - a that has at

Re[2]: [Haskell-cafe] using of data types as kinds

2005-11-22 Thread Bulat Ziganshin
Hello Greg, Tuesday, November 22, 2005, 8:24:41 PM, you wrote: Busy doing GADTs and impredicativity at the moment though GW Impredicativity? just in the case you don't have time to read HCAR ;) some excerpt from there: 2.1 The Glasgow Haskell Compiler There is lots more in the

Re[2]: [Haskell-cafe] using of data types as kinds

2005-11-22 Thread Bulat Ziganshin
Hello Simon, Tuesday, November 22, 2005, 8:17:38 PM, you wrote: SPJ I have not written anything about what I plan to do in GHC, but SPJ basically it amounts to allowing you to use a data type as a SPJ kind. Busy doing GADTs and impredicativity at the moment though Simon, i can't download file

Re[2]: [Haskell-cafe] Shortening if-then-else

2005-11-22 Thread Bulat Ziganshin
Hello Matthias, Tuesday, November 22, 2005, 9:17:57 PM, you wrote: MN return $ guard (cmdType cmd /= CmdSitError Serv) return seat_num return $ when (cmdType cmd /= CmdSitError Serv) (return seat_num) must also work :) -- Best regards, Bulatmailto:[EMAIL

Re: [Haskell-cafe] using of data types as kinds

2005-11-22 Thread kyra
Bulat Ziganshin wrote: Hello Simon, Tuesday, November 22, 2005, 8:17:38 PM, you wrote: SPJ I have not written anything about what I plan to do in GHC, but SPJ basically it amounts to allowing you to use a data type as a SPJ kind. Busy doing GADTs and impredicativity at the moment though

Re: [Haskell-cafe] Shortening if-then-else

2005-11-22 Thread Tomasz Zielonka
On Tue, Nov 22, 2005 at 10:15:15PM +0300, Bulat Ziganshin wrote: Tuesday, November 22, 2005, 9:17:57 PM, you wrote: MN return $ guard (cmdType cmd /= CmdSitError Serv) return seat_num return $ when (cmdType cmd /= CmdSitError Serv) (return seat_num) must also work :) But it won't. I

Re: [Haskell-cafe] Shortening if-then-else

2005-11-22 Thread Joel Reymont
Why wouldn't Bulat's version work? I don't think it will work for me either way as I'm returning m (Maybe Int) where m is my own monad. It seems that folks assumed that m itself was the maybe monad. Unless I'm mistaken the code below won't work otherwise. On Nov 22, 2005, at 8:50 PM,

Re: [Haskell-cafe] Shortening if-then-else

2005-11-22 Thread Matthias Neubauer
Bulat Ziganshin [EMAIL PROTECTED] writes: Hello Matthias, Tuesday, November 22, 2005, 9:17:57 PM, you wrote: MN return $ guard (cmdType cmd /= CmdSitError Serv) return seat_num return $ when (cmdType cmd /= CmdSitError Serv) (return seat_num) must also work :) Only if seat_num is of

Re: [Haskell-cafe] Shortening if-then-else

2005-11-22 Thread Yitzchak Gale
Is there a shorter way to write the if-then-else part below? -- tryTakeSeat :: [Word8] - Word8 - ScriptState (Maybe Word8) tryTakeSeat _ _ = do ... if (cmdType cmd) /= (CmdSitError Server) then return $ Just seat_num else return Nothing -- tryTakeSeat _ _

Re: [Haskell-cafe] Shortening if-then-else

2005-11-22 Thread Matthias Neubauer
Joel Reymont [EMAIL PROTECTED] writes: I don't think it will work for me either way as I'm returning m (Maybe Int) where m is my own monad. It seems that folks assumed that m itself was the maybe monad. Unless I'm mistaken the code below won't work otherwise. There are two monads involved.

Re: [Haskell-cafe] Function application like a Unix pipe

2005-11-22 Thread Scherrer, Chad
Albert Lai [EMAIL PROTECTED] writes: I offer a simpler, more direct, and pre-existing correspondence between a functional programming construct and unix pipes: Maybe my point wasn't clear. Of course this idea of comparing lazy evaluation to Unix pipes is very old (long before July 2004, I'm

[Haskell-cafe] Monad Transformer question

2005-11-22 Thread Fan Wu
Hi Haskell gurus, I'm learning Haskell now and here I'm quite puzzled over some code about Monad Transformers. The code is like: type NDS a = StateT ProblemState [] a getVar :: Var - NDS (Maybe Value) getVar v = do vs - gets vars return $ lookup v vs What puzzles me

Re: [Haskell-cafe] Monad Transformer question

2005-11-22 Thread Andrew Pimlott
On Tue, Nov 22, 2005 at 05:26:00PM -0700, Fan Wu wrote: type NDS a = StateT ProblemState [] a getVar :: Var - NDS (Maybe Value) getVar v = do vs - gets vars return $ lookup v vs What puzzles me is that, I think the Monad of the do block shall be the NDS (Maybe

Re: Re[2]: [Haskell-cafe] re-definition of '.'

2005-11-22 Thread Max Eronin
is the word OOP persuade so strange on you? No, my brain exploded by the examples and proposed rules made me look so When it is exploding I often start acting funnily. And I was fortunate enough not to begin biting the dogs and scratching the cats after an attempt to predict an order of

Re: [Haskell-cafe] Shortening if-then-else

2005-11-22 Thread Tomasz Zielonka
On Tue, Nov 22, 2005 at 09:07:29PM +, Joel Reymont wrote: Why wouldn't Bulat's version work? Because Int /= () when :: (Monad m) = Bool - m () - m () Best regards Tomasz ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Function application like a Unix pipe

2005-11-22 Thread Tomasz Zielonka
On Tue, Nov 22, 2005 at 02:09:40PM -0800, Scherrer, Chad wrote: (\|) = flip ($) -- (#) seems to me too pretty for other purposes to use it here. infixl 0 \| -- Again, why can't this be negative or Fractional?? I have a ? operator that does the same thing. Next time I use it I'll check if

[Haskell-cafe] Records vs HList

2005-11-22 Thread David Menendez
Keean Schupke writes: David Menendez wrote: Chris Kuklewicz writes: Would the record system describe at http://lambda-the-ultimate.org/node/view/1119 also be convertable into System Fw, GHC's existing, strongly-typeed intermediate language. ? Probably. Daan's current implementation