[Haskell] Mixing monadic and non-monadic functions

Bulat Ziganshin bulatz at HotPOP.com
Thu Sep 15 15:40:23 EDT 2005

Hello Lyle,

Thursday, September 15, 2005, 10:50:30 PM, you wrote:

>>   z := *x + *y   -- translated to { x' <- readIORef x; y' <- readIORef y; writeIORef z (x'+y') }
LK> Right, I realize my suggestion is the same as Ben's.  I just prefer a 
LK> more succinct notation, like special brackets instead of a keyword.  I 
LK> like your idea about IORefs.  I think it should work as well for 
LK> STRefs... perhaps it needs to belong to a type class, in a way?

of course

class Ref c a where
  new :: a -> IO (c a)
  get :: c a -> IO a
  set :: c a -> a -> IO ()

Best regards,
 Bulat                            mailto:bulatz at HotPOP.com

More information about the Haskell mailing list