on b1419b2 help sign in
Idris-dev/src/Idris/Error.hs
36 lines 1.0 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) = "Can't unify " ++ show (delab i x) ++
29 " with " ++ show (delab i y)
31tclift :: Show a => TC a -> Idris a
32tclift tc = case tc of
33 OK v -> return v
34 Error err -> do i <- get
35 fail (pshow i err)