Hi, everybody. I'm really new to Haskell, but am really fascinated by it all! I have been thinking about its uses, and have a newbie question.

I was thinking about the process of mapping imperative languages to functional ones. It occurred to me that you can restate an imperative function as a functional function which takes the old state of the global values as an input and returns a new set of globals and output:

int foo(char arg1) {...};

foo arg1 globalsIn = ( retval , globalsOut )

Now, some imperative functions truly are functional. So I was wanting to write something like this in Haskell:

foo _ globalsIn = ( <unspecified> , globalsIn )
...other foo defintions below...

Basically, the idea would be that, no matter what the argument was, the output globals would be identifal to the input globals. So, if the calling function only cared about the output globals, then no more calculation would be needed. But if the retval was required, then the thunk would cause more searches of 'foo' to be performed.

Of course, you can implement it with a second function:

foo x globalsIn = ( fooInternal x , globalsIn )
...define fooInternal below...

But I was wondering if Haskell had a way to do this with a single function.

_______________________________________________
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to