agentm / project-m36

Project: M36 Relational Algebra Engine
The Unlicense
894 stars 48 forks source link

`toDefineExpr` for `Either` type is missing the `TypeVarMap` #301

Closed farzadbekran closed 2 years ago

farzadbekran commented 2 years ago

Given a simple record type which auto derives Atomable and Tupleable, if it contains an Either type field, toDefineExpr returns an invalid expression:

data TestType = TestType { eTextInt :: Either Text Int }
  deriving (Generic, Show, Eq, NFData, Atomable, Tupleable)
  deriving W.Serialise via W.WineryVariant TestType

In ghci:

> toDefineExpr (Proxy :: Proxy TestType) "testType"
Define "testType" [NakedAttributeExpr (Attribute "eTextInt" (ConstructedAtomType "Either" (fromList [])))]

What is expected:

> toDefineExpr (Proxy :: Proxy TestType) "testType"
Define "testType" [NakedAttributeExpr (Attribute "eTextInt" (ConstructedAtomType "Either" (fromList [("a", TextAtomType), ("b", IntAtomType)])))]
agentm commented 2 years ago

Good catch- we were just missing a function in Atomable.