agrafix / agrafix/elm-bridge

Good way to deal with Persistent's Entity?

Open
#30 9 comments 0 reactions 0 assignees View on GitHub
Dominant language
Elm
Stars
107
Forks
28
PR merge metrics
No merged PRs in 30d

Description

Im adapting to Yesod Persistent. Thus my old Game type becomes "[Entity](https://hackage.haskell.org/package/persistent-2.8.1/docs/Database-Persist-Types.html#t:Entity) Game" that is constructed as "Entity GameId Game" where type GameId = Key Game (or something like that).

ive managed to make stuff work by adding a wrapper that can be incorpoarated in elm-bridge, but it feels clumsy

`data Ent a b = Ent { _key :: a, _val :: b } deriving (Show,Generic)`

Incase you are familiar with Persistent, how would one incorporate encoding of (nested) entity types in elm-bridge.

trying to get :

`deriveBoth defaultOptions { fieldLabelModifier = drop 1} ''PS.Entity`

..to compile gives :

`Can't derive this sum: ForallC [] [AppT (ConT Database.Persist.Class.PersistEntity.PersistEntity) (VarT record_7566047373982557936)] (RecC Database.Persist.Class.PersistEntity.Entity [(Database.Persist.Class.PersistEntity.entityKey,Bang NoSourceUnpackedness NoSourceStrictness,AppT (ConT Database.Persist.Class.PersistEntity.Key) (VarT record_7566047373982557936)),(Database.Persist.Class.PersistEntity.entityVal,Bang NoSourceUnpackedness NoSourceStrictness,VarT record_7566047373982557936)])`

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.