Hoogle Search

Within LTS Haskell 24.32 (ghc-9.10.3)

Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.

  1. enumDirective :: DirectiveConstraint a => TypeName -> a -> DirectiveUsages

    morpheus-graphql-server Data.Morpheus.Server.Types

    No documentation available.

  2. enumDirective' :: DirectiveConstraint a => Name -> a -> DirectiveUsages

    morpheus-graphql-server Data.Morpheus.Server.Types

    No documentation available.

  3. enumFromField :: EnumMapper sqlEnum haskellSum -> FromField sqlEnum haskellSum

    opaleye Opaleye.Experimental.Enum

    No documentation available.

  4. enumMapper :: String -> (String -> Maybe haskellSum) -> (haskellSum -> String) -> EnumMapper sqlEnum haskellSum

    opaleye Opaleye.Experimental.Enum

    Create a mapping between a Postgres ENUM type and a Haskell type. Also works for DOMAIN types. For example, if you have the following ENUM

    CREATE TYPE public.mpaa_rating AS ENUM (
    'G',
    'PG',
    'PG-13',
    'R',
    'NC-17'
    );
    
    then you can define data types to represent the enum on the SQL side and Haskell side respectively
    data SqlRating
    data Rating = G | PG | PG13 | R | NC17 deriving Show
    
    and functions to map between them
    toSqlRatingString :: Rating -> String
    toSqlRatingString r = case r of
    G    -> "G"
    PG   -> "PG"
    PG13 -> "PG-13"
    R    -> "R"
    NC17 -> "NC-17"
    
    fromSqlRatingString :: String -> Maybe Rating
    fromSqlRatingString s = case s of
    "G"     -> Just G
    "PG"    -> Just PG
    "PG-13" -> Just PG13
    "R"     -> Just R
    "NC-17" -> Just NC17
    _       -> Nothing
    
    Then you can use the mappings as follows
    import qualified Opaleye as O
    import qualified Data.Profunctor.Product.Default as D
    
    sqlRatingMapper :: EnumMapper SqlRating Rating
    sqlRatingMapper = enumMapper "mpaa_rating" fromSqlRatingString toSqlRatingString
    
    instance O.DefaultFromField SqlRating Rating where
    defaultFromField = enumFromField sqlRatingMapper
    
    instance rating ~ Rating
    => D.Default (Inferrable O.FromField) SqlRating rating where
    def = inferrableDef
    
    instance D.Default O.ToFields Rating (O.Field SqlRating) where
    def = enumToFields sqlRatingMapper
    
    instance IsSqlType SqlRating where
    showSqlType = enumShowSqlType sqlRatingMapper
    

  5. enumMapperWithSchema :: String -> String -> (String -> Maybe haskellSum) -> (haskellSum -> String) -> EnumMapper sqlEnum haskellSum

    opaleye Opaleye.Experimental.Enum

    No documentation available.

  6. enumShowSqlType :: EnumMapper sqlEnum haskellSum -> forall (proxy :: Type -> Type) . () => proxy sqlEnum -> String

    opaleye Opaleye.Experimental.Enum

    No documentation available.

  7. enumToFields :: EnumMapper sqlEnum haskellSum -> ToFields haskellSum (Field sqlEnum)

    opaleye Opaleye.Experimental.Enum

    No documentation available.

  8. enumToInt :: WireEnum a => a -> Int32

    protobuf-simple Data.ProtoBufInt

    Convert a enum value to an Int32.

  9. enumToInt :: WireEnum a => a -> Int32

    protobuf-simple Data.ProtoBufInt

    Convert a enum value to an Int32.

  10. enum8toWord8 :: Enum8 -> Word8

    rainbow Rainbow.Types

    No documentation available.

Page 80 of many | Previous | Next