Re: framework for composing monads?
(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? Cheers, Elke --- "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 mail: [EMAIL PROTECTED] see: http://www.catmint.de/elke for pgp public key see: http://www.catmint.de/elke/pgp_signature.html ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: framework for composing monads?
Elke Kasimir [EMAIL PROTECTED] wrote, (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. I am all for portable code, too. 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. nhc does supports `IORef's (they come in the module IOExtras). I am not sure whether H/Direct works with nhc, though. Sigbjorn should be able to answer this. 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? Yes, except that you want to have {-# NOINLINE state #-} too. Wouldn't be nice if ghc were to choose to inline `state', would it? ;-) Cheers, Manuel ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: framework for composing monads?
Andy Gill's Monad Template Library is good for that, but the link from the Haskell library page is broken: http://www.cse.ogi.edu/~andy/monads/doc.htm Jan ___ Haskell-Cafe mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell-cafe