on master help sign in
allow atomTypeForAtom to pass back invalid type var map which is resolved later
c0554e0AgentM
ProjectM36/AtomType.hs+5−7
@@ -12,7 +12,6 @@ import qualified Data.List as L
12import Data.Maybe (isJust)
12import Data.Maybe (isJust)
13import Control.Monad.Writer
13import Control.Monad.Writer
14import qualified Data.Map as M
14import qualified Data.Map as M
15−--import Debug.Trace
16
15
17findDataConstructor :: DataConstructorName -> TypeConstructorMapping -> Maybe (TypeConstructorDef, DataConstructorDef)
16findDataConstructor :: DataConstructorName -> TypeConstructorMapping -> Maybe (TypeConstructorDef, DataConstructorDef)
18findDataConstructor dName tConsList = foldr tConsFolder Nothing tConsList
17findDataConstructor dName tConsList = foldr tConsFolder Nothing tConsList
@@ -108,12 +107,11 @@ resolveTypeConstructorTypeVars (ADTypeConstructor tConsName _) (ConstructedAtomT
108 else
107 else
109 case findTypeConstructor tConsName tConss of
108 case findTypeConstructor tConsName tConss of
110 Nothing -> Left (NoSuchTypeConstructorName tConsName)
109 Nothing -> Left (NoSuchTypeConstructorName tConsName)
111− Just (tConsDef, _) -> let expectedPVars = S.fromList (TCD.typeVars tConsDef)
110+ Just (tConsDef, _) -> let expectedPVarNames = S.fromList (TCD.typeVars tConsDef) in
112− actualPVars = M.keysSet pVarMap' in
111+ if M.keysSet pVarMap' `S.isSubsetOf` expectedPVarNames then
113− if expectedPVars /= actualPVars then
112+ Right pVarMap' -- I wish we could actually resolve this- we are creating temporary AtomTypes which are actually invalid until they are resolved with a second pass of type resolution- not great
113+ else
114− Left (TypeConstructorTypeVarsMismatch expectedPVars actualPVars)
114+ Left (TypeConstructorTypeVarsMismatch expectedPVarNames (M.keysSet pVarMap'))
115− else
116− Right (pVarMap')
117resolveTypeConstructorTypeVars _ _ _ = error "Unhandled type vars"
115resolveTypeConstructorTypeVars _ _ _ = error "Unhandled type vars"
118
116
119-- check that type vars on the right also appear on the left
117-- check that type vars on the right also appear on the left