| Copyright | © 2018-2020 IOHK |
|---|---|
| License | Apache-2.0 |
| Safe Haskell | None |
| Language | Haskell2010 |
Data.Text.Class
Description
Synopsis
- class ToText a where
- class FromText a where
- fromText :: Text -> Either TextDecodingError a
- newtype TextDecodingError = TextDecodingError {}
- fromTextMaybe :: FromText a => Text -> Maybe a
- data CaseStyle
- toTextFromBoundedEnum :: forall a. (Bounded a, Enum a, Show a) => CaseStyle -> a -> Text
- fromTextToBoundedEnum :: forall a. (Bounded a, Enum a, Show a) => CaseStyle -> Text -> Either TextDecodingError a
- showT :: ToText a => a -> String
- splitAtLastOccurrence :: Char -> Text -> Maybe (Text, Text)
Producing and consuming text from arbitrary types
Defines a textual encoding for a type.
Instances
| ToText Double Source # | |
| ToText Int Source # | |
| ToText Integer Source # | |
| ToText Natural Source # | |
| ToText Word32 Source # | |
| ToText Word64 Source # | |
| ToText String Source # | |
| ToText Word31 Source # | |
| ToText NominalDiffTime Source # | |
Defined in Data.Text.Class Methods toText :: NominalDiffTime -> Text Source # | |
| ToText Text Source # | |
class FromText a where Source #
Defines a textual decoding for a type.
Instances
| FromText Double Source # | |
Defined in Data.Text.Class | |
| FromText Int Source # | |
Defined in Data.Text.Class | |
| FromText Integer Source # | |
Defined in Data.Text.Class | |
| FromText Natural Source # | |
Defined in Data.Text.Class | |
| FromText Word32 Source # | |
Defined in Data.Text.Class | |
| FromText String Source # | |
Defined in Data.Text.Class | |
| FromText NominalDiffTime Source # | |
Defined in Data.Text.Class Methods fromText :: Text -> Either TextDecodingError NominalDiffTime Source # | |
| FromText Text Source # | |
Defined in Data.Text.Class | |
newtype TextDecodingError Source #
Indicates an error that occurred while decoding from text.
Constructors
| TextDecodingError | |
Fields | |
Instances
| Eq TextDecodingError Source # | |
Defined in Data.Text.Class Methods (==) :: TextDecodingError -> TextDecodingError -> Bool # (/=) :: TextDecodingError -> TextDecodingError -> Bool # | |
| Show TextDecodingError Source # | |
Defined in Data.Text.Class Methods showsPrec :: Int -> TextDecodingError -> ShowS # show :: TextDecodingError -> String # showList :: [TextDecodingError] -> ShowS # | |
| Buildable TextDecodingError Source # | |
Defined in Data.Text.Class Methods build :: TextDecodingError -> Builder Source # | |
fromTextMaybe :: FromText a => Text -> Maybe a Source #
Decode the specified text with a Maybe result type.
Producing and consuming text from bounded enumeration types
Represents a case style for multi-word strings.
Constructors
| CamelCase | A string in the style of "doNotRepeatYourself" |
| PascalCase | A string in the style of DoNotRepeatYourself |
| KebabLowerCase | A string in the style of "do-not-repeat-yourself" |
| SnakeLowerCase | A string in the style of "do_not_repeat_yourself" |
| SnakeUpperCase | A string in the style of DO_NOT_REPEAT_YOURSELF |
| SpacedLowerCase | A string in the style of "do not repeat yourself" |
Instances
toTextFromBoundedEnum :: forall a. (Bounded a, Enum a, Show a) => CaseStyle -> a -> Text Source #
Converts the given value to text, according to the specified CaseStyle.
This function guarantees to satisfy the following property:
fromTextToBoundedEnum s (toTextFromBoundedEnum s a) == Right a
fromTextToBoundedEnum :: forall a. (Bounded a, Enum a, Show a) => CaseStyle -> Text -> Either TextDecodingError a Source #
Parses the given text to a value, according to the specified CaseStyle.
This function guarantees to satisfy the following property:
fromTextToBoundedEnum s (toTextFromBoundedEnum s a) == Right a