Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Leon Smith <leon.p.smith <at> gmail.com>
Subject: Issue with monad-control
Newsgroups: gmane.comp.lang.haskell.snapframework
Date: Saturday 30th July 2011 17:12:51 UTC (over 5 years ago)
Since I need bracket on application-specific monads,  and Snap is
thinking about moving to monad-control,  I started digging into the
issue this weekend at HacPhi.   But here's some food for thought;
before you run this test case yourself,  you should work out what it
should do.

import qualified Prelude
import Prelude hiding (putStrLn)
import Control.Monad.State.Strict
import Control.Monad.Trans
import Control.Exception.Control

type M = StateT Int IO

putStrLn = liftIO . Prelude.putStrLn

test :: IO ((),Int)
test = runStateT (do
                      x <- get
                      putStrLn ("Prologue with state: " ++ show x)
                      bracket
                          (putStrLn "Hello!" >> put 2)
                          (\ () -> do
                             x <- get
                             putStrLn ("Ending with state: " ++ show x)
                             put 3)
                          (\ () -> do
                             x <- get
                             putStrLn ("Doing with state: " ++ show x)
                             put 4)
                      x' <- get
                      putStrLn ("Epilogue with state: " ++ show x')
                 ) 1
 
CD: 3ms