I have this function:
isUndefined :: () -> Bool
isUndefined x = case unsafePerformIO $ (try (return $! x) :: IO (Either SomeException ())) of
Left _ -> True
Right _ -> False
then:
isUndefined () = False
isUndefined undefined = True
Solving the halting problem. Of course, this can be extended to other types too.
My question: how is this possible? Is Control.Exception.try
really breaking things here?