Hoogle Search
Within LTS Haskell 24.50 (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
DecimalNumber :: GeneralCategoryrio RIO.Char Nd: Number, Decimal
LetterNumber :: GeneralCategoryrio RIO.Char Nl: Number, Letter
OtherNumber :: GeneralCategoryrio RIO.Char No: Number, Other
-
rio RIO.Char Selects alphabetic or numeric Unicode characters. Note that numeric digits outside the ASCII range, as well as numeric characters which aren't digits, are selected by this function but not by isDigit. Such characters may be part of identifiers but are not used by the printer and reader to represent numbers, e.g., Roman numerals like V, full-width digits like '1' (aka '65297'). This function returns True if its argument has one of the following GeneralCategorys, or False otherwise: