I'm supplying a function to idleCallback This notation works:
idleCallback $= Just (do
modifyIORef world play
postRedisplay Nothing)
Why doesn't this (seemingly similar) notation work?
idleCallback $= Just $ do
modifyIORef world play
postRedisplay Nothing
To save your hoogling, the types are:
($=) :: HasSetter s => s a -> a -> IO ()
type IdleCallback = IO ()
data SettableStateVar a
idleCallback :: SettableStateVar (Maybe IdleCallback)
postRedisplay :: Maybe Window -> IO ()
modifyIORef :: IORef a -> (a -> a) -> IO ()
GHC says:
Couldn't match expected type `Maybe IdleCallback'
with actual type `a0 -> Maybe a0'
In the second argument of `($=)', namely `Just'
In the expression: idleCallback $= Just
In a stmt of a 'do' block:
idleCallback $= Just
$ do { modifyIORef world play;
postRedisplay Nothing }
Can this be written without wrapping the do block in parenthesis?