on ebcb29b help sign in
Idris-dev/src/Idris/Error.hs
31 lines 842 B history raw
1module Idris.Error where
3import Idris.AbsSyntax
4import Idris.Delaborate
6import Core.TT
7import Core.Typecheck
9import Control.Monad.State
10import System.IO.Error
12report :: IOError -> String
13report e
14 | isUserError e = ioeGetErrorString e
15 | otherwise = show e
17-- Taken from the library source code - for ghc 6.12/7 compatibility
18liftCatch :: (m (a,s) -> (e -> m (a,s)) -> m (a,s)) ->
19 StateT s m a -> (e -> StateT s m a) -> StateT s m a
20liftCatch catchError m h =
21 StateT $ \s -> runStateT m s `catchError` \e -> runStateT (h e) s
23idrisCatch :: Idris a -> (IOError -> Idris a) -> Idris a
24idrisCatch op handler = liftCatch catch op handler
26tclift :: Show a => TC a -> Idris a
27tclift tc = case tc of
28 OK v -> return v
29 Error err -> do i <- get
30 fail (pshow i err)