2019-08-12 18:19:02 +02:00
|
|
|
module PersistEvaluationScheme where
|
|
|
|
|
|
|
|
import ClassyPrelude.Yesod
|
|
|
|
import Database.Persist.Sql
|
|
|
|
|
|
|
|
import GEval.EvaluationScheme
|
|
|
|
import qualified Data.Text as T
|
|
|
|
|
|
|
|
instance PersistField EvaluationScheme where
|
|
|
|
toPersistValue m = PersistText (T.pack $ show m)
|
|
|
|
|
|
|
|
fromPersistValue (PersistText t) = case readMay t of
|
|
|
|
Just val -> Right val
|
2021-02-27 15:00:22 +01:00
|
|
|
Nothing -> Left $ "Unexpected value '" ++ t ++ "'"
|
2019-08-12 18:19:02 +02:00
|
|
|
fromPersistValue _ = Left "Unexpected value"
|
|
|
|
|
|
|
|
instance PersistFieldSql EvaluationScheme where
|
|
|
|
sqlType _ = SqlString
|