framework for composing monads?

Elke Kasimir
Sun, 18 Feb 2001 12:59:57 +0100 (CET)

(Moving to haskell cafe...)

On 18-Feb-2001 Manuel M. T. Chakravarty wrote:
>> It is even acceptable for me to manage the state in C -
>> independent of the API design - but then some time there 
>> will be the question: Why do I always say that that Haskell 
>> is the better programming language, when I'm
>> really doing all the tricky stuff in C?...
> Sure - therefore, I proposed to use `IORef's rather than C
> routines. 

Thanks for the hint! 

I took a look at them and now have some questions:

a) It is clear that I need some C-link to access the cli/odbc lib.
Up to now I planned to use Haskell Direct for this. Except of this, I want
to stick to Haskell 98 and seek for maximal portability. 

Practically, this raises the question of wether nhc and hbc support hslibs
or else I can provide a substitute for IORef's for these compilers.

Can someone give me hint?

b) What I finally need is "hidden state". My first attempt to get one 
using IORefs is:

> import IOExts
> state :: IORef Int
> state = unsafePerformIO $ newIORef 0
> main = seq state $ do
>                   writeIORef state 1
>                   currstate <- readIORef state
>                   putStr (show currstate)

Is this the right way?


"If you have nothing to say, don't do it here..."

Elke Kasimir
Skalitzer Str. 79
10997 Berlin (Germany)
fon:  +49 (030) 612 852 16
see: <>

for pgp public key see: