Hoogle Search
Within LTS Haskell 24.52 (ghc-9.10.3)
Note that Stackage only displays results for the latest LTS and Nightly snapshot. Learn more.
boundedEnumCodec :: (Eq enum, Enum enum, Bounded enum) => (enum -> Text) -> JSONCodec enumautodocodec Autodocodec A codec for a Bounded Enum that uses the provided function to have the values correspond to literal Text values.
Example usage
>>> data Fruit = Apple | Orange deriving (Show, Eq, Enum, Bounded) >>> :{ let c = boundedEnumCodec $ \case Apple -> "foo" Orange -> "bar" :}>>> toJSONVia c Apple String "foo" >>> JSON.parseMaybe (parseJSONVia c) (String "bar") :: Maybe Fruit Just Orange
enumCodec :: Eq enum => NonEmpty (enum, Codec context enum enum) -> Codec context enum enumautodocodec Autodocodec A codec for an enum that can be written each with their own codec.
WARNING
If you don't provide a string for one of the type's constructors, the last codec in the list will be used instead.shownBoundedEnumCodec :: (Show enum, Eq enum, Enum enum, Bounded enum) => JSONCodec enumautodocodec Autodocodec A codec for a Bounded Enum that uses its Show instance to have the values correspond to literal Text values.
Example usage
>>> data Fruit = Apple | Orange deriving (Show, Eq, Enum, Bounded) >>> let c = shownBoundedEnumCodec >>> toJSONVia c Apple String "Apple" >>> JSON.parseMaybe (parseJSONVia c) (String "Orange") :: Maybe Fruit Just Orange
boundedEnumCodec :: (Eq enum, Enum enum, Bounded enum) => (enum -> Text) -> JSONCodec enumautodocodec Autodocodec.Codec A codec for a Bounded Enum that uses the provided function to have the values correspond to literal Text values.
Example usage
>>> data Fruit = Apple | Orange deriving (Show, Eq, Enum, Bounded) >>> :{ let c = boundedEnumCodec $ \case Apple -> "foo" Orange -> "bar" :}>>> toJSONVia c Apple String "foo" >>> JSON.parseMaybe (parseJSONVia c) (String "bar") :: Maybe Fruit Just Orange
enumCodec :: Eq enum => NonEmpty (enum, Codec context enum enum) -> Codec context enum enumautodocodec Autodocodec.Codec A codec for an enum that can be written each with their own codec.
WARNING
If you don't provide a string for one of the type's constructors, the last codec in the list will be used instead.shownBoundedEnumCodec :: (Show enum, Eq enum, Enum enum, Bounded enum) => JSONCodec enumautodocodec Autodocodec.Codec A codec for a Bounded Enum that uses its Show instance to have the values correspond to literal Text values.
Example usage
>>> data Fruit = Apple | Orange deriving (Show, Eq, Enum, Bounded) >>> let c = shownBoundedEnumCodec >>> toJSONVia c Apple String "Apple" >>> JSON.parseMaybe (parseJSONVia c) (String "Orange") :: Maybe Fruit Just Orange
enumTypeFrom :: IsEnumType a => a -> NS (K () :: [Type] -> Type) (Code a)generics-sop Generics.SOP Convert from an enum type to its sum representation.
enumTypeTo :: IsEnumType a => NS (K () :: [Type] -> Type) (Code a) -> agenerics-sop Generics.SOP Convert a sum representation to ihe original type.
enumTypeFrom :: IsEnumType a => a -> NS (K () :: [Type] -> Type) (Code a)generics-sop Generics.SOP.Universe Convert from an enum type to its sum representation.
enumTypeTo :: IsEnumType a => NS (K () :: [Type] -> Type) (Code a) -> agenerics-sop Generics.SOP.Universe Convert a sum representation to ihe original type.