1
我有一個Haskell Status
類型:映射哈斯克爾類型Postgres數據庫持久性
data Status = FirstViewed | Reviewed | Learned
我怎麼能這個數據映射到持久Postgres數據庫?
share [mkPersist sqlSettings, mkMigrate "migrateAll"] [persistLowerCase|
Vocabulary sql=vocabulary
word Text
date UTCTime
status Status
deriving Show
|]
你可以使用['derivePersistField'](https://hackage.haskell.org/package/persistent-template-2.5.2/docs/Database-Persist-TH.html#v:derivePersistField)模板Haskell函數爲持久化派生必要的實例來序列化和反序列化它。 –