agentm / agentm/project-m36

can't infer ConstructedAtomType properly

Offen
#225 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Haskell
Sterne
952
Forks
50
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

Hi, @agentm

I was creating a schema by trying project-m36-typed example with `CrashSafePersistence` db, and then tried to test an insert by tutd. But I can't find a way to input `ConstructedAtomType` in tutd. I can input `Just "something"` but not `Nothing`. It seems tutd can't infer Nothing's type.

```
TutorialD (master/main): :showexpr temp
┌───────────────────────────────────┬──────────────────────┬───────────────────────┐
│phoneNumberComment::Maybe (a::Text)│phoneNumberEmail::Text│phoneNumberNumber::Text│
├───────────────────────────────────┼──────────────────────┼───────────────────────┤
│Just "12345" │"12345" │"12345" │
└───────────────────────────────────┴──────────────────────┴───────────────────────┘
TutorialD (master/main): insert temp relation{tuple{ phoneNumberComment (Just "12346"), phoneNumberEmail "12346", phoneNumberNumber "12346"}}
TutorialD (master/main): :showexpr temp
┌───────────────────────────────────┬──────────────────────┬───────────────────────┐
│phoneNumberComment::Maybe (a::Text)│phoneNumberEmail::Text│phoneNumberNumber::Text│
├───────────────────────────────────┼──────────────────────┼───────────────────────┤
│Just "12345" │"12345" │"12345" │
│Just "12346" │"12346" │"12346" │
└───────────────────────────────────┴──────────────────────┴───────────────────────┘
TutorialD (master/main): insert temp relation{tuple{ phoneNumberComment (Nothing), phoneNumberEmail "12346", phoneNumberNumber "12346"}}
ERR: TypeConstructorTypeVarsMismatch (fromList ["a"]) (fromList [])

```

And in the meantime, I can't auto-derive some newtype Atomable from base Atoms.

```
newtype SafeId = SafeId B.ByteString
deriving (Eq, Ord, Show, Generic)
deriving newtype (NFData, Binary)

-- * Couldn't match representation of type `proxy ByteString'
-- with that of `proxy SafeId'
-- arising from the coercion of the method `toAtomType'
-- from type `forall (proxy :: * -> *).
-- proxy ByteString -> ProjectM36.Base.AtomType'
-- to type `forall (proxy :: * -> *).
-- proxy SafeId -> ProjectM36.Base.AtomType'
-- NB: We cannot know what roles the parameters to `proxy' have;
-- we must assume that the role is nominal
-- * When deriving the instance for (Atomable SafeId)

```
It's due to some type role issue. And change `proxy` to `Proxy` may work (saw this advice somewhere).
Is there any reason to have a `toAtomType :: proxy a ->` ... with a type variable instead of the Proxy type?

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.