TypeDecl.hs revision df638d53c2d5fe5e80b943a58609c8936848ed82
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder{- HetCATS/HasCASL/TypeDecl.hs
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder $Id$
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder Authors: Christian Maeder
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder Year: 2003
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder analyse type decls
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder-}
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maedermodule HasCASL.TypeDecl where
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maederimport HasCASL.As
bcd232120234d3cbbfd730b64a5a165f5c16e2a9Christian Maederimport HasCASL.AsUtils
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maederimport Common.AS_Annotation(item)
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maederimport HasCASL.ClassAna
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maederimport HasCASL.ClassDecl
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maederimport qualified Common.Lib.Map as Map
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maederimport Common.Id
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maederimport HasCASL.Le
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maederimport Data.Maybe
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maederimport Common.Lib.State
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maederimport Common.Lib.Parsec
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maederimport Common.Lib.Parsec.Error
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maederimport Common.Result
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maederimport Common.PrettyPrint
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maederimport HasCASL.TypeAna
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maederimport HasCASL.DataAna
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maederimport HasCASL.Reader
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maederimport HasCASL.Unify
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder-- ---------------------------------------------------------------------------
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder-- analyse types as state
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder-- ---------------------------------------------------------------------------
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian MaederfromReadR :: a -> ReadR (ClassMap, TypeMap) a -> State Env a
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian MaederfromReadR a r = toState a ( \ e -> (classMap e, typeMap e)) r
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian MaederanaTypeS :: (Kind, Type) -> State Env (Kind, Type)
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian MaederanaTypeS kt = fromReadR kt $ anaType kt
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder-- check with merge
bcd232120234d3cbbfd730b64a5a165f5c16e2a9Christian MaedercompatibleTypeDefn :: TypeDefn -> TypeDefn -> Id -> [Diagnosis]
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian MaedercompatibleTypeDefn d1 d2 i =
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder if case (d1, d2) of
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder (TypeVarDefn, TypeVarDefn) -> True
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder (TypeVarDefn, _) -> False
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder (_, TypeVarDefn) -> False
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder _ -> True
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder then [] else [mkDiag Error "incompatible redeclaration of type" i]
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder-- ---------------------------------------------------------------------------
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder-- storing type ids with their kind and definition
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder-- ---------------------------------------------------------------------------
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder-- | store a complete type map
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian MaederputTypeMap :: TypeMap -> State Env ()
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian MaederputTypeMap tk = do { e <- get; put e { typeMap = tk } }
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder-- | store type id and check the kind
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian MaederaddTypeId :: TypeDefn -> Instance -> Kind -> Id -> State Env ()
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder-- type args not yet considered for kind construction
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian MaederaddTypeId defn _ kind i@(Id ts _ _) =
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder do nk <- toState kind classMap $ expandKind kind
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder let n = length $ filter isPlace ts
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder if n <= kindArity TopLevel nk then
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder addTypeKind defn i kind
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder else addDiag $ mkDiag Error "wrong arity of" i
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder-- | store prefix type ids both with and without following places
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian MaederaddTypeKind :: TypeDefn -> Id -> Kind -> State Env ()
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian MaederaddTypeKind d i k =
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder if isPrefix i then do addSingleTypeKind d i k
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder addSingleTypeKind d (stripFinalPlaces i) k
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder else addSingleTypeKind d i k
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder-- | store type as is
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian MaederaddSingleTypeKind :: TypeDefn -> Id -> Kind -> State Env ()
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian MaederaddSingleTypeKind d i k =
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder do tk <- gets typeMap
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder case Map.lookup i tk of
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder Nothing -> putTypeMap $ Map.insert i
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder (TypeInfo k [] [] d) tk
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder Just (TypeInfo ok ks sups defn) ->
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder -- check with merge
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder do checkKindsS i k ok
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder if any (==k) (ok:ks)
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder then addDiag $ mkDiag Warning
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder "redeclared type" i
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder else putTypeMap $ Map.insert i
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder (TypeInfo ok
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder (k:ks) sups defn) tk
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder-- | add a supertype to a given type id
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian MaederaddSuperType :: Type -> Id -> State Env ()
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian MaederaddSuperType t i =
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder do tk <- gets typeMap
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder case Map.lookup i tk of
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder Nothing -> return () -- previous error
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder Just (TypeInfo ok ks sups defn) ->
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder putTypeMap $ Map.insert i
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder (TypeInfo ok ks (t:sups) defn)
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder tk
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder-- ---------------------------------------------------------------------------
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder-- analyse type items
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder-- ---------------------------------------------------------------------------
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian MaederanaTypeItem :: GenKind -> Instance -> TypeItem -> State Env ()
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian MaederanaTypeItem _ inst (TypeDecl pats kind _) =
9eaf4ea0944f7c5a1773c5f3c066f0117ece22dbChristian Maeder do anaKindS kind
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder let Result ds (Just is) = convertTypePatterns pats
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder appendDiags ds
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder mapM_ (addTypeId NoTypeDefn inst kind) is
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian MaederanaTypeItem _ inst (SubtypeDecl pats t _) =
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder do anaTypeS (star, t)
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder let Result ds (Just is) = convertTypePatterns pats
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder appendDiags ds
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder mapM_ (addTypeId NoTypeDefn inst star) is
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder mapM_ (addSuperType t) is
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian MaederanaTypeItem _ inst (IsoDecl pats _) =
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder do let Result ds (Just is) = convertTypePatterns pats
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder appendDiags ds
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder mapM_ (addTypeId NoTypeDefn inst star) is
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder mapM_ ( \ i -> mapM_ (addSuperType (TypeName i star 0)) is) is
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian MaederanaTypeItem _ inst (SubtypeDefn pat v t f ps) =
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder do (k, newT) <- anaTypeS (star, t)
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder checkKindsS t star k
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder addDiag $ Diag Warning ("unchecked formula '" ++ showPretty f "'")
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder $ firstPos [v] ps
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder let Result ds m = convertTypePattern pat
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder appendDiags ds
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder case m of
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder Nothing -> return ()
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder Just i -> do addTypeId (Supertype v newT $ item f)
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder inst k i
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder addSuperType newT i
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian MaederanaTypeItem _ inst (AliasType pat mk sc _) =
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder do (ik, newPty) <- anaPseudoType mk sc
9eaf4ea0944f7c5a1773c5f3c066f0117ece22dbChristian Maeder let Result ds m = convertTypePattern pat
9eaf4ea0944f7c5a1773c5f3c066f0117ece22dbChristian Maeder appendDiags ds
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder case m of
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder Just i -> addTypeId (AliasTypeDefn newPty) inst ik i
ea03c5d09694b4a966fbd19d46cfa5772648d95fChristian Maeder _ -> return ()
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian MaederanaTypeItem gk inst (Datatype d) = anaDatatype gk inst d
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian Maeder
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian MaederanaDatatype :: GenKind -> Instance -> DatatypeDecl -> State Env ()
502ed7ed7fecd10b6d0c83cdd48a244ec45e840aChristian MaederanaDatatype genKind inst (DatatypeDecl pat kind alts derivs _) =
9eaf4ea0944f7c5a1773c5f3c066f0117ece22dbChristian Maeder do k <- anaKindS kind
9eaf4ea0944f7c5a1773c5f3c066f0117ece22dbChristian Maeder checkKindsS pat star k
9eaf4ea0944f7c5a1773c5f3c066f0117ece22dbChristian Maeder case derivs of
Just c -> do (dk, _) <- anaClassS (star, c)
checkKindsS c star dk
Nothing -> return ()
let Result ds m = convertTypePattern pat
appendDiags ds
case m of
Nothing -> return ()
Just i ->
do let dt = TypeName i k 0
newAlts <- fromReadR [] $ anaAlts dt
$ map item alts
mapM_ ( \ (Construct c tc p sels) -> do
addOpId c (simpleTypeScheme $
getConstrType dt p tc)
[] (ConstructData i)
mapM_ ( \ (Select s ts pa) ->
addOpId s (simpleTypeScheme $
getSelType dt pa ts)
[] (SelectData [c] i)
) sels) newAlts
addTypeId (DatatypeDefn genKind [] newAlts) inst k i
anaPseudoType :: Maybe Kind -> TypeScheme -> State Env (Kind, TypeScheme)
anaPseudoType mk (TypeScheme tArgs (q :=> ty) p) =
do k <- case mk of
Nothing -> return star
Just j -> anaKindS j
tm <- gets typeMap -- save global variables
mapM_ anaTypeVarDecl tArgs
(sk, newTy) <- anaTypeS (k, ty)
let newPty = TypeScheme tArgs (q :=> newTy) p
newK = typeArgsListToKind tArgs sk
case mk of
Nothing -> return ()
Just j -> checkKindsS ty j newK
putTypeMap tm -- forget local variables
return (newK, newPty)
typeArgsListToKind :: [TypeArg] -> Kind -> Kind
typeArgsListToKind tArgs k =
if null tArgs then k
else typeArgsListToKind (init tArgs)
(KindAppl (typeArgToKind $ last tArgs) k [])
typeArgToKind :: TypeArg -> Kind
typeArgToKind (TypeArg _ k _ _) = k
anaTypeVarDecl :: TypeArg -> State Env ()
anaTypeVarDecl(TypeArg t k _ _) =
do nk <- anaKindS k
addTypeId TypeVarDefn Plain nk t
kindArity :: ApplMode -> Kind -> Int
kindArity m (KindAppl k1 k2 _) =
case m of
TopLevel -> kindArity OnlyArg k1 +
kindArity TopLevel k2
OnlyArg -> 1
kindArity m (ExtClass _ _ _) = case m of
TopLevel -> 0
OnlyArg -> 1
convertTypePatterns :: [TypePattern] -> Result [Id]
convertTypePatterns [] = Result [] $ Just []
convertTypePatterns (s:r) =
let Result d m = convertTypePattern s
Result ds (Just l) = convertTypePatterns r
in case m of
Nothing -> Result (d++ds) $ Just l
Just i -> Result (d++ds) $ Just (i:l)
convertTypePattern, makeMixTypeId :: TypePattern -> Result Id
convertTypePattern (TypePattern t _ _) = return t
convertTypePattern(TypePatternToken t) =
if isPlace t then fatal_error ("illegal type '__'") (tokPos t)
else return $ (simpleIdToId t)
convertTypePattern t =
if {- hasPlaces t && -} hasTypeArgs t then
fatal_error ( "arguments in type patterns not yet supported")
-- "illegal mix of '__' and '(...)'"
(posOfTypePattern t)
else makeMixTypeId t
-- TODO trailing places are not necessary for curried kinds
-- and should be ignored to avoid different Ids "Pred" and "Pred__"
typePatternToTokens :: TypePattern -> [Token]
typePatternToTokens (TypePattern ti _ _) = getTokenList place ti
typePatternToTokens (TypePatternToken t) = [t]
typePatternToTokens (MixfixTypePattern ts) = concatMap typePatternToTokens ts
typePatternToTokens (BracketTypePattern pk ts ps) =
let tts = map typePatternToTokens ts
expanded = concat $ expandPos (:[]) (getBrackets pk) tts ps in
case pk of
Parens -> if length tts == 1 &&
length (head tts) == 1 then head tts
else expanded
_ -> expanded
typePatternToTokens (TypePatternArg (TypeArg v _ _ _) _) =
[Token "__" (posOfId v)]
-- compound Ids not supported yet
getToken :: GenParser Token st Token
getToken = token tokStr tokPos Just
parseTypePatternId :: GenParser Token st Id
parseTypePatternId =
do ts <- many1 getToken
return $ Id ts [] []
makeMixTypeId t =
case parse parseTypePatternId "" (typePatternToTokens t) of
Left err -> fatal_error (showErrorMessages "or" "unknown parse error"
"expecting" "unexpected" "end of input"
(errorMessages err))
(errorPos err)
Right x -> return x
hasPlaces, hasTypeArgs :: TypePattern -> Bool
hasPlaces (TypePattern _ _ _) = False
hasPlaces (TypePatternToken t) = isPlace t
hasPlaces (MixfixTypePattern ts) = any hasPlaces ts
hasPlaces (BracketTypePattern _ ts _) = any hasPlaces ts
hasPlaces (TypePatternArg _ _) = False
hasTypeArgs (TypePattern _ _ _) = True
hasTypeArgs (TypePatternToken _) = False
hasTypeArgs (MixfixTypePattern ts) = any hasTypeArgs ts
hasTypeArgs (BracketTypePattern _ ts _) = any hasTypeArgs ts
hasTypeArgs (TypePatternArg _ _) = True
-- ---------------------------------------------------------------------------
-- for storing selectors and constructors
-- ---------------------------------------------------------------------------
-- | store assumptions
putAssumps :: Assumps -> State Env ()
putAssumps as = do { e <- get; put e { assumps = as } }
unifiable :: TypeScheme -> TypeScheme -> State Env Bool
unifiable sc1 sc2 =
do tm <- gets typeMap
c <- gets counter
let Result ds mm = evalState (unifIable tm sc1 sc2) c
appendDiags ds
return $ isJust mm
-- | storing an operation
addOpId :: UninstOpId -> TypeScheme -> [OpAttr] -> OpDefn -> State Env ()
addOpId i sc attrs defn =
do as <- gets assumps
let l = Map.findWithDefault [] i as
if sc `elem` map opType l then
addDiag $ mkDiag Warning
"repeated value" i
else do bs <- mapM (unifiable sc) $ map opType l
if or bs then addDiag $ mkDiag Error
"illegal overloading of" i
else putAssumps $ Map.insert i
(OpInfo sc attrs defn : l ) as