@@ -12,7 +12,6 @@ import qualified Data.List as L
1212import Data.Maybe (isJust)
1313import Control.Monad.Writer
1414import qualified Data.Map as M
15−--import Debug.Trace
1615
1716findDataConstructor :: DataConstructorName -> TypeConstructorMapping -> Maybe (TypeConstructorDef, DataConstructorDef)
1817findDataConstructor dName tConsList = foldr tConsFolder Nothing tConsList
@@ -108,12 +107,11 @@ resolveTypeConstructorTypeVars (ADTypeConstructor tConsName _) (ConstructedAtomT
108107 else
109108 case findTypeConstructor tConsName tConss of
110109 Nothing -> Left (NoSuchTypeConstructorName tConsName)
111− Just (tConsDef, _) -> let expectedPVars = S.fromList (TCD.typeVars tConsDef)
112− actualPVars = M.keysSet pVarMap' in
113− if expectedPVars /= actualPVars then
114− Left (TypeConstructorTypeVarsMismatch expectedPVars actualPVars)
115− else
116− Right (pVarMap')
110+ Just (tConsDef, _) -> let expectedPVarNames = S.fromList (TCD.typeVars tConsDef) in
111+ if M.keysSet pVarMap' `S.isSubsetOf` expectedPVarNames 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 expectedPVarNames (M.keysSet pVarMap'))
117115resolveTypeConstructorTypeVars _ _ _ = error "Unhandled type vars"
118116
119117-- check that type vars on the right also appear on the left