Files
start-os/agent/src/Orphans/UUID.hs
Aiden McClelland 95d3845906 0.2.5 initial commit
Makefile incomplete
2020-11-23 13:44:28 -07:00

19 lines
557 B
Haskell

{-# OPTIONS_GHC -fno-warn-orphans #-}
module Orphans.UUID where
import Startlude
import Data.UUID
import Database.Persist.Sql
import Yesod.Core
instance PathPiece UUID where
toPathPiece = show
fromPathPiece = readMaybe
instance PersistField UUID where
toPersistValue = PersistText . show
fromPersistValue (PersistText t) = note "Invalid UUID" $ readMaybe t
fromPersistValue other = Left $ "Invalid UUID: " <> show other
instance PersistFieldSql UUID where
sqlType _ = SqlString