module Graphics.Animation.Cal3D.Error
(Fallible, IOFallible
, checkErrorValue, checkError
)
where
type Fallible a = Either String a
type IOFallible a = IO (Fallible a)
checkErrorValue :: (Eq a) =>
IO a
-> a
-> String
-> IO (Either String a)
checkErrorValue action bad errmsg = do
{
result <- action
; return (if result == bad
then Left errmsg
else Right result)
}
checkError :: (Eq a) =>
IO a
-> a
-> String
-> IO (Either String ())
checkError action bad errmsg = do
{
eresult <- checkErrorValue action bad errmsg
; return (case eresult of
Left errmsg -> Left errmsg
Right _ -> Right ())
}