Changeset 12771

Show
Ignore:
Timestamp:
02.11.2009 17:36:36 (3 weeks ago)
Author:
maeder
Message:

shortened error message and put theory text into a hint

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/Logic/Comorphism.hs

    r12643 r12771  
    4444import Logic.Coerce 
    4545import Logic.ExtSign 
    46 import Common.ExtSign 
    47 import Common.Result 
    48 import Common.ProofUtils 
     46 
    4947import Common.AS_Annotation 
    5048import Common.Doc 
    5149import Common.DocUtils 
     50import Common.ExtSign 
     51import Common.Id 
     52import Common.ProofUtils 
     53import Common.Result 
     54 
     55import Data.Maybe 
    5256import qualified Data.Set as Set 
    5357import Data.Typeable 
     
    120124                sign2 morphism2 symbol2 raw_symbol2 proof_tree2 
    121125         => cid -> sublogics2 
    122 targetSublogic cid = maybe (top_sublogic $ targetLogic cid) 
    123                            id $ mapSublogic cid $ sourceSublogic cid 
     126targetSublogic cid = fromMaybe (top_sublogic $ targetLogic cid) 
     127                           $ mapSublogic cid $ sourceSublogic cid 
    124128 
    125129-- | this function is base on 'map_theory' using no sentences as input 
     
    187191              if isSubElem senLog sub 
    188192                 then res 
    189                  else fail $ "for '" ++ language_name cid ++ 
     193                 else Result 
     194                  [ Diag Hint 
     195                      (show (vcat $ pretty sign : map 
     196                                (print_named $ sourceLogic cid) sens)) 
     197                      nullRange 
     198                  , Diag Error 
     199                      ("for '" ++ language_name cid ++ 
    190200                           "' expected sublogic '" ++ 
    191201                           sublogicName sub ++ 
     
    193203                           sublogicName senLog ++ 
    194204                           "' with signature sublogic '" ++ 
    195                            sublogicName sigLog ++ "'\n" ++ 
    196                  show (vcat $ pretty sign : map 
    197                                 (print_named $ sourceLogic cid) sens) 
     205                           sublogicName sigLog ++ "'") nullRange] Nothing 
    198206 
    199207simpleTheoryMapping :: (sign1 -> sign2) -> (sentence1 -> sentence2) 
     
    237245mkInclComorphism lid srcSub trgSub = 
    238246    if isSubElem srcSub trgSub 
    239     then return $ InclComorphism 
     247    then return InclComorphism 
    240248      { inclusion_logic = lid 
    241249      , inclusion_source_sublogic = srcSub 
     
    251259            in if sub_src == sub_trg 
    252260               then "id_" ++ lname ++ 
    253                     if null sblName 
    254                     then "" else "." ++ sblName 
    255                else "incl_" ++ lname ++ ":" ++ 
    256                     sblName ++ "->" ++ sublogicName sub_trg 
     261                    if null sblName then "" else '.' : sblName 
     262               else "incl_" ++ lname ++ ':' 
     263                    : sblName ++ "->" ++ sublogicName sub_trg 
    257264 
    258265instance Logic lid sublogics 
     
    276283           map_theory _ = return 
    277284           map_morphism _ = return 
    278            map_sentence _ = \_ -> return 
     285           map_sentence _ _ = return 
    279286           map_symbol _ _ = Set.singleton 
    280287           constituents cid = 
     
    318325   mapSublogic (CompComorphism cid1 cid2) sl = 
    319326         mapSublogic cid1 sl >>= 
    320            (\ y -> mapSublogic cid2 $ 
    321           forceCoerceSublogic (targetLogic cid1) (sourceLogic cid2) y) 
    322    map_sentence (CompComorphism cid1 cid2) = 
    323        \si1 se1 -> 
     327           mapSublogic cid2 . 
     328            forceCoerceSublogic (targetLogic cid1) (sourceLogic cid2) 
     329   map_sentence (CompComorphism cid1 cid2) si1 se1 = 
    324330         do (si2,_) <- map_sign cid1 si1 
    325331            se2 <- map_sentence cid1 si1 se1 
     
    331337                _ -> error "CompComorphism.map_sentence" 
    332338 
    333    map_theory (CompComorphism cid1 cid2) = 
    334        \ti1 -> 
     339   map_theory (CompComorphism cid1 cid2) ti1 = 
    335340         do ti2 <- map_theory cid1 ti1 
    336341            ti2' <- coerceBasicTheory (targetLogic cid1) (sourceLogic cid2) 
     
    338343            wrapMapTheory cid2 ti2' 
    339344 
    340    map_morphism (CompComorphism cid1 cid2) = \ m1 -> 
     345   map_morphism (CompComorphism cid1 cid2) m1 = 
    341346       do m2 <- map_morphism cid1 m1 
    342347          m3 <- coerceMorphism (targetLogic cid1) (sourceLogic cid2) 
     
    459464         _ ->  -} return $ Comorphism (CompComorphism cid1 cid2) 
    460465       else fail $ "Subl" ++ msg 
    461     else fail $ "L" ++ msg 
     466    else fail $ 'L' : msg