1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
{-# LANGUAGE DeriveLift #-}
-- | This module contains types and functions for working with and
-- disambiguating database and Haskell names.
--
-- @since 2.13.0.0
module Database.Persist.Names where
import Data.Text (Text)
import Language.Haskell.TH.Syntax (Lift)
-- Bring `Lift (Map k v)` instance into scope, as well as `Lift Text`
-- instance on pre-1.2.4 versions of `text`
import Instances.TH.Lift ()
-- | Convenience operations for working with '-NameDB' types.
--
-- @since 2.12.0.0
class DatabaseName a where
escapeWith :: (Text -> str) -> (a -> str)
-- | A 'FieldNameDB' represents the datastore-side name that @persistent@
-- will use for a field.
--
-- @since 2.12.0.0
newtype FieldNameDB = FieldNameDB { unFieldNameDB :: Text }
deriving (Show, Eq, Read, Ord, Lift)
-- | @since 2.12.0.0
instance DatabaseName FieldNameDB where
escapeWith f (FieldNameDB n) = f n
-- | A 'FieldNameHS' represents the Haskell-side name that @persistent@
-- will use for a field.
--
-- @since 2.12.0.0
newtype FieldNameHS = FieldNameHS { unFieldNameHS :: Text }
deriving (Show, Eq, Read, Ord, Lift)
-- | An 'EntityNameHS' represents the Haskell-side name that @persistent@
-- will use for an entity.
--
-- @since 2.12.0.0
newtype EntityNameHS = EntityNameHS { unEntityNameHS :: Text }
deriving (Show, Eq, Read, Ord, Lift)
-- | An 'EntityNameDB' represents the datastore-side name that @persistent@
-- will use for an entity.
--
-- @since 2.12.0.0
newtype EntityNameDB = EntityNameDB { unEntityNameDB :: Text }
deriving (Show, Eq, Read, Ord, Lift)
instance DatabaseName EntityNameDB where
escapeWith f (EntityNameDB n) = f n
-- | A 'ConstraintNameDB' represents the datastore-side name that @persistent@
-- will use for a constraint.
--
-- @since 2.12.0.0
newtype ConstraintNameDB = ConstraintNameDB { unConstraintNameDB :: Text }
deriving (Show, Eq, Read, Ord, Lift)
-- | @since 2.12.0.0
instance DatabaseName ConstraintNameDB where
escapeWith f (ConstraintNameDB n) = f n
-- | An 'ConstraintNameHS' represents the Haskell-side name that @persistent@
-- will use for a constraint.
--
-- @since 2.12.0.0
newtype ConstraintNameHS = ConstraintNameHS { unConstraintNameHS :: Text }
deriving (Show, Eq, Read, Ord, Lift)
|