postgresql-types
Safe HaskellNone
LanguageHaskell2010

PostgresqlTypes.Bpchar

Synopsis

Documentation

data Bpchar (numChars :: Nat) Source #

PostgreSQL bpchar(n), char(n), or character(n) type. Fixed-length, blank-padded character string.

PostgreSQL docs.

The type parameter numChars specifies the static length of the character string. Only character strings with exactly this length can be represented by this type.

Important: Do not confuse this with the quoted "char" type, which is a special single-byte internal type used in PostgreSQL system catalogs. The quoted "char" type is represented by Char, not by Bpchar 1.

  • Bpchar n represents bpchar(n), char(n), or character(n) — fixed-length, blank-padded strings
  • Char represents "char" (quoted) — single-byte internal type

For example, char(1) in SQL is Bpchar 1 in Haskell, while "char" in SQL is Char in Haskell. These are completely different types in PostgreSQL.

Instances

Instances details
KnownNat numChars => Arbitrary (Bpchar numChars) Source # 
Instance details

Defined in PostgresqlTypes.Bpchar

Methods

arbitrary :: Gen (Bpchar numChars) #

shrink :: Bpchar numChars -> [Bpchar numChars] #

Eq (Bpchar numChars) Source # 
Instance details

Defined in PostgresqlTypes.Bpchar

Methods

(==) :: Bpchar numChars -> Bpchar numChars -> Bool #

(/=) :: Bpchar numChars -> Bpchar numChars -> Bool #

Ord (Bpchar numChars) Source # 
Instance details

Defined in PostgresqlTypes.Bpchar

Methods

compare :: Bpchar numChars -> Bpchar numChars -> Ordering #

(<) :: Bpchar numChars -> Bpchar numChars -> Bool #

(<=) :: Bpchar numChars -> Bpchar numChars -> Bool #

(>) :: Bpchar numChars -> Bpchar numChars -> Bool #

(>=) :: Bpchar numChars -> Bpchar numChars -> Bool #

max :: Bpchar numChars -> Bpchar numChars -> Bpchar numChars #

min :: Bpchar numChars -> Bpchar numChars -> Bpchar numChars #

KnownNat numChars => IsString (Bpchar numChars) Source # 
Instance details

Defined in PostgresqlTypes.Bpchar

Methods

fromString :: String -> Bpchar numChars #

KnownNat numChars => Read (Bpchar numChars) Source # 
Instance details

Defined in PostgresqlTypes.Bpchar

Methods

readsPrec :: Int -> ReadS (Bpchar numChars) #

readList :: ReadS [Bpchar numChars] #

readPrec :: ReadPrec (Bpchar numChars) #

readListPrec :: ReadPrec [Bpchar numChars] #

KnownNat numChars => Show (Bpchar numChars) Source # 
Instance details

Defined in PostgresqlTypes.Bpchar

Methods

showsPrec :: Int -> Bpchar numChars -> ShowS #

show :: Bpchar numChars -> String #

showList :: [Bpchar numChars] -> ShowS #

Hashable (Bpchar numChars) Source # 
Instance details

Defined in PostgresqlTypes.Bpchar

Methods

hashWithSalt :: Int -> Bpchar numChars -> Int #

hash :: Bpchar numChars -> Int #

KnownNat numChars => IsScalar (Bpchar numChars) Source # 
Instance details

Defined in PostgresqlTypes.Bpchar

Accessors

toText :: forall (numChars :: Nat). KnownNat numChars => Bpchar numChars -> Text Source #

Extract the underlying Text value.

toString :: forall (numChars :: Nat). KnownNat numChars => Bpchar numChars -> String Source #

Convert the Bpchar to a String.

Constructors

refineFromText :: forall (numChars :: Nat). KnownNat numChars => Text -> Maybe (Bpchar numChars) Source #

Construct a PostgreSQL Bpchar from Text with validation. Returns Nothing if the text length doesn't exactly match the expected length.

normalizeFromText :: forall (numChars :: Nat). KnownNat numChars => Text -> Bpchar numChars Source #

Construct a PostgreSQL Bpchar from Text. Truncates or pads with spaces to match the type-level length.

refineFromString :: forall (numChars :: Nat). KnownNat numChars => String -> Maybe (Bpchar numChars) Source #

Construct a PostgreSQL Bpchar from String with validation. Returns Nothing if the string length doesn't exactly match the expected length.

normalizeFromString :: forall (numChars :: Nat). KnownNat numChars => String -> Bpchar numChars Source #

Construct a PostgreSQL Bpchar from String. Truncates or pads with spaces to match the type-level length.