Closed YuMingLiao closed 2 years ago
TutorialD (master/main): :showexpr nutrition{`樣本數`}:{sample := text2MaybeInt(@`樣本數`)}
"extTupProc:FunctionAtomExpr \"text2MaybeInt\" [AttributeAtomExpr \"\\27171\\26412\\25976\"] UncommittedContextMarker
ConstructedAtomType \"Maybe\" (fromList [])"
"expectedType:ConstructedAtomType \"Maybe\" (fromList [])"
ERR: TypeConstructorTypeVarsTypesMismatch "Maybe" (fromList []) (fromList [("a",IntAtomType)])
It seems that parsing FunctionAtomExpr couldn't get Maybe Int
.
Ugh- I've had problems with this function in the past. With hindsight, we should have two different data types for concrete (saturated) data types and those which are not yet resolved. I'll take a look to see what the best solution is here.
I am able to reproduce this with this script:
TutorialD (master/main): addatomfunction "text2MaybeInt" Text -> Either AtomFunctionError (Maybe Int) """(const $ Right $ ConstructedAtom "Just" (ConstructedAtomType "Maybe" (Data.Map.singleton "a" IntAtomType)) [IntegerAtom 4]) :: [Atom] -> Either AtomFunctionError Atom"""
TutorialD (master/main): :showexpr relation{tuple{spam text2MaybeInt("123")}}
ERR: AtomFunctionTypeVariableResolutionError "text2MaybeInt" "a"
I've pushed a fix for the immediate issue, but I would still like to separate saturated and unsaturated types- that would prevent a lot of these types of issues.
It seems the return type
Maybe Int
is not considered as resolved.Should I go further to check there is no TypeVariable in retMap to determine if it is resolved?