Ketil Malde wrote:
"Russ Lewis" <[EMAIL PROTECTED]> writes:

Another newbie question: Is it possible to catch _|_ - that is, to
encounter it, handle it and continue?

Since _|_ is the value of a non-terminating computation, this requires you to solve the halting problem. GHC does occasionally detect loops, but for the general case, don't hold your breath :-)

-kzm

If all you are interested in is catching calls to error, they can be caught like normal exceptions. Here is some code from Network.XmlRpc that catches error calls and handles them in an error monad:


type Err m a = ErrorT String m a

-- | Evaluate the argument and catch error call exceptions
errorToErr :: Monad m => a -> Err m a
errorToErr x = let e = unsafePerformIO (tryJust errorCalls (evaluate x))
                   in ErrorT (return e)

Pretty nasty, using evaluate and unsafePerformIO in the same function. The essential part is (tryJust errorCalls).

/Bjorn Bringert

_______________________________________________
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to