Re: [Haskell-cafe] Re: How to do this in FP way?

2008-06-16 Thread Thomas Davie
One half of all Haskell coders will tell you that mutable state isn't a good starting point to learn Haskell, the other half will tell you the same because they want to be cool kids, too. And the one left over will point out that he asked how to do this the FP way, not the imperative way?

Re: [Haskell-cafe] Memory profiling

2008-06-16 Thread Chaddaï Fouché
2008/6/16 Pieter Laeremans [EMAIL PROTECTED]: Hi, Which tools do you recommand for memory profiling haskell programs on a *nix system. I'm using haskell to develop a CGI program/script. The application has to be deployed on shared hosting infrastructure. Since I would like to be a good

Re: [Haskell-cafe] How to do this in FP way?

2008-06-16 Thread Ketil Malde
Magicloud Magiclouds [EMAIL PROTECTED] writes: static int old; int diff (int now) { /* this would be called once a second */ int ret = now - old; old = now; return ret; } Because there is no variable in Haskell. So how to do this in a FP way? I would claim the FP way is like

Re: [Haskell-cafe] Design your modules for qualified import

2008-06-16 Thread Wolfgang Jeltsch
Am Sonntag, 15. Juni 2008 23:17 schrieb Duncan Coutts: […] If we get a proper way to export a non-flat namespace then Gtk2Hs will certainly switch to using it. Using 'buttonBlah' is horrible but there is currently nothing better. So is there anyone who wants to file a feature request? […]

Re: [Haskell-cafe] How to do this in FP way?

2008-06-16 Thread Michał Pałka
On Mon, 2008-06-16 at 10:19 +0200, Ketil Malde wrote: Magicloud Magiclouds [EMAIL PROTECTED] writes: static int old; int diff (int now) { /* this would be called once a second */ int ret = now - old; old = now; return ret; } Because there is no variable in Haskell. So

Re: [Haskell-cafe] Lazy IO.

2008-06-16 Thread Abhay Parvate
hGetContents reads the entire contents of the stream till the end (although lazily). The return value of hGetContents is logically the entire contents of the stream. That it has not read it completely is only a part of its laziness, so the result does not depend upon when the caller stops

Re: [Haskell-cafe] Design your modules for qualified import

2008-06-16 Thread Isaac Dupree
Henning Thielemann wrote: On Mon, 9 Jun 2008, Duncan Coutts wrote: On Mon, 2008-06-09 at 16:04 +0200, Ketil Malde wrote: And - is there a way to make GHCi use aliased qualification? I find my self typing detailed taxonomies all the time there. The ghci syntax currently is: :m Data.Set

Re: [Haskell-cafe] Design your modules for qualified import

2008-06-16 Thread Isaac Dupree
Duncan Coutts wrote: Right. That's exactly why we've not done something like that. With 100+ modules in the Gtk package it's totally infeasible to do qualified imports of them all. If we get a proper way to export a non-flat namespace then Gtk2Hs will certainly switch to using it. Using

Re[2]: [Haskell-cafe] Design your modules for qualified import

2008-06-16 Thread Bulat Ziganshin
Hello Isaac, Monday, June 16, 2008, 4:02:10 PM, you wrote: Are there multiple blah functions among the GTK modules? I.e. would GTK.blah be unambiguous, not mentioning that it's a button function. yes. actually, gtk2hs uses typeclasses to overload functions over various types -- Best

Re: [Haskell-cafe] cabal-install failure

2008-06-16 Thread Claus Reinke
The main point of the Program abstraction is about configuring and running programs. As it happens some programs are provided by some haskell packages (but not all, eg ld, ar, etc). option to get version info and code to extract it (with one apparently very special case being hsc2hs). And

Re: [Haskell-cafe] Design your modules for qualified import

2008-06-16 Thread Jules Bean
Duncan Coutts wrote: If we get a proper way to export a non-flat namespace then Gtk2Hs will certainly switch to using it. Using 'buttonBlah' is horrible but there is currently nothing better. Whilst I'm sure anyone who's used deep module structures has wondered about this feature, I've seen

Re: [Haskell-cafe] Lazy IO.

2008-06-16 Thread Jules Bean
Sebastiaan Visser wrote: Does anyone know a pattern in which I can do this easily? Don't use hGetContents on a socket. That's asking for trouble. Use hGetContents either NEVER (easy option) or only on throwaway handles/files which won't be used again. Jules

Re: [Haskell-cafe] Design your modules for qualified import

2008-06-16 Thread Claus Reinke
Duncan Coutts wrote: If we get a proper way to export a non-flat namespace then Gtk2Hs will certainly switch to using it. Using 'buttonBlah' is horrible but there is currently nothing better. Whilst I'm sure anyone who's used deep module structures has wondered about this feature, I've seen

Re: [Haskell-cafe] Lazy IO.

2008-06-16 Thread Sebastiaan Visser
On Jun 16, 2008, at 2:58 PM, Jules Bean wrote: Sebastiaan Visser wrote: Does anyone know a pattern in which I can do this easily? Don't use hGetContents on a socket. That's asking for trouble. Can you please explain why? What is a more easier method to spool your HTTP post data to a file

Re: [Haskell-cafe] Lazy IO.

2008-06-16 Thread Jules Bean
Sebastiaan Visser wrote: On Jun 16, 2008, at 2:58 PM, Jules Bean wrote: Sebastiaan Visser wrote: Does anyone know a pattern in which I can do this easily? Don't use hGetContents on a socket. That's asking for trouble. Can you please explain why? Because it's a broken abstraction. It's

[Haskell-cafe] Re: How to do this in FP way?

2008-06-16 Thread Achim Schneider
Thomas Davie [EMAIL PROTECTED] wrote: One half of all Haskell coders will tell you that mutable state isn't a good starting point to learn Haskell, the other half will tell you the same because they want to be cool kids, too. And the one left over will point out that he asked how

[Haskell-cafe] Re: Lazy IO.

2008-06-16 Thread Achim Schneider
Jules Bean [EMAIL PROTECTED] wrote: Sebastiaan Visser wrote: On Jun 16, 2008, at 2:58 PM, Jules Bean wrote: Sebastiaan Visser wrote: Does anyone know a pattern in which I can do this easily? Don't use hGetContents on a socket. That's asking for trouble. Can you please explain

[Haskell-cafe] Design suggestion for Data.Binary.Defer

2008-06-16 Thread Neil Mitchell
Hi, I'm in the process of updating the Deferred Binary library, http://www-users.cs.york.ac.uk/~ndm/binarydefer/. The idea is that its does serialisation, but certain elements can be marked as deferred - instead of being written in the current file stream, they are merely pointed at and if

Re: [Haskell-cafe] Re: How to do this in FP way?

2008-06-16 Thread Thomas Davie
On 16 Jun 2008, at 18:28, Achim Schneider wrote: Thomas Davie [EMAIL PROTECTED] wrote: One half of all Haskell coders will tell you that mutable state isn't a good starting point to learn Haskell, the other half will tell you the same because they want to be cool kids, too. And the one

Re: [Haskell-cafe] How to do this in FP way?

2008-06-16 Thread David Roundy
2008/6/15 Magicloud Magiclouds [EMAIL PROTECTED]: Hello, I am getting familiar with FP now, and I have a program design kind of question. Say I have something like this in C: static int old; int diff (int now) { /* this would be called once a second */ int ret = now - old; old

[Haskell-cafe] Re: How to do this in FP way?

2008-06-16 Thread Achim Schneider
Thomas Davie [EMAIL PROTECTED] wrote: On 16 Jun 2008, at 18:28, Achim Schneider wrote: Thomas Davie [EMAIL PROTECTED] wrote: One half of all Haskell coders will tell you that mutable state isn't a good starting point to learn Haskell, the other half will tell you the same

Re: [Haskell-cafe] How to do this in FP way?

2008-06-16 Thread pierre
On Mon, Jun 16, 2008 at 10:31:22AM +0800, Magicloud Magiclouds wrote: Hello, I am getting familiar with FP now, and I have a program design kind of question. Say I have something like this in C: static int old; int diff (int now) { /* this would be called once a second */ int ret

Re: [Haskell-cafe] Re: How to do this in FP way?

2008-06-16 Thread Henning Thielemann
On Mon, 16 Jun 2008, Achim Schneider wrote: We have to resort to IO actions to get the time, and to IORefs because we need to chain up different calls to getCurrentTime using the IO Monad. The rest of the program can work with whatever you like best. Isn't (StateT s IO a) the cleaner

[Haskell-cafe] Re: How to do this in FP way?

2008-06-16 Thread Achim Schneider
Henning Thielemann [EMAIL PROTECTED] wrote: On Mon, 16 Jun 2008, Achim Schneider wrote: We have to resort to IO actions to get the time, and to IORefs because we need to chain up different calls to getCurrentTime using the IO Monad. The rest of the program can work with whatever you

Re: [Haskell-cafe] How to do this in FP way?

2008-06-16 Thread Sebastian Sylvan
On 6/16/08, Magicloud Magiclouds [EMAIL PROTECTED] wrote: Hello, I am getting familiar with FP now, and I have a program design kind of question. Say I have something like this in C: static int old; int diff (int now) { /* this would be called once a second */ int ret = now -

Re: [Haskell-cafe] monomorphism restriction

2008-06-16 Thread Ryan Ingram
On 6/11/08, Jonathan Cast [EMAIL PROTECTED] wrote: This doesn't apply to f, though --- it has a function type, so the user presumably already knows it won't be subject to updating, no? Distinguishing functions from variables by the form of declaration, rather than the type, seems somewhat

Re: [Haskell-cafe] How to do this in FP way?

2008-06-16 Thread Andrew Coppin
David Roundy wrote: A better question would be to think about what you are trying to accomplish, and then ask how to achieve that through functional programming. Amen! I was waiting for somebody to say that... There are a dozen situations in an imperative language where you'd write a

Re: [Haskell-cafe] FunPtr error?

2008-06-16 Thread Ryan Ingram
The simple explanation is because the FFI standard says so; primitive types wrapped in newtypes automatically get wrapped and unwrapped during FFI calls. See http://www.cse.unsw.edu.au/~chak/haskell/ffi/ffi/ffise3.html#x6-120003.2 ; the FFI uses renamed datatype to mean newtype. Consider the

[Haskell-cafe] C-program calling Haskell program?

2008-06-16 Thread Taepke, Bob
Hello, I am very new to Haskell, and I work in Windows XP. Can anyone please point me to a working C / Haskell program pair that does the following: 1) The C routine passes one or more scalars, arrays, or matrices to the Haskell routine. 2) The Haskell routine reads a comma-delimited, ASCII

Re: [Haskell-cafe] Design suggestion for Data.Binary.Defer

2008-06-16 Thread Derek Elkins
On Mon, 2008-06-16 at 17:43 +0100, Neil Mitchell wrote: Hi, I'm in the process of updating the Deferred Binary library, http://www-users.cs.york.ac.uk/~ndm/binarydefer/. The idea is that its does serialisation, but certain elements can be marked as deferred - instead of being written in the

[Haskell-cafe] 1/0

2008-06-16 Thread Evan Laforge
So, I know this has been discussed before, but: 1/0 Infinity 0/0 NaN ... so I see from the archives that Infinity is mandated by ieee754 even though my intuition says both should be NaN. Every other language throws an exception, even C will crash the program, so I'm guessing it's telling the

Re: [Haskell-cafe] Design suggestion for Data.Binary.Defer

2008-06-16 Thread David Roundy
On Mon, Jun 16, 2008 at 9:43 AM, Neil Mitchell [EMAIL PROTECTED] wrote: == The Question == Is there a simple way of tagging fields in a constructor as deferred, just once for reading and writing, and ideally outside the instance definition and not requiring additional code to unwrap? I can't

Re: [Haskell-cafe] 1/0

2008-06-16 Thread David Roundy
On Mon, Jun 16, 2008 at 4:07 PM, Evan Laforge [EMAIL PROTECTED] wrote: So, I know this has been discussed before, but: 1/0 Infinity 0/0 NaN ... so I see from the archives that Infinity is mandated by ieee754 even though my intuition says both should be NaN. There is a good reason for 1/0

Re: [Haskell-cafe] 1/0

2008-06-16 Thread David Roundy
On Mon, Jun 16, 2008 at 4:18 PM, David Roundy [EMAIL PROTECTED] wrote: On Mon, Jun 16, 2008 at 4:07 PM, Evan Laforge [EMAIL PROTECTED] wrote: Every other language throws an exception, even C will crash the program, so I'm guessing it's telling the processor / OS to turn these into signals,

Re: [Haskell-cafe] 1/0

2008-06-16 Thread Xiao-Yong Jin
Evan Laforge [EMAIL PROTECTED] writes: So, I know this has been discussed before, but: 1/0 Infinity 0/0 NaN ... so I see from the archives that Infinity is mandated by ieee754 even though my intuition says both should be NaN. Every other language throws an exception, even C will crash

Re: [Haskell-cafe] 1/0

2008-06-16 Thread Evan Laforge
No, The issue is that '/' is always floating point division in haskell, for integer division, use `div`. 1 `div` 0 throws an exception like you expect. GHC behaves exactly the same as C here. But in C whether '/' means floating point or integral division depends on the types of its

Re: [Haskell-cafe] 1/0

2008-06-16 Thread Dan Doel
On Monday 16 June 2008, Evan Laforge wrote: So, I know this has been discussed before, but: 1/0 Infinity 0/0 NaN ... so I see from the archives that Infinity is mandated by ieee754 even though my intuition says both should be NaN. Every other language throws an exception, even C

Re: [Haskell-cafe] 1/0

2008-06-16 Thread John Meacham
On Mon, Jun 16, 2008 at 04:41:23PM -0700, Evan Laforge wrote: But what about that NaN-Integer conversion thing? I think that may be a bug or at least a misfeature. The standard is somewhat vauge on a lot of issues dealing with floating point since it is such a tricky subject and depends a lot on

Re: [Haskell-cafe] 1/0

2008-06-16 Thread David Roundy
On Mon, Jun 16, 2008 at 04:50:05PM -0700, John Meacham wrote: On Mon, Jun 16, 2008 at 04:41:23PM -0700, Evan Laforge wrote: But what about that NaN-Integer conversion thing? I think that may be a bug or at least a misfeature. The standard is somewhat vauge on a lot of issues dealing with

Re: [Haskell-cafe] 1/0

2008-06-16 Thread Don Stewart
droundy: On Mon, Jun 16, 2008 at 04:50:05PM -0700, John Meacham wrote: On Mon, Jun 16, 2008 at 04:41:23PM -0700, Evan Laforge wrote: But what about that NaN-Integer conversion thing? I think that may be a bug or at least a misfeature. The standard is somewhat vauge on a lot of issues

Re: [Haskell-cafe] 1/0

2008-06-16 Thread David Roundy
On Mon, Jun 16, 2008 at 05:08:36PM -0700, Don Stewart wrote: droundy: On Mon, Jun 16, 2008 at 04:50:05PM -0700, John Meacham wrote: On Mon, Jun 16, 2008 at 04:41:23PM -0700, Evan Laforge wrote: But what about that NaN-Integer conversion thing? I think that may be a bug or at least

Re: [Haskell-cafe] 1/0

2008-06-16 Thread Don Stewart
droundy: On Mon, Jun 16, 2008 at 05:08:36PM -0700, Don Stewart wrote: droundy: On Mon, Jun 16, 2008 at 04:50:05PM -0700, John Meacham wrote: On Mon, Jun 16, 2008 at 04:41:23PM -0700, Evan Laforge wrote: But what about that NaN-Integer conversion thing? I think that may be a

Re: [Haskell-cafe] ANN: Haddock Trac

2008-06-16 Thread Misha Aizatulin
hi, I wasn't able to add an attachment to a ticket, is something wrong with permissions? Python Traceback Traceback (most recent call last): File /var/lib/python-support/python2.4/trac/web/main.py, line 387, in dispatch_request dispatcher.dispatch(req) File

Re: [Haskell-cafe] 1/0

2008-06-16 Thread John Meacham
On Mon, Jun 16, 2008 at 05:39:39PM -0700, Don Stewart wrote: It's a bug in the H98 report then: Yes, I consider a whole lot of the floating point stuff in the report a bug of sorts IMHO :) It is certainly something that I hope to work on for Haskell'. John -- John Meacham -

Re: [Haskell-cafe] 1/0

2008-06-16 Thread David Roundy
On Mon, Jun 16, 2008 at 05:39:39PM -0700, Don Stewart wrote: decodeFloat really ought to be a partial function, and this should be a crashing bug, if the standard libraries were better-written. It's a bug in the H98 report then: Section 6.4.6: The function decodeFloat applied

Re: [Haskell-cafe] Re: How to do this in FP way?

2008-06-16 Thread Thomas Davie
On 16 Jun 2008, at 19:24, Achim Schneider wrote: Thomas Davie [EMAIL PROTECTED] wrote: On 16 Jun 2008, at 18:28, Achim Schneider wrote: Thomas Davie [EMAIL PROTECTED] wrote: One half of all Haskell coders will tell you that mutable state isn't a good starting point to learn Haskell,

Re: [Haskell-cafe] 1/0

2008-06-16 Thread Brandon S. Allbery KF8NH
On 2008 Jun 16, at 19:18, David Roundy wrote: On Mon, Jun 16, 2008 at 4:07 PM, Evan Laforge [EMAIL PROTECTED] wrote: Every other language throws an exception, even C will crash the program, so I'm guessing it's telling the processor / OS to turn these into signals, while GHC is turning

Re: [Haskell-cafe] 1/0

2008-06-16 Thread Richard A. O'Keefe
On 17 Jun 2008, at 11:07 am, Evan Laforge wrote: So, I know this has been discussed before, but: 1/0 Infinity 0/0 NaN ... so I see from the archives that Infinity is mandated by ieee754 even though my intuition says both should be NaN. Other people have other intuitions. It may be

Re: [Haskell-cafe] 1/0

2008-06-16 Thread Evan Laforge
... so I see from the archives that Infinity is mandated by ieee754 even though my intuition says both should be NaN. Other people have other intuitions. It may be that your intuition is telling you that neither result should be an ordinary number, and if that's what it's really telling

[Haskell-cafe] Re: How to do this in FP way?

2008-06-16 Thread Achim Schneider
Thomas Davie [EMAIL PROTECTED] wrote: On 16 Jun 2008, at 19:24, Achim Schneider wrote: Thomas Davie [EMAIL PROTECTED] wrote: On 16 Jun 2008, at 18:28, Achim Schneider wrote: Thomas Davie [EMAIL PROTECTED] wrote: One half of all Haskell coders will tell you that mutable

Re: [Haskell-cafe] 1/0

2008-06-16 Thread Richard A. O'Keefe
Since Haskell-Café often strays into mathematics, this may not be too far off topic. On 17 Jun 2008, at 2:29 pm, Evan Laforge wrote: Yeah, on reflection, I think my intuition derives from me asking a math teacher back in high school isn't n/0 infinity? after looking at a graph, to which he said

答复: [Haskell-cafe] Re: How to do this in FP way?

2008-06-16 Thread Magicloud
Yes, that's it, State. Thanks. -邮件原件- 发件人: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 代表 Achim Schneider 发送时间: 2008年6月16日 12:01 收件人: haskell-cafe@haskell.org 主题: [Haskell-cafe] Re: How to do this in FP way? Magicloud Magiclouds [EMAIL PROTECTED] wrote: static int old; int diff (int

答复: [Haskell-cafe] Re: How to do this in FP way?

2008-06-16 Thread Magicloud
I think if I do not use a state, and the function would be called for many times, it would waste memory, if using something like loop, right? -邮件原件- 发件人: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 代表 Achim Schneider 发送时间: 2008年6月16日 12:01 收件人: haskell-cafe@haskell.org 主题: [Haskell-cafe]

Re: [Haskell-cafe] Re: How to do this in FP way?

2008-06-16 Thread Achim Schneider
Magicloud [EMAIL PROTECTED] wrote: I think if I do not use a state, and the function would be called for many times, it would waste memory, if using something like loop, right? nope, at least not in general. update :: MyState - Int - MyState draw :: MyState - IO () mainLoop :: MyState -

答复: [Haskell-cafe] Re: How to do this in FP way?

2008-06-16 Thread Magicloud
But if there are some beautiful arithmetics that do not use something like state, I won't say no to them. -邮件原件- 发件人: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 代表 Achim Schneider 发送时间: 2008年6月16日 12:01 收件人: haskell-cafe@haskell.org 主题: [Haskell-cafe] Re: How to do this in FP way?

答复: [Haskell-cafe] How to do this in FP wa y?

2008-06-16 Thread Magicloud
OK. Here it is. I want to make a monitor tool for linux. It runs for a long time, and give out a certain process's io stat per second. The way I get io stat is to read from /proc/pid/io. But the data in this file is a total, I need to read it first, then next second, read it again, and shows the