答复: [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 F

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

2008-06-16 Thread Achim Schneider
wikipedia. > -邮件原件- > 发件人: [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]> wrot

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

2008-06-16 Thread Magicloud
] Re: How to do this in FP way? "Magicloud Magiclouds" <[EMAIL PROTECTED]> wrote: > static int old; > int diff (int now) { /* this would be called once a second */ > int ret = now - old; > old = now; > return ret; > } > You do it with variables, of course.

答复: [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: > st

[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 Haske

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,

[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 whate

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 altern

[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

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 l

[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 h

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?

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

2008-06-15 Thread Achim Schneider
"Magicloud Magiclouds" <[EMAIL PROTECTED]> wrote: > static int old; > int diff (int now) { /* this would be called once a second */ > int ret = now - old; > old = now; > return ret; > } > You do it with variables, of course. This is out of some GLUT code, using IORef's: idle :: State -> Idl