-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A text rendering and parsing toolkit for enumerated types -- -- A text rendering and parsing toolkit for enumerated types. Please see -- the README on GitHub at -- https://github.com/cdornan/enum-text#readme @package enum-text @version 0.5.1.0 module Text.Enum.Text -- | 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 ---- -- With the DeriveAnyClass language extension you can list -- EnumText in the deriving clause, and with -- DerivingVia (available from GHC 8.6.1) you can derive -- via UsingEnumText as follows: -- --
-- {-# LANGUAGE DeriveAnyClass #-}
-- {-# LANGUAGE DerivingVia #-}
--
-- import Fmt
-- import Text.Enum.Text
--
-- data Foo = FOO_bar | FOO_bar_baz
-- deriving (Bounded,Enum,EnumText,Eq,Ord,Show)
-- deriving (Buildable,TextParsable) via UsingEnumText Foo
--
class (Buildable e, Bounded e, Enum e, Eq e, Ord e, Show e, TextParsable e) => EnumText e
-- | Configures the textual representation of e generated by
-- renderEnumText.
configEnumText :: EnumText e => e -> EnumTextConfig
-- | Generate the standard textual representation according to
-- configEnumText by default.
renderEnumText :: EnumText e => e -> Text
-- | Sames as renderEnumText, but generating a Builder.
buildEnumText :: EnumText e => e -> Builder
-- | Parses an e according to the renderEnumText render.
parseEnumText :: EnumText e => Text -> Possibly e
-- | A cassava field encoder, using 'the renderEnumText' format.
toFieldEnumText :: EnumText e => e -> ByteString
-- | A cassava field parser using the renderEnumText format.
fromFieldEnumText_ :: (EnumText e, Monad m) => ByteString -> m e
-- | For hashing e with the renderEnumText representation.
hashWithSaltEnumText :: EnumText e => Int -> e -> Int
newtype UsingEnumText a
UsingEnumText :: a -> UsingEnumText a
[_UsingEnumText] :: UsingEnumText a -> a
-- | a class for Text parsers.
class TextParsable a
parseText :: TextParsable a => Text -> Possibly a
-- | Configures the default implementation of renderEnumText
data EnumTextConfig
EnumTextConfig :: (Text -> Text) -> (Char -> Char) -> EnumTextConfig
-- | applied to the output of show once converted to Text; by
-- default strips each data constructor up to and including the first '_'
[_etc_text_prep] :: EnumTextConfig -> Text -> Text
-- | applied to each character of the outpout of _etc_text_prep (by
-- default flips underscores (_) to dashes (-)
[_etc_char_prep] :: EnumTextConfig -> Char -> Char
-- | The default configEnumText for EnumText:
--
--