mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-31 20:43:41 +00:00
19 lines
557 B
Haskell
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
|