Foreign.Marshal.Error
Foreign.Marshal.Error
IO 액션의 결과 값에 대한 오류 조건을 검사하고 예외를 던지는 가드(guard) 함수들을 제공하는 모듈이에요.
본문
module Foreign.Marshal.Error (
throwIf, throwIf_, throwIfNeg, throwIfNeg_, throwIfNull, void
) where
throwIf
:: (a -> Bool) -- ^ IO 액션 결과에 대한 오류 조건 (error condition on the result of the IO action)
-> (a -> String) -- ^ IO 액션의 오류 결과로부터 오류 메시지를 계산 (computes an error message from erroneous results of the IO action)
-> IO a -- ^ 실행할 IO 액션 (the IO action to be executed)
-> IO a
IO 액션을 실행하고, 그 액션이 돌려준 결과에 술어를 적용했을 때 True가 나오면 userError를 던져요. 예외가 발생하지 않으면 계산의 결과를 돌려줘요.
throwIf_ :: (a -> Bool) -> (a -> String) -> IO a -> IO ()
throwIf와 같지만, 그 결과를 버려요.
throwIfNeg :: (Ord a, Num a) => (a -> String) -> IO a -> IO a
음수 결과 값에 대해 가드해요.
throwIfNeg_ :: (Ord a, Num a) => (a -> String) -> IO a -> IO ()
throwIfNeg와 같지만, 그 결과를 버려요.
throwIfNull :: String -> IO (Ptr a) -> IO (Ptr a)
null 포인터에 대해 가드해요.
void :: IO a -> IO ()
IO 액션의 반환 값을 버려요.
더 알아보기 (Learn more)
errno기반의 C 오류 처리는 26장 Foreign.C.Error에서 다뤄요.- 이 모듈은
Foreign.Marshal을 통해 함께 임포트할 수 있어요(30장).