More generally: standard Haskell does not allow signatures in templates, but allows any expression to receive a signature. The following conditions are valid:
main :: IO () main = do x <- readLn print $ 5 + x main' = (\y -> do { x <- readLn; print $ y + x } ) :: Int -> IO () main'' y = do x <- readLn :: IO Int print $ y + x :: IO ()
but not one of them is
main''' = do (x :: Int) <- readLn print $ 5 + x main''' = (\(y :: Int) -> do { x <- readLn; print $ y + x } ) :: Int -> IO () main'''' (y :: Int) = do x <- readLn :: IO Int print $ y + x :: IO ()
Apparently, it is simply not foreseen that the signatures in the templates may be useful. But they are sure, therefore ScopedTypeVariables presented this opportunity.
source share