gonito/PersistMetric.hs

19 lines
452 B
Haskell
Raw Normal View History

2015-12-12 18:53:20 +01:00
module PersistMetric where
import ClassyPrelude.Yesod
import Database.Persist.Sql
import GEval.Core
import qualified Data.Text as T
instance PersistField Metric where
toPersistValue m = PersistText (T.pack $ show m)
fromPersistValue (PersistText t) = case readMay t of
Just val -> Right val
Nothing -> Left "Unexpected value"
fromPersistValue _ = Left "Unexpected value"
instance PersistFieldSql Metric where
sqlType _ = SqlString