Re: [Haskell-cafe] IO is a bad example for Monads [was: do]

2007-12-08 Thread Lennart Augustsson
I agree with Dan here. IO is important because you can't write any real program without using it. So why not teach enough of it to get people off the ground straight away? People who hang around long enough to do some more Haskell programming will run into the other monads sooner or later. But

Re: [Haskell-cafe] a Char-Char function?

2007-12-08 Thread Lennart Augustsson
0x02 is not a Char, it's a numeric constant. Perhaps you meant '\x02' ? On Dec 8, 2007 9:02 AM, Galchin Vasili [EMAIL PROTECTED] wrote: Hello, I am writing a function(actually much more than this): bozo :: Char - Char bozo 0x02 = 'a' ... However, I get complaints from ghc

[Haskell-cafe] a Char-Char function?

2007-12-08 Thread Galchin Vasili
Hello, I am writing a function(actually much more than this): bozo :: Char - Char bozo 0x02 = 'a' ... However, I get complaints from ghc suggesting that I should add an instance declaration (Num, Char). I (mistaking) thought I understood the Haskell class hierarchy and the associated

[Haskell-cafe] Re: distinguish functions from non-functions in a class/instances

2007-12-08 Thread apfelmus
Luke Palmer wrote: Hmm, this still seems ill-defined to me. compose :: (Int - Int - Int) - (Int - Int) - Int - Int - Int Is a valid expression given that definition (with a,b = Int and c = Int - Int), but now the arity is 4. That's correct, the arity of a function is not well-defined due to

Re: [Haskell-cafe] Literate HTML

2007-12-08 Thread hjgtuyl
Hello, You can compile a .html file with: ghc --make -x lhs index.html if you write the code like this: code foo = 1 /code N.B. You need an empty line between code and the code and one between the code and /code. The -x flag doesn't seem to work for runhaskell, when I try this,

[Haskell-cafe] do notation strangeness

2007-12-08 Thread Felipe Lessa
Hello! I see from http://www.haskell.org/haskellwiki/Monads_as_computation#Do_notation that do { v - x ; stmts } = x = \v - do { stmts } However, look at this GHCi session: Prelude let return' = return :: a - Maybe a Prelude do {1 - return 1; return' ok} Just ok Prelude return 1 = \1 -

Re: [Haskell-cafe] do notation strangeness

2007-12-08 Thread Ilya Tsindlekht
On Sat, Dec 08, 2007 at 02:59:16PM -0200, Felipe Lessa wrote: Hello! I see from http://www.haskell.org/haskellwiki/Monads_as_computation#Do_notation that do { v - x ; stmts } = x = \v - do { stmts } However, look at this GHCi session: Prelude let return' = return :: a - Maybe a

Re: [Haskell-cafe] do notation strangeness

2007-12-08 Thread Ilya Tsindlekht
On Sat, Dec 08, 2007 at 03:28:58PM -0200, Felipe Lessa wrote: On Dec 8, 2007 3:12 PM, Ilya Tsindlekht [EMAIL PROTECTED] wrote: On Sat, Dec 08, 2007 at 02:59:16PM -0200, Felipe Lessa wrote: Prelude do {1 - return 3; return' ok} Nothing Prelude return 3 = \1 - return' ok ***

Re: [Haskell-cafe] [OT] A nice organized collection of threads in Haskell-Cafe

2007-12-08 Thread Andrew Coppin
Albert Y. C. Lai wrote: Some reply posts lack In-Reply-To: References: headers because their authors fail to choose compliant software or know the issue. Some non-reply posts (genuinely new topic, not even digression from existing ones) contain In-Reply-To: References: headers because their

Re: [Haskell-cafe] Re: Point and link

2007-12-08 Thread Andrew Coppin
Tom Davies wrote: Andrew Coppin andrewcoppin at btinternet.com writes: [snip] You might like to look at OpenQuark: http://labs.businessobjects.com/cal/ -- its 'GemCutter' provides a visual environment for linking together functions written in a Haskell-like language. I'm not sure if it would

Re: [Haskell-cafe] Point and link

2007-12-08 Thread Andrew Coppin
Denis Bueno wrote: Do you need to update positions of the units in real time? Do they even evolve over time, or are you just trying to visualise? If it's the latter, you might just take a collection of units and connections between them, output them in the graphviz [0] format, and see the

[Haskell-cafe] general

2007-12-08 Thread Ryan Bloor
hi I have a problem. Function A is a function that passes its input into B Function B is a function that does something once. How do I make it so function A is done multiple times without adding a third function? Ryan _

Re: [Haskell-cafe] general

2007-12-08 Thread Luke Palmer
On Dec 8, 2007 7:41 PM, Ryan Bloor [EMAIL PROTECTED] wrote: hi I have a problem. Function A is a function that passes its input into B Function B is a function that does something once. What do you mean by that? B does something once. More details! (Type signatures at least will give

Re: [Haskell-cafe] [OT] A nice organized collection of threads in Haskell-Cafe

2007-12-08 Thread Andrew Coppin
Albert Y. C. Lai wrote: Andrew Coppin wrote: Thunderbird has a long-standing bug in that new posts having the same subject line as some other post that happened many years ago get added to that thread. It's really most irritating. :-S I have investigated. A bit of skepticism goes a long way.

Re: [Haskell-cafe] general

2007-12-08 Thread Jed Brown
On 8 Dec 2007, [EMAIL PROTECTED] wrote: Function A is a function that passes its input into B Function B is a function that does something once. How do I make it so function A is done multiple times without adding a third function? By this, do you mean that you have functions f, g f :: a

Re: [Haskell-cafe] Point and link

2007-12-08 Thread Bit Connor
On Dec 8, 2007 10:15 PM, Andrew Coppin [EMAIL PROTECTED] wrote: Bit Connor wrote: On Dec 8, 2007 8:19 PM, Andrew Coppin [EMAIL PROTECTED] wrote: http://alts.homelinux.net/shots/195-0.jpg This is the kind of thing I'd like to end up with. Such a GUI would also be cool for visually

[Haskell-cafe] Problem with Gtk2hs

2007-12-08 Thread Andrew Coppin
I just spent the evening writing a library that's a thin layer over Gtk2hs. It took an age to get it to compile, but eventually it worked. Yay! When I ran it, I got this: Test2: gtk/Graphics/UI/Gtk/Gdk/PixbufData.hs.pp:58:0: No instance nor default method for class operation

Re: [Haskell-cafe] [OT] A nice organized collection of threads in Haskell-Cafe

2007-12-08 Thread Bryan O'Sullivan
Albert Y. C. Lai wrote: I can't blame you for being not observant. Afterall, this is precisely what I'm alluding to with everyone can haz PC [...] Please don't flame people on the list. Thank you, b ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] Problem with Gtk2hs

2007-12-08 Thread Stefan O'Rear
On Sat, Dec 08, 2007 at 08:33:36PM +, Andrew Coppin wrote: I just spent the evening writing a library that's a thin layer over Gtk2hs. It took an age to get it to compile, but eventually it worked. Yay! When I ran it, I got this: Test2: gtk/Graphics/UI/Gtk/Gdk/PixbufData.hs.pp:58:0: No

Re: [Haskell-cafe] Point and link

2007-12-08 Thread Henning Thielemann
On Sat, 8 Dec 2007, Bit Connor wrote: On Dec 8, 2007 8:19 PM, Andrew Coppin [EMAIL PROTECTED] wrote: Andrew Coppin wrote: Well, for starters, take a look at KLogic. http://alts.homelinux.net/shots/195-0.jpg This is the kind of thing I'd like to end up with. Such a GUI would also

Re: [Haskell-cafe] Point and link

2007-12-08 Thread Jules Bean
Bit Connor wrote: On Dec 8, 2007 10:15 PM, Andrew Coppin [EMAIL PROTECTED] wrote: Bit Connor wrote: On Dec 8, 2007 8:19 PM, Andrew Coppin [EMAIL PROTECTED] wrote: http://alts.homelinux.net/shots/195-0.jpg This is the kind of thing I'd like to end up with. Such a GUI would also be cool for

Re: [Haskell-cafe] Re: Over-allocation

2007-12-08 Thread Don Stewart
gracjanpolak: Gracjan Polak gracjanpolak at gmail.com writes: Don Stewart dons at galois.com writes: ByteStrings have all the same operations as lists though, so you can index, compare and take substrings, with the benefit that he underlying string will be shared, not copied.

[Haskell-cafe] general-revised

2007-12-08 Thread Ryan Bloor
hi I have four functions below: What I want to do is have a way to parse more than one digit or more than one string head in ParseTrue. Any ideas... removeSpace:: String - StringremoveSpace = dropWhile (`elem` space) where space = [' '] match :: String - String - (Bool,

[Haskell-cafe] Type error in final generator

2007-12-08 Thread Loganathan Lingappan
Hi, I am new to Haskell. I wrote the following code: module Main where import IO main = do hSetBuffering stdin LineBuffering numList - processInputs foldr (+) 0 numList processInputs = do putStrLn Enter a number: strNum - getLine let num

Re: [Haskell-cafe] Type error in final generator

2007-12-08 Thread Bryan O'Sullivan
Loganathan Lingappan wrote: main = do hSetBuffering stdin LineBuffering numList - processInputs foldr (+) 0 numList The type of main is understood to be IO (), so it can't return anything. You could work around this by rewriting the last line above as follows: print

Re: [Haskell-cafe] Type error in final generator

2007-12-08 Thread Derek Elkins
On Sat, 2007-12-08 at 16:39 -0800, Bryan O'Sullivan wrote: Loganathan Lingappan wrote: main = do hSetBuffering stdin LineBuffering numList - processInputs foldr (+) 0 numList The type of main is understood to be IO (), so it can't return anything. You could

Re: [Haskell-cafe] Type error in final generator

2007-12-08 Thread Loganathan Lingappan
Thanks Bryan and Derek. This works! Logo - Original Message From: Derek Elkins [EMAIL PROTECTED] To: Bryan O'Sullivan [EMAIL PROTECTED] Cc: Loganathan Lingappan [EMAIL PROTECTED]; haskell-cafe@haskell.org Sent: Saturday, December 8, 2007 4:53:54 PM Subject: Re: [Haskell-cafe] Type error

[Haskell-cafe] do... error

2007-12-08 Thread Ryan Bloor
hi test :: Parser (Char,Char) test = do x - item item y - item return (x,y) How come this brings an error saying that after do {} it must end with an expression. Ryan _ Get free

Re: [Haskell-cafe] do... error

2007-12-08 Thread Brandon S. Allbery KF8NH
On Dec 8, 2007, at 21:38 , Ryan Bloor wrote: test :: Parser (Char,Char) test = do x - item item The second and subsequent lines are indented too much, so are read as a continuation of the first; which, starting with x - , is not an expression. -- brandon s. allbery

Re: [Haskell-cafe] do... error

2007-12-08 Thread Brandon S. Allbery KF8NH
On Dec 8, 2007, at 21:40 , Brandon S. Allbery KF8NH wrote: On Dec 8, 2007, at 21:38 , Ryan Bloor wrote: test :: Parser (Char,Char) test = do x - item item The second and subsequent lines are indented too much, so are read as a continuation of the first; which, starting

Re: [Haskell-cafe] do... error

2007-12-08 Thread Felipe Lessa
On Dec 9, 2007 12:42 AM, Brandon S. Allbery KF8NH [EMAIL PROTECTED] wrote: I neglected to say the proper indentation: test = do x - item item -- note, indented to match the token after the do y - item return (x,y) That is the best thing to

Re: [Haskell-cafe] do... error

2007-12-08 Thread Felipe Lessa
On Dec 9, 2007 1:01 AM, Ryan Bloor [EMAIL PROTECTED] wrote: But what is the right way to indent...? It is so annoying, why does it matter so much! :( You may read http://en.wikibooks.org/wiki/Haskell/Indentation which tries to explain in a very simple language. -- Felipe.

[Haskell-cafe] annoying output

2007-12-08 Thread Ryan Bloor
hi The code below does almost what I want but not quite! It outputs...parseInt 12444a gives... [(EInt 1,2444a),(EInt 2,444a),(EInt 4,44a),(EInt 4,4a),(EInt 4,a)] What I want is: [(EInt 12444, a)] data Expr = EInt {vInt :: Int} -- integer values | EBool {vBool :: Bool} -- boolean

Re: [Haskell-cafe] annoying output

2007-12-08 Thread Philip Weaver
Well, you're choosing to parse each digit of your integer as a separate integer, so if you want to combine them after reading you'll need to multiply by powers of two. Or, you can just read in all the digits in one 'read' command, like this: parseInt :: String - (Expr, String) parseInt xs

Re: [Haskell-cafe] annoying output

2007-12-08 Thread Philip Weaver
I mean powers of *ten* :) On Dec 8, 2007 10:48 PM, Philip Weaver [EMAIL PROTECTED] wrote: Well, you're choosing to parse each digit of your integer as a separate integer, so if you want to combine them after reading you'll need to multiply by powers of two. Or, you can just read in all the