on 796fa25 help sign in
Idris-dev/src/Idris/Error.hs
38 lines 1.1 kB 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
26pshow :: IState -> Err -> String
27pshow i (Msg s) = s
28pshow i (CantUnify x y e) = "Can't unify " ++ show (delab i x)
29 ++ " with " ++ show (delab i y)
30 -- ++ "\n\t(" ++ pshow i e ++ ")"
31pshow i (At f e) = show f ++ ":" ++ pshow i e
33tclift :: Show a => TC a -> Idris a
34tclift tc = case tc of
35 OK v -> return v
36 Error err -> do i <- get
37 fail (pshow i err)