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.

  1. word8_to_enum :: Enum e => Word8 -> e

    hosc Sound.Osc.Coding.Convert

    Type-specialised toEnum of fromIntegral

  2. dbEnums :: DatabaseDefinitions -> [EnumType]

    hpqtypes-extras Database.PostgreSQL.PQTypes.Checks

    No documentation available.

  3. newtype SQLEnum a

    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)]
    

  4. SQLEnum :: a -> SQLEnum a

    hpqtypes-extras Database.PostgreSQL.PQTypes.Deriving

    No documentation available.

  5. newtype SQLEnumAsText a

    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"]
    

  6. SQLEnumAsText :: a -> SQLEnumAsText a

    hpqtypes-extras Database.PostgreSQL.PQTypes.Deriving

    No documentation available.

  7. decodeEnum :: EnumEncoding a => EnumBase a -> Either [(EnumBase a, EnumBase a)] a

    hpqtypes-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.

  8. decodeEnumAsText :: EnumAsTextEncoding a => Text -> Either [Text] a

    hpqtypes-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.

  9. decodeEnumAsTextMap :: EnumAsTextEncoding a => Map Text a

    hpqtypes-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.

  10. decodeEnumMap :: EnumEncoding a => Map (EnumBase a) a

    hpqtypes-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.

Page 178 of many | Previous | Next