Changeset 22989 for src

Show
Ignore:
Timestamp:
11/12/08 10:00:43 (8 weeks ago)
Author:
audreyt
Message:

* GHC 6.10 support, part 2 of 3: Adjust for extensible exceptions.

Location:
src/Pugs
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • src/Pugs/AST/Eval.hs

    r15616 r22989  
    44import Pugs.Internals 
    55import Pugs.Cont hiding (resetT) 
    6 import Control.Exception (try, Exception) 
     6import System.IO.Error (try, IOError) 
    77 
    88import Pugs.AST.SIO 
     
    165165supress the exception and return an associated value instead. 
    166166-} 
    167 guardIOexcept :: MonadIO m => [((Exception -> Bool), a)] -> IO a -> m a 
     167guardIOexcept :: MonadIO m => [((IOError -> Bool), a)] -> IO a -> m a 
    168168guardIOexcept safetyNet x = do 
    169169    rv <- io $ try x 
  • src/Pugs/Prim.hs

    r22317 r22989  
    3939import Data.IORef 
    4040import System.IO.Error (isEOFError) 
    41 import Control.Exception (ioErrors) 
    4241 
    4342import Pugs.Prim.Keyed 
     
    217216op1 "~^"   = op1Cast (VStr . mapStr complement) 
    218217op1 "?^"   = op1 "!" 
    219 op1 "\\"   = \v -> do 
    220     return $ case v of 
    221         (VRef (MkRef (IScalar _))) -> VRef . scalarRef $ v 
    222         (VRef _)    -> v 
    223         (VList vs)  -> VRef . arrayRef $ vs 
    224         _           -> VRef . scalarRef $ v 
     218op1 "\\"   = return . doCapture 
     219    where 
     220    doCapture :: Val -> Val 
     221    doCapture v@(VRef (MkRef IScalar{})) = VRef . scalarRef $ v 
     222    doCapture v@VRef{}                   = v 
     223    doCapture (VList vs)                 = VRef . arrayRef $ vs 
     224    doCapture v                          = VRef . scalarRef $ v 
    225225op1 "^" = op2RangeExclRight (VNum 0) 
    226226op1 "post:..."  = op1Range 
     
    843843            _           -> return undef 
    844844    doGetLine :: VHandle -> IO (Maybe VStr) 
    845     doGetLine fh = guardIOexcept [(isIOError isEOFError, Nothing)] $ do 
     845    doGetLine fh = guardIOexcept [(isEOFError, Nothing)] $ do 
    846846        line <- hGetLine fh 
    847847        return . Just . decodeUTF8 $ line 
    848848 
    849 isIOError :: (IOError -> Bool) -> Exception -> Bool 
    850 isIOError f err = case ioErrors err of 
    851     Just ioe    -> f ioe 
    852     Nothing     -> False 
    853  
    854849op1Getc :: Val -> Eval Val 
    855850op1Getc = \v -> op1Read v (getChar) (getChar) 
    856851    where 
    857852    getChar :: VHandle -> Eval Val 
    858     getChar fh = guardIOexcept [(isIOError isEOFError, undef)] $ do 
     853    getChar fh = guardIOexcept [(isEOFError, undef)] $ do 
    859854        char <- hGetChar fh 
    860855        str  <- getChar' fh char