use a newtype for better type safety

This commit is contained in:
Joey Hess 2012-10-24 13:15:31 -04:00
parent 892d691ffd
commit 6b6ce30b42

View file

@ -8,14 +8,15 @@
module Assistant.BranchChange where
import Control.Concurrent.MSampleVar
import Assistant.Common
type BranchChangeHandle = MSampleVar ()
newtype BranchChangeHandle = BranchChangeHandle (MSampleVar ())
newBranchChangeHandle :: IO BranchChangeHandle
newBranchChangeHandle = newEmptySV
newBranchChangeHandle = BranchChangeHandle <$> newEmptySV
branchChanged :: BranchChangeHandle -> IO ()
branchChanged = flip writeSV ()
branchChanged (BranchChangeHandle h) = writeSV h ()
waitBranchChange :: BranchChangeHandle -> IO ()
waitBranchChange = readSV
waitBranchChange (BranchChangeHandle h) = readSV h