Hoogle Search
Within LTS Haskell 24.33 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
word8_to_enum :: Enum e => Word8 -> ehosc Sound.Osc.Coding.Convert Type-specialised toEnum of fromIntegral
dbEnums :: DatabaseDefinitions -> [EnumType]hpqtypes-extras Database.PostgreSQL.PQTypes.Checks No documentation available.
-
hpqtypes-extras Database.PostgreSQL.PQTypes.Deriving Helper newtype to be used with deriving via to derive (PQFormat, ToSQL, FromSQL) instances for enums, given an instance of EnumEncoding. Hint: non-trivial Enum instances can be derived using the 'generic-data' package!
>>> :{ data Colours = Blue | Black | Red | Mauve | Orange deriving (Eq, Show, Enum, Bounded) instance EnumEncoding Colours where type EnumBase Colours = Int16 encodeEnum = \case Blue -> 1 Black -> 7 Red -> 2 Mauve -> 6 Orange -> 3 :}Note: To get SQL-specific instances use DerivingVia:data Colours = ... ... deriving (PQFormat, ToSQL, FromSQL) via SQLEnum Colours
>>> isInjective (encodeEnum @Colours) True
>>> decodeEnum @Colours 7 Right Black
>>> decodeEnum @Colours 42 Left [(1,3),(6,7)]
-
hpqtypes-extras Database.PostgreSQL.PQTypes.Deriving No documentation available.
-
hpqtypes-extras Database.PostgreSQL.PQTypes.Deriving A special case of SQLEnum, where the enum is to be encoded as text (SQLEnum can't be used because of the Enum constraint on the domain of encodeEnum).
>>> :{ data Person = Alfred | Bertrand | Charles deriving (Eq, Show, Enum, Bounded) instance EnumAsTextEncoding Person where encodeEnumAsText = \case Alfred -> "alfred" Bertrand -> "bertrand" Charles -> "charles" :}Note: To get SQL-specific instances use DerivingVia:data Person = ... ... deriving (PQFormat, ToSQL, FromSQL) via SQLEnumAsText Person
>>> isInjective (encodeEnumAsText @Person) True
>>> decodeEnumAsText @Person "bertrand" Right Bertrand
>>> decodeEnumAsText @Person "batman" Left ["alfred","bertrand","charles"]
SQLEnumAsText :: a -> SQLEnumAsText ahpqtypes-extras Database.PostgreSQL.PQTypes.Deriving No documentation available.
decodeEnum :: EnumEncoding a => EnumBase a -> Either [(EnumBase a, EnumBase a)] ahpqtypes-extras Database.PostgreSQL.PQTypes.Deriving Decode base type to an a. If the conversion fails, a list of valid ranges is returned instead. Note: The default implementation looks up values in decodeEnumMap and can be overwritten for performance if necessary.
decodeEnumAsText :: EnumAsTextEncoding a => Text -> Either [Text] ahpqtypes-extras Database.PostgreSQL.PQTypes.Deriving Decode Text to an a. If the conversion fails, a list of valid values is returned instead. Note: The default implementation looks up values in decodeEnumAsTextMap and can be overwritten for performance if necessary.
decodeEnumAsTextMap :: EnumAsTextEncoding a => Map Text ahpqtypes-extras Database.PostgreSQL.PQTypes.Deriving Include the inverse map as a top-level part of the SQLEnumTextEncoding instance to ensure it is only computed once by GHC.
decodeEnumMap :: EnumEncoding a => Map (EnumBase a) ahpqtypes-extras Database.PostgreSQL.PQTypes.Deriving Include the inverse map as a top-level part of the EnumEncoding instance to ensure it is only computed once by GHC.