haskell - How to use record-syntax with Yesod-Persistent -
why doesn't following work? kinda know there's lot going under hood , user
type doesn't have email
, createdat
, , updatedat
field. what's best way not instantiate objects using positional parameters, can go out of hand?
share [mkpersist sqlsettings, mkmigrate "migrateall"] [persistlowercase| user email string createdat utctime maybe default=current_time updatedat utctime maybe default=current_time deriving show ]] main :: io () main = runsqlite ":memory:" $ runmigration migrateall u <- insert $ user {email="saurabhnanda@gmail.com" createdat=nothing updatedat=nothing}
compilation errors:
trysql.hs:38:23: ‘email’ not (visible) field of constructor ‘user’ trysql.hs:38:55: ‘createdat’ not (visible) field of constructor ‘user’ trysql.hs:38:74: ‘updatedat’ not (visible) field of constructor ‘user’
the function names like: useremail
, usercreatedat
, userupdatedat
.
running cabal repl , browsing project identify yesod generated functions persistent types.
Comments
Post a Comment