Closed YuMingLiao closed 2 years ago
I am able to reproduce this with:
{-# LANGUAGE OverloadedStrings #-}
import ProjectM36.Client
main :: IO ()
main = do
Right conn <- connectProjectM36 (InProcessConnectionInfo NoPersistence emptyNotificationCallback [])
Right sessionId <- createSessionAtHead conn defaultHeadName
executeDatabaseContextExpr sessionId conn (Define "x" [AttributeAndTypeNameExpr "a" (ADTypeConstructor "Nope" []) ()]) >>= print
executeDatabaseContextExpr sessionId conn (Define "y" [NakedAttributeExpr (Attribute "b" (ConstructedAtomType "Spam" mempty))]) >>= print
$ ./Test356
"SPAM"
Left (NoSuchTypeConstructorError "Nope")
Left (TypeConstructorAtomTypeMismatch "Spam" (ConstructedAtomType "Spam" (fromList [])))
The difference in the errors is that, in some contexts when we have multiple NakedAtomExprs, we know what type is expected, so we can return an error explaining which type was expected. In the above context though, the comparison type doesn't exist. I'll improve the error.
I think that you are right. In the context of an unknown type constructor, the correct error is NoSuchTypeConstructorError
.
Thanks for the clarification and fixing. Amazing project!
In client side, If I
Define ... [AttributeAndTypeNameExpr ...]
with an non-existent datatype, I getNoSuchTypeConstructorError
. I found this error is easier for me to understand.If I
Define ...[NakedAttributeExpr ...]
with an non-existent datatype, I getTypeConstructorAtomTypeMismatch
.What's their difference? (project-m36-typed uses NakedAttributeExpr to define.)