-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Extra helpers to convert data-types to and from Text
--   
--   Extra helpers to convert data-types to and from Text
@package text-class
@version 2020.12.8


-- | Extend the <a>Text</a> module with an extra abstraction to encode and
--   decode values safely to and from <a>Text</a>. It's very similar to
--   <tt>FromJSON</tt> and <tt>ToJSON</tt> from <a>Aeson</a>.
module Data.Text.Class

-- | Defines a textual encoding for a type.
class ToText a

-- | Encode the specified value as text.
toText :: ToText a => a -> Text

-- | Defines a textual decoding for a type.
class FromText a

-- | Decode the specified text as a value.
fromText :: FromText a => Text -> Either TextDecodingError a

-- | Indicates an error that occurred while decoding from text.
newtype TextDecodingError
TextDecodingError :: String -> TextDecodingError
[getTextDecodingError] :: TextDecodingError -> String

-- | Decode the specified text with a <a>Maybe</a> result type.
fromTextMaybe :: FromText a => Text -> Maybe a

-- | Represents a case style for multi-word strings.
data CaseStyle

-- | A string in the style of "doNotRepeatYourself"
CamelCase :: CaseStyle

-- | A string in the style of <a>DoNotRepeatYourself</a>
PascalCase :: CaseStyle

-- | A string in the style of "do-not-repeat-yourself"
KebabLowerCase :: CaseStyle

-- | A string in the style of "do_not_repeat_yourself"
SnakeLowerCase :: CaseStyle

-- | A string in the style of <a>DO_NOT_REPEAT_YOURSELF</a>
SnakeUpperCase :: CaseStyle

-- | A string in the style of "do not repeat yourself"
SpacedLowerCase :: CaseStyle

-- | Converts the given value to text, according to the specified
--   <a>CaseStyle</a>.
--   
--   This function guarantees to satisfy the following property:
--   
--   <pre>
--   fromTextToBoundedEnum s (toTextFromBoundedEnum s a) == Right a
--   </pre>
toTextFromBoundedEnum :: forall a. (Bounded a, Enum a, Show a) => CaseStyle -> a -> Text

-- | Parses the given text to a value, according to the specified
--   <a>CaseStyle</a>.
--   
--   This function guarantees to satisfy the following property:
--   
--   <pre>
--   fromTextToBoundedEnum s (toTextFromBoundedEnum s a) == Right a
--   </pre>
fromTextToBoundedEnum :: forall a. (Bounded a, Enum a, Show a) => CaseStyle -> Text -> Either TextDecodingError a

-- | Show a data-type through its <a>ToText</a> instance
showT :: ToText a => a -> String

-- | Splits the given <a>Text</a> into a prefix and a suffix using the last
--   occurrence of the specified separator character as a splitting point.
--   Evaluates to <a>Nothing</a> if the specified <a>Text</a> does not
--   contain the separator character.
splitAtLastOccurrence :: Char -> Text -> Maybe (Text, Text)
instance Formatting.Buildable.Buildable Data.Text.Class.TextDecodingError
instance GHC.Show.Show Data.Text.Class.TextDecodingError
instance GHC.Classes.Eq Data.Text.Class.TextDecodingError
instance GHC.Show.Show Data.Text.Class.CaseStyle
instance GHC.Generics.Generic Data.Text.Class.CaseStyle
instance GHC.Classes.Eq Data.Text.Class.CaseStyle
instance GHC.Enum.Enum Data.Text.Class.CaseStyle
instance GHC.Enum.Bounded Data.Text.Class.CaseStyle
instance Data.Text.Class.FromText GHC.Base.String
instance Data.Text.Class.FromText Data.Text.Internal.Text
instance Data.Text.Class.FromText GHC.Types.Int
instance Data.Text.Class.FromText GHC.Natural.Natural
instance Data.Text.Class.FromText GHC.Word.Word32
instance Data.Text.Class.FromText GHC.Integer.Type.Integer
instance Data.Text.Class.FromText GHC.Types.Double
instance Data.Text.Class.FromText Data.Time.Clock.Internal.NominalDiffTime.NominalDiffTime
instance Data.Text.Class.ToText GHC.Base.String
instance Data.Text.Class.ToText Data.Text.Internal.Text
instance Data.Text.Class.ToText GHC.Types.Int
instance Data.Text.Class.ToText GHC.Natural.Natural
instance Data.Text.Class.ToText GHC.Integer.Type.Integer
instance Data.Text.Class.ToText GHC.Types.Double
instance Data.Text.Class.ToText GHC.Word.Word64
instance Data.Text.Class.ToText GHC.Word.Word32
instance Data.Text.Class.ToText Data.Word.Odd.Word31
instance Data.Text.Class.ToText Data.Time.Clock.Internal.NominalDiffTime.NominalDiffTime

module Test.Text.Roundtrip

-- | Constructs a test to check that roundtrip textual encoding and
--   decoding is possible for values of the given type.
textRoundtrip :: forall a. (Arbitrary a, Eq a, Show a, ToText a, FromText a, Typeable a) => Proxy a -> Spec
