-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Textual Type Classes
--
-- This library provides type classes for conversion between data types
-- and textual data types (strings). Please see the README on GitHub at
-- https://github.com/ExtremaIS/ttc-haskell#readme.
@package ttc
@version 0.2.3.0
-- | TTC, an initialism of Textual Type Classes, is a library that
-- provides type classes for conversion between data types and textual
-- data types (strings).
--
-- This library is meant to be imported qualified, as follows:
--
--
-- import qualified Data.TTC as TTC
--
module Data.TTC
-- | The Textual type class is used to convert between the following
-- textual data types:
--
--
--
-- ByteString values are assumed to be UTF-8 encoded text.
-- Invalid bytes are replaced with the Unicode replacement character
-- U+FFFD. In cases where different behavior is required,
-- process ByteString values before using this class.
--
-- The key feature of this type class is that it has a single type
-- variable, making it easy to write functions that accepts arguments
-- and/or returns values that may be any of the supported textual data
-- types.
--
-- Note that support for additional data types cannot be implemented by
-- writing instances. Adding support for additional data types would
-- require changing the class definition itself. This is the price paid
-- for having only one type variable instead of two.
class Textual t
-- | Convert between any supported textual data types
convert :: (Textual t, Textual t') => t' -> t
-- | Convert to a String
toS :: Textual t => t -> String
-- | Convert to strict Text
toT :: Textual t => t -> Text
-- | Convert to lazy Text
toTL :: Textual t => t -> Text
-- | Convert to a strict ByteString
toBS :: Textual t => t -> ByteString
-- | Convert to a lazy ByteString
toBSL :: Textual t => t -> ByteString
-- | Convert from a String
fromS :: Textual t => String -> t
-- | Convert from strict Text
fromT :: Textual t => Text -> t
-- | Convert from lazy Text
fromTL :: Textual t => Text -> t
-- | Convert from a strict ByteString
fromBS :: Textual t => ByteString -> t
-- | Convert from a lazy ByteString
fromBSL :: Textual t => ByteString -> t
-- | Convert an argument to a String
asS :: Textual t => (String -> a) -> t -> a
-- | Convert an argument to strict Text
asT :: Textual t => (Text -> a) -> t -> a
-- | Convert an argument to lazy Text
asTL :: Textual t => (Text -> a) -> t -> a
-- | Convert an argument to a strict ByteString
asBS :: Textual t => (ByteString -> a) -> t -> a
-- | Convert an argument to a lazy ByteString
asBSL :: Textual t => (ByteString -> a) -> t -> a
-- | Convert to a Text Builder
toTLB :: Textual t => t -> Builder
-- | Convert from a Text Builder
fromTLB :: Textual t => Builder -> t
-- | Convert to a ByteString Builder
toBSB :: Textual t => t -> Builder
-- | Convert from a ByteString Builder
fromBSB :: Textual t => Builder -> t
-- | Convert to a ShortByteString
toSBS :: Textual t => t -> ShortByteString
-- | Convert from a ShortByteString
fromSBS :: Textual t => ShortByteString -> t
-- | The Render type class renders a data type as a textual data
-- type.
--
-- There are no default instances for the Render type class, so
-- that all instances can be customized per project when desired.
-- Instances for some basic data types are available in
-- Data.TTC.Instances.
--
-- See the uname and prompt example programs in the
-- examples directory.
class Render a
render :: (Render a, Textual t) => a -> t
-- | Render to a String
renderS :: Render a => a -> String
-- | Render to strict Text
renderT :: Render a => a -> Text
-- | Render to lazy Text
renderTL :: Render a => a -> Text
-- | Render to a strict ByteString
renderBS :: Render a => a -> ByteString
-- | Render to a lazy ByteString
renderBSL :: Render a => a -> ByteString
-- | Render a value to a textual data type using the Show instance
renderWithShow :: (Show a, Textual t) => a -> t
-- | The Parse type class parses a data type from a textual data
-- type.
--
-- There are no default instances for the Parse type class, so
-- that all instances can be customized per project when desired.
-- Instances for some basic data types are available in
-- Data.TTC.Instances.
--
-- See the uname and prompt example programs in the
-- examples directory.
class Parse a
parse :: (Parse a, Textual t) => t -> Either String a
-- | Parse from a String
parseS :: Parse a => String -> Either String a
-- | Parse from strict Text
parseT :: Parse a => Text -> Either String a
-- | Parse from lazy Text
parseTL :: Parse a => Text -> Either String a
-- | Parse from a strict ByteString
parseBS :: Parse a => ByteString -> Either String a
-- | Parse from a lazy ByteString
parseBSL :: Parse a => ByteString -> Either String a
-- | Parse to a Maybe type
parseMaybe :: Parse a => Textual t => t -> Maybe a
-- | Parse from a String to a Maybe type
parseMaybeS :: Parse a => String -> Maybe a
-- | Parse from strict Text to a Maybe type
parseMaybeT :: Parse a => Text -> Maybe a
-- | Parse from lazy Text to a Maybe type
parseMaybeTL :: Parse a => Text -> Maybe a
-- | Parse from a strict ByteString to a Maybe type
parseMaybeBS :: Parse a => ByteString -> Maybe a
-- | Parse from a lazy ByteString to a Maybe type
parseMaybeBSL :: Parse a => ByteString -> Maybe a
-- | Unsafely parse
parseUnsafe :: (Parse a, Textual t) => t -> a
-- | Unsafely parse to a String
parseUnsafeS :: Parse a => String -> a
-- | Unsafely parse to strict Text
parseUnsafeT :: Parse a => Text -> a
-- | Unsafely parse to lazy Text
parseUnsafeTL :: Parse a => Text -> a
-- | Unsafely parse to a strict ByteString
parseUnsafeBS :: Parse a => ByteString -> a
-- | Unsafely parse to a lazy ByteString
parseUnsafeBSL :: Parse a => ByteString -> a
-- | Parse a value in an enumeration
--
-- See the enum example program in the examples
-- directory.
parseEnum :: (Bounded a, Enum a, Render a, Textual t) => Bool -> Bool -> e -> e -> t -> Either e a
-- | Parse a value in an enumeration, with String error messages
--
-- The following English error messages are returned:
--
--
-- - "invalid {name}" when there are no matches
-- - "ambiguous {name}" when there is more than one match
--
parseEnum' :: (Bounded a, Enum a, Render a, Textual t) => String -> Bool -> Bool -> t -> Either String a
-- | Parse a value using the Read instance
parseWithRead :: (Read a, Textual t) => e -> t -> Either e a
-- | Parse a value using the Read instance, with String error
-- messages
--
-- The following English error message is returned:
--
--
-- - "invalid {name}" when the parse fails
--
parseWithRead' :: (Read a, Textual t) => String -> t -> Either String a
-- | Implement ReadS using parseEnum
--
-- This implementation expects all of the input to be consumed.
readsEnum :: (Bounded a, Enum a, Render a) => Bool -> Bool -> ReadS a
-- | Implement ReadS using a Parse instance
--
-- This implementation expects all of the input to be consumed.
readsWithParse :: Parse a => ReadS a
-- | Validate a constant at compile-time using a Parse instance
--
-- This function parses the String at compile-time and fails
-- compilation on error. When valid, the result is compiled in, so the
-- result type must have a Lift instance. When this is
-- inconvenient, use one of the alternative functions in this library.
--
-- This function uses a typed expression. Typed expressions were not
-- supported in haskell-src-exts <1.22.0, which caused
-- problems with hlint. If the issue effects you, use hlint
-- -i "Parse error" to ignore parse errors or use one of the
-- alternative functions in this library.
--
-- See the valid, invalid, and lift example
-- programs in the examples directory.
valid :: (Parse a, Lift a) => String -> Q (TExp a)
-- | Validate a constant at compile-time using a Parse instance
--
-- This function requires a Proxy of the result type. Use
-- mkValid to avoid having to pass a Proxy during constant
-- definition.
--
-- This function parses the String at compile-time and fails
-- compilation on error. When valid, the String is compiled in, to
-- be parsed again at run-time. Since the result is not compiled in, no
-- Lift instance is required.
--
-- This function uses a typed expression. Typed expressions were not
-- supported in haskell-src-exts <1.22.0, which caused
-- problems with hlint. If the issue effects you, use hlint
-- -i "Parse error" to ignore parse errors or use
-- untypedValidOf instead.
--
-- See the validof example program in the examples
-- directory.
validOf :: Parse a => Proxy a -> String -> Q (TExp a)
-- | Make a valid function using validOf for the given type
--
-- Create a valid function in the module for a type in order to
-- avoid having to write a Proxy when defining constants.
--
-- This function uses a typed expression. Typed expressions were not
-- supported in haskell-src-exts <1.22.0, which caused
-- problems with hlint. If the issue effects you, use hlint
-- -i "Parse error" to ignore parse errors or use
-- mkUntypedValidOf instead.
--
-- See the mkvalid example program in the examples
-- directory.
mkValid :: String -> Name -> DecsQ
-- | Validate a constant at compile-time using a Parse instance
--
-- This function requires a Proxy of the result type. Use
-- mkUntypedValid to avoid having to pass a Proxy during
-- constant definition.
--
-- This function parses the String at compile-time and fails
-- compilation on error. When valid, the String is compiled in, to
-- be parsed again at run-time. Since the result is not compiled in, no
-- Lift instance is required.
--
-- See the uvalidof example program in the examples
-- directory.
untypedValidOf :: Parse a => Proxy a -> String -> ExpQ
-- | Make a valid function using untypedValidOf for the
-- given type
--
-- Create a valid function in the module for a type in order to
-- avoid having to write a Proxy when defining constants.
--
-- See the mkuvalid example program in the examples
-- directory.
mkUntypedValid :: String -> Name -> DecsQ
-- | Make a valid quasi-quoter using untypedValidOf for the
-- given type
--
-- See the uvalidqq example program in the examples
-- directory.
mkUntypedValidQQ :: String -> Name -> DecsQ
instance Data.TTC.Textual GHC.Base.String
instance Data.TTC.Textual Data.Text.Internal.Text
instance Data.TTC.Textual Data.Text.Internal.Lazy.Text
instance Data.TTC.Textual Data.ByteString.Internal.ByteString
instance Data.TTC.Textual Data.ByteString.Lazy.Internal.ByteString
-- | This module defines TTC Render and Parse instances for
-- some basic data types. The definitions for the numeric data types are
-- implemented using the Show and Read instances. The
-- definitions for the character and textual data types are implemented
-- without quoting.
--
-- To use these instances, explicitly import them as follows:
--
--
-- import Data.TTC.Instances ()
--
module Data.TTC.Instances
instance Data.TTC.Parse GHC.Types.Char
instance Data.TTC.Render GHC.Types.Char
instance Data.TTC.Parse GHC.Types.Double
instance Data.TTC.Render GHC.Types.Double
instance Data.TTC.Parse GHC.Types.Float
instance Data.TTC.Render GHC.Types.Float
instance Data.TTC.Parse GHC.Types.Int
instance Data.TTC.Render GHC.Types.Int
instance Data.TTC.Parse GHC.Int.Int8
instance Data.TTC.Render GHC.Int.Int8
instance Data.TTC.Parse GHC.Int.Int16
instance Data.TTC.Render GHC.Int.Int16
instance Data.TTC.Parse GHC.Int.Int32
instance Data.TTC.Render GHC.Int.Int32
instance Data.TTC.Parse GHC.Int.Int64
instance Data.TTC.Render GHC.Int.Int64
instance Data.TTC.Parse GHC.Integer.Type.Integer
instance Data.TTC.Render GHC.Integer.Type.Integer
instance Data.TTC.Parse GHC.Types.Word
instance Data.TTC.Render GHC.Types.Word
instance Data.TTC.Parse GHC.Word.Word8
instance Data.TTC.Render GHC.Word.Word8
instance Data.TTC.Parse GHC.Word.Word16
instance Data.TTC.Render GHC.Word.Word16
instance Data.TTC.Parse GHC.Word.Word32
instance Data.TTC.Render GHC.Word.Word32
instance Data.TTC.Parse GHC.Word.Word64
instance Data.TTC.Render GHC.Word.Word64
instance Data.TTC.Parse GHC.Base.String
instance Data.TTC.Render GHC.Base.String
instance Data.TTC.Parse Data.ByteString.Lazy.Internal.ByteString
instance Data.TTC.Render Data.ByteString.Lazy.Internal.ByteString
instance Data.TTC.Parse Data.ByteString.Internal.ByteString
instance Data.TTC.Render Data.ByteString.Internal.ByteString
instance Data.TTC.Parse Data.Text.Internal.Lazy.Text
instance Data.TTC.Render Data.Text.Internal.Lazy.Text
instance Data.TTC.Parse Data.Text.Internal.Text
instance Data.TTC.Render Data.Text.Internal.Text