Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- class (Buildable e, Bounded e, Enum e, Eq e, Ord e, Show e, TextParsable e) => EnumText e where
- configEnumText :: e -> EnumTextConfig
- renderEnumText :: e -> Text
- buildEnumText :: e -> Builder
- parseEnumText :: Text -> Possibly e
- toFieldEnumText :: e -> ByteString
- fromFieldEnumText_ :: Monad m => ByteString -> m e
- hashWithSaltEnumText :: Int -> e -> Int
- class TextParsable a where
- data EnumTextConfig = EnumTextConfig {
- _etc_text_prep :: Text -> Text
- _etc_char_prep :: Char -> Char
- defaultEnumTextConfig :: EnumTextConfig
Documentation
class (Buildable e, Bounded e, Enum e, Eq e, Ord e, Show e, TextParsable e) => EnumText e where Source #
Our toolkit for enumerated types which should be defined as follows:
import Fmt import Text.Enum.Text data Foo = FOO_bar | FOO_bar_baz deriving (Bounded,Enum,Eq,Ord,Show) instance EnumText Foo instance Buildable Foo where build = buildEnumText instance TextParsable Foo where parseText = parseEnumText
Nothing
configEnumText :: e -> EnumTextConfig Source #
Configures the textual representation of e
generated by renderEnumText.
renderEnumText :: e -> Text Source #
Generate the standard textual representation according to
configEnumText
by default.
buildEnumText :: e -> Builder Source #
Sames as renderEnumText
, but generating a Builder
.
parseEnumText :: Text -> Possibly e Source #
Parses an e
according to the renderEnumText
render.
toFieldEnumText :: e -> ByteString Source #
A cassava field encoder, using 'the renderEnumText' format.
fromFieldEnumText_ :: Monad m => ByteString -> m e Source #
A cassava field parser using the renderEnumText
format.
hashWithSaltEnumText :: Int -> e -> Int Source #
For hashing e
with the renderEnumText
representation.
class TextParsable a where Source #
a class for Text
parsers.
Instances
TextParsable Int Source # | |
TextParsable Text Source # | |
TextParsable UTCTime Source # | |
TextParsable Day Source # | |
a ~ Char => TextParsable [a] Source # | |
TextParsable a => TextParsable (Maybe a) Source # | |
data EnumTextConfig Source #
Configures the default implementation of renderEnumText
EnumTextConfig | |
|
defaultEnumTextConfig :: EnumTextConfig Source #
The default configEnumText
for EnumText
:
_etc_text_prep
removes the prefix up to and including the first underscore ('_')_etc_char_prep
flips the underscores (_
) to dashes (-
)