Catch upsets semantic approximation?

The order of semantic approximation states that if a function is fdefined when its arguments are absent, then it fis a constant in this argument (it does not use it). But consider this function,

import Control.Exception

handleAll :: SomeException -> IO ()
handleAll e = putStrLn "caught"

f :: String -> IO ()
f x = catch (putStrLn x) handleAll

f undefineddisplays caughtin GHCi, so it looks specific. However, fit is not a constant in its argument, because it f "test"displays test.

Is there a mistake somewhere?

+4
source share
1 answer

catch , ( ). . (pdf) , GHC.

, " " Haskell, IO a ( ).

, " " Haskell, IO

data IO a = MkIO

catch

catch a h = MkIO

f, f undefined f "test" MkIO.

[[IO t]] = {⊥ < ⊤}

, IO, seq IO, , , length :: [Bool] -> Integer, , , -. , , .

+8

Source: https://habr.com/ru/post/1671451/


All Articles