[Haskell] Mixing monadic and non-monadic functions

Lyle Kopnicky lists at qseep.net
Thu Sep 15 14:50:30 EDT 2005


Bulat Ziganshin wrote:

>Hello Ben,
>
>Wednesday, September 14, 2005, 6:32:27 PM, you wrote:
>
>BRG>      do { ... ; ... borrow E ... ; ... }
>
>BRG> is transformed into
>
>BRG>      do { ... ; x <- E ; ... x ... ; ... }
>
>i strongly support this suggestion. actually, i suggest the same for
>dealing with references (IORef/MVar/...), for example:
>
>do x <- newIORef 0
>   y <- newIORef 0
>   z <- newIORef 0
>   z := *x + *y   -- translated to { x' <- readIORef x; y' <- readIORef y; writeIORef z (x'+y') }
>
>  
>
Right, I realize my suggestion is the same as Ben's.  I just prefer a 
more succinct notation, like special brackets instead of a keyword.  I 
like your idea about IORefs.  I think it should work as well for 
STRefs... perhaps it needs to belong to a type class, in a way?

- Lyle


More information about the Haskell mailing list