Changeset 8699

Show
Ignore:
Timestamp:
01/16/06 13:08:43 (3 years ago)
Author:
audreyt
Message:

* DrIFT.YAML: Do not die when the Typeable instance is undefined.

Location:
src
Files:
9 modified

Legend:

Unmodified
Added
Removed
  • src/DrIFT/YAML.hs

    r8694 r8699  
    99import UTF8 
    1010import Data.Typeable 
     11import Control.Exception 
    1112 
    1213type YAMLClass = String 
     
    1617showYaml :: YAML a => a -> IO String 
    1718showYaml x = do 
    18     rv <- emitYaml =<< asYAML x 
     19    node    <- asYAML x 
     20    rv      <- emitYaml node 
    1921    case rv of 
    2022        Left e  -> error e 
     
    2325class Typeable a => YAML a where 
    2426    asYAML :: a -> IO YamlNode 
    25     asYAML x | ty == "()" = return nilNode 
    26              | otherwise  = return $ mkTagNode (tagHs ty) YamlNil 
    27         where 
    28         ty = (reverse (takeWhile (/= '.') (reverse (show (typeOf x))))) 
     27    asYAML x = do 
     28        ty <- Control.Exception.handle (const $ return "()") $ 
     29            evaluate (reverse (takeWhile (/= '.') (reverse (show (typeOf x))))) 
     30        return $ case ty of 
     31            "()" -> nilNode 
     32            _    -> mkTagNode (tagHs ty) YamlNil 
    2933 
    3034asYAMLseq :: YAMLClass -> [IO YAMLVal] -> IO YamlNode 
     
    4852tagHs :: YAMLClass -> String 
    4953tagHs = ("tag:hs:" ++) 
     54 
     55instance YAML () where 
    5056 
    5157instance YAML Int where 
  • src/Emit/PIR.hs

    r8695 r8699  
    970970    asYAML = asYAML . render 
    971971instance Typeable Doc where 
    972     typeOf = undefined 
     972    typeOf _ = typeOf () 
    973973 
    974974------------------------------------------------------------------------ 
  • src/Emit/PIR.hs-drift

    r8693 r8699  
    968968    asYAML = asYAML . render 
    969969instance Typeable Doc where 
    970     typeOf = undefined 
     970    typeOf _ = typeOf () 
    971971 
    972972------------------------------------------------------------------------ 
  • src/Pugs/AST/Internals.hs

    r8695 r8699  
    17941794instance YAML VOpaque 
    17951795instance YAML VSocket 
    1796 instance YAML PerlSV 
    17971796instance Typeable Unique where typeOf _ = typeOf () 
    17981797instance Typeable ProcessHandle where typeOf _ = typeOf () 
  • src/Pugs/AST/Internals.hs-drift

    r8694 r8699  
    18261826instance YAML VOpaque 
    18271827instance YAML VSocket 
    1828 instance YAML PerlSV 
    18291828instance Typeable Unique where typeOf _ = typeOf () 
    18301829instance Typeable ProcessHandle where typeOf _ = typeOf () 
  • src/Pugs/Eval.hs

    r8640 r8699  
    390390    env  <- ask 
    391391    cont <- if subType sub /= SubCoroutine then return Nothing else liftSTM $ do 
    392         tvar <- newTVar undefined 
     392        tvar <- newTVar (error "empty sub") 
    393393        let thunk = (`MkThunk` anyType) . fix $ \redo -> do 
    394394            evalExp $ subBody sub 
  • src/Pugs/Monads.hs

    r8207 r8699  
    224224        if typ >= SubBlock 
    225225            then do 
    226                 doFix <- fixEnv undefined env 
     226                doFix <- fixEnv return env 
    227227                local doFix action 
    228228            else resetT $ callCC $ \cc -> do 
  • src/Pugs/Prim.hs

    r8593 r8699  
    1515    primDecl, 
    1616    initSyms, 
    17     op2DefinedOr, 
    1817    op2ChainedList, 
    1918    op1Exit, 
     
    12411240    ref <- fromVal y 
    12421241    forceRef ref 
    1243  
    1244 op2DefinedOr :: Val 
    1245 op2DefinedOr = undefined 
    12461242 
    12471243op2Identity :: Val -> Val -> Eval Val 
  • src/Pugs/Types/Code.hs

    r4928 r8699  
    1717    code_store    = (liftSTM .) . writeTVar 
    1818    code_assuming c [] [] = code_fetch c 
    19     code_assuming _ _ _   = undefined 
     19    code_assuming _ _ _   = error "assuming" 
    2020    code_apply    = error "apply" 
    2121    code_assoc c  = code_assoc . unsafePerformSTM $ readTVar c