@@ -1,3 +1,5 @@
1+{-# LANGUAGE DeriveDataTypeable #-}
1module Idris.Error where
3module Idris.Error where
3import Prelude hiding (catch)
5import Prelude hiding (catch)
@@ -12,13 +14,14 @@ import System.Console.Haskeline
12import Control.Monad.State
14import Control.Monad.State
13import System.IO.Error(isUserError, ioeGetErrorString)
15import System.IO.Error(isUserError, ioeGetErrorString)
14import Data.Char
16import Data.Char
16iucheck :: Idris ()
19iucheck :: Idris ()
17iucheck = do tit <- typeInType
20iucheck = do tit <- typeInType
18 when (not tit) $
21 when (not tit) $
19 do ist <- get
22 do ist <- get
20 idrisCatch (tclift $ ucheck (idris_constraints ist))
23 idrisCatch (tclift $ ucheck (idris_constraints ist))
21− (\e -> do let msg = report e
24+ (\e -> do let msg = show e
22 setErrLine (getErrLine msg)
25 setErrLine (getErrLine msg)
23 iputStrLn msg)
26 iputStrLn msg)
@@ -27,9 +30,17 @@ report e
27 | isUserError e = ioeGetErrorString e
30 | isUserError e = ioeGetErrorString e
28 | otherwise = show e
31 | otherwise = show e
30−idrisCatch :: Idris a -> (IOError -> Idris a) -> Idris a
33+idrisCatch :: Idris a -> (IdrisErr -> Idris a) -> Idris a
31idrisCatch = catch
34idrisCatch = catch
36+data IdrisErr = IErr String
39+instance Show IdrisErr where
42+instance Exception IdrisErr
33tclift :: TC a -> Idris a
44tclift :: TC a -> Idris a
34tclift tc = case tc of
45tclift tc = case tc of
35 OK v -> return v
46 OK v -> return v
@@ -37,7 +48,7 @@ tclift tc = case tc of
37 case err of
48 case err of
38 At (FC f l) e -> setErrLine l
49 At (FC f l) e -> setErrLine l
39 _ -> return ()
50 _ -> return ()
40− fail (pshow i err)
51+ throwIO (IErr $ pshow i err)
42getErrLine str
53getErrLine str
43 = case span (/=':') str of
54 = case span (/=':') str of