agentm / project-m36

Project: M36 Relational Algebra Engine
The Unlicense
876 stars 47 forks source link

can't deduce a TypeConstructorTypeVar in a Assign expression #254

Closed YuMingLiao closed 4 years ago

YuMingLiao commented 4 years ago
TutorialD (master/main): data A a = A | B a
TutorialD (master/main): a :: {a A Integer}
TutorialD (master/main): a := relation{tuple{a A}}
ERR: TypeConstructorTypeVarMissing "a"
TutorialD (master/main): a := relation{tuple{a B 1}}
TutorialD (master/main): :showexpr a
┌─────────────────┐
│a::A (a::Integer)│
├─────────────────┤
│B 1              │
└─────────────────┘
TutorialD (master/main): a := relation{tuple{a B 1}, tuple {a A}}
ERR: TypeConstructorTypeVarMissing "a"
TutorialD (master/main): 
YuMingLiao commented 4 years ago

Oops, I forgot I have asked this question in #225...

The type inference problem is covered by #46 where there is thankfully an easy workaround by adding the type to the relation

TutorialD (master/main): a := relation{a A Integer}{tuple{a A}}
TutorialD (master/main): :showexpr a
┌─────────────────┐
│a::A (a::Integer)│
├─────────────────┤
│A                │
└─────────────────┘