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


-- | Isomorphism typeclass solving the conversion problem
--   
--   Isomorphism typeclass solving the conversion problem
@package isomorphism-class
@version 0.1.0.10


-- | Isomorphism as a lawful solution to the conversion problem.
--   
--   <h1>Conversion problem</h1>
--   
--   Have you ever looked for a <tt>toString</tt> function? How often do
--   you import <tt>Data.Text.Lazy</tt> only to call its <a>fromStrict</a>?
--   How about importing <tt>Data.Text</tt> only to call its <a>unpack</a>?
--   How about going thru the always fun sequence of importing
--   <tt>Data.ByteString.Builder</tt> only to call its
--   <a>toLazyByteString</a> and then importing
--   <tt>Data.ByteString.Lazy</tt> only to call its <a>toStrict</a>?
--   
--   Those all are instances of one pattern. They are conversions between
--   representations of the same information. Codebases that don't attempt
--   to abstract over this pattern tend to be sprawling with this type of
--   boilerplate. It's noise to the codereader, it's a burden to the
--   implementor and the maintainer.
--   
--   <h1>Why another conversion library?</h1>
--   
--   Many libraries exist that approach the conversion problem. However all
--   of them provide lawless typeclasses leaving it up to the author of the
--   instance to define what makes a proper conversion. This results in
--   inconsistencies across instances and their behaviour being not evident
--   to the user.
--   
--   This library tackles this problem with a lawful typeclass, making it
--   evident what any of its instances do.
--   
--   <h1>The law</h1>
--   
--   The key insight of this library is that if you add a requirement for
--   the conversion to be lossless and to have a mirror conversion in the
--   opposite direction, there usually appears to be only one way of
--   defining it. That makes it very clear what the conversion does to the
--   user and how to define it to the author of the conversion.
--   
--   That insight itself stems from an observation that almost all of the
--   practical conversions in Haskell share a property: you can restore the
--   original data from its converted form. E.g., you can get a bytestring
--   from a builder and you can create a builder from a bytestring, you can
--   convert a text into a list of chars and vice-versa, bytestring to/from
--   bytearray, strict bytestring to/from lazy, list to/from sequence,
--   sequence to/from vector, set of ints to/from int-set. In other words,
--   it's always a two-way street with them and there's a lot of instances
--   of this pattern.
--   
--   <h1>UX</h1>
--   
--   A few other accidental findings like encoding this property with
--   recursive typeclass constraints and fine-tuning for the use of the
--   <tt>TypeApplications</tt> extension resulted in a very terse yet clear
--   API.
--   
--   Essentially the whole API is just two functions: <a>to</a> and
--   <a>from</a>. Both perform a conversion between two types. The only
--   difference between them is in what the first type application
--   parameter specifies. E.g.:
--   
--   <pre>
--   fromString = from @String
--   </pre>
--   
--   <pre>
--   toText = to @Text
--   </pre>
--   
--   In other words <a>to</a> and <a>from</a> let you explicitly specify
--   either the source or the target type of a conversion when you need to
--   help the type inferencer.
--   
--   Here are more practical examples:
--   
--   <pre>
--   renderNameAndHeight :: <a>Text</a> -&gt; <a>Int</a> -&gt; <a>Text</a>
--   renderNameAndHeight name height =
--     <a>from</a> @<a>Builder</a> $
--       "Height of " &lt;&gt; <a>to</a> name &lt;&gt; " is " &lt;&gt; <a>showAs</a> height
--   </pre>
--   
--   <pre>
--   combineEncodings :: <a>ShortByteString</a> -&gt; <a>ByteArray</a> -&gt; <a>ByteString</a> -&gt; [Word8]
--   combineEncodings a b c =
--     <a>from</a> @<a>Builder</a> $
--       <a>to</a> a &lt;&gt; <a>to</a> b &lt;&gt; <a>to</a> c
--   </pre>
module IsomorphismClass

-- | Bidirectional conversion between two types with no loss of
--   information. The bidirectionality is encoded via a recursive
--   dependency with arguments flipped.
--   
--   You can read the signature <tt>IsomorphicTo a b</tt> as "<i>B</i> is
--   isomorphic to <i>A</i>".
--   
--   <b>Laws</b>
--   
--   <i>B</i> is isomorphic to <i>A</i> if and only if there exists a
--   conversion from <i>B</i> to <i>A</i> (<a>to</a>) and a conversion from
--   <i>A</i> to <i>B</i> (<a>from</a>) such that:
--   
--   <ul>
--   <li><tt><a>from</a> . <a>to</a> = <a>id</a></tt> - For all values of
--   <i>B</i> converting from <i>B</i> to <i>A</i> and then converting from
--   <i>A</i> to <i>B</i> produces a value that is identical to the
--   original.</li>
--   <li><tt><a>to</a> . <a>from</a> = <a>id</a></tt> - For all values of
--   <i>A</i> converting from <i>A</i> to <i>B</i> and then converting from
--   <i>B</i> to <i>A</i> produces a value that is identical to the
--   original.</li>
--   </ul>
--   
--   <b>Usage</b>
--   
--   This class is particularly easy to use in combination with the
--   <tt>TypeApplications</tt> extension making it clear to the reader what
--   sort of conversion he sees. E.g.,
--   
--   <pre>
--   fromString = from @String
--   </pre>
--   
--   <pre>
--   toText = to @Text
--   </pre>
--   
--   The types are also self-evident:
--   
--   <pre>
--   &gt; :t from @String
--   from @String :: IsomorphicTo b String =&gt; String -&gt; b
--   </pre>
--   
--   <pre>
--   &gt; :t to @Text
--   to @Text :: IsomorphicTo Text b =&gt; b -&gt; Text
--   </pre>
--   
--   <b>Instance Definition</b>
--   
--   For each pair of isomorphic types (<i>A</i> and <i>B</i>) the compiler
--   will require you to define two instances, namely: <tt>IsomorphicTo A
--   B</tt> and <tt>IsomorphicTo B A</tt>.
class (IsomorphicTo b a) => IsomorphicTo a b
to :: IsomorphicTo a b => b -> a

-- | <a>to</a> in reverse direction.
--   
--   Particularly useful in combination with the <tt>TypeApplications</tt>
--   extension, where it allows to specify the input type, e.g.:
--   
--   <pre>
--   fromString :: IsomorphicTo a String =&gt; String -&gt; a
--   fromString = from @String
--   </pre>
--   
--   The first type application of the <a>to</a> function on the other hand
--   specifies the output data type.
from :: forall a b. IsomorphicTo b a => a -> b

-- | A utility, which uses the <a>Show</a> instance to produce a value that
--   is isomorphic to <a>String</a>.
--   
--   It lets you generalize over the functions like the following:
--   
--   <pre>
--   showAsText :: Show a =&gt; a -&gt; Text
--   showAsText = showAs @Text
--   </pre>
--   
--   <pre>
--   showAsBuilder :: Show a =&gt; a -&gt; Builder
--   showAsBuilder = showAs @Builder
--   </pre>
showAs :: forall b a. (IsomorphicTo String b, Show a) => a -> b
instance IsomorphismClass.IsomorphicTo GHC.Base.String Data.Text.Internal.Text
instance IsomorphismClass.IsomorphicTo GHC.Base.String Data.Text.Internal.Lazy.Text
instance IsomorphismClass.IsomorphicTo GHC.Base.String Data.Text.Internal.Builder.Builder
instance IsomorphismClass.IsomorphicTo [GHC.Word.Word8] Data.ByteString.Internal.Type.ByteString
instance IsomorphismClass.IsomorphicTo [GHC.Word.Word8] Data.ByteString.Lazy.Internal.ByteString
instance IsomorphismClass.IsomorphicTo [GHC.Word.Word8] Data.ByteString.Short.Internal.ShortByteString
instance IsomorphismClass.IsomorphicTo [GHC.Word.Word8] Data.ByteString.Builder.Internal.Builder
instance IsomorphismClass.IsomorphicTo [GHC.Word.Word8] Data.Array.Byte.ByteArray
instance IsomorphismClass.IsomorphicTo [GHC.Word.Word8] Data.Text.Array.Array
instance IsomorphismClass.IsomorphicTo [a] [a]
instance IsomorphismClass.IsomorphicTo [a] (Data.Vector.Vector a)
instance IsomorphismClass.IsomorphicTo [a] (Data.Sequence.Internal.Seq a)
instance IsomorphismClass.IsomorphicTo Data.Text.Internal.Text Data.Text.Internal.Text
instance IsomorphismClass.IsomorphicTo Data.Text.Internal.Text GHC.Base.String
instance IsomorphismClass.IsomorphicTo Data.Text.Internal.Text Data.Text.Internal.Lazy.Text
instance IsomorphismClass.IsomorphicTo Data.Text.Internal.Text Data.Text.Internal.Builder.Builder
instance IsomorphismClass.IsomorphicTo Data.Text.Internal.Lazy.Text Data.Text.Internal.Lazy.Text
instance IsomorphismClass.IsomorphicTo Data.Text.Internal.Lazy.Text GHC.Base.String
instance IsomorphismClass.IsomorphicTo Data.Text.Internal.Lazy.Text Data.Text.Internal.Text
instance IsomorphismClass.IsomorphicTo Data.Text.Internal.Lazy.Text Data.Text.Internal.Builder.Builder
instance IsomorphismClass.IsomorphicTo Data.Text.Internal.Builder.Builder Data.Text.Internal.Builder.Builder
instance IsomorphismClass.IsomorphicTo Data.Text.Internal.Builder.Builder GHC.Base.String
instance IsomorphismClass.IsomorphicTo Data.Text.Internal.Builder.Builder Data.Text.Internal.Text
instance IsomorphismClass.IsomorphicTo Data.Text.Internal.Builder.Builder Data.Text.Internal.Lazy.Text
instance IsomorphismClass.IsomorphicTo Data.ByteString.Internal.Type.ByteString Data.ByteString.Internal.Type.ByteString
instance IsomorphismClass.IsomorphicTo Data.ByteString.Internal.Type.ByteString [GHC.Word.Word8]
instance IsomorphismClass.IsomorphicTo Data.ByteString.Internal.Type.ByteString Data.ByteString.Lazy.Internal.ByteString
instance IsomorphismClass.IsomorphicTo Data.ByteString.Internal.Type.ByteString Data.ByteString.Short.Internal.ShortByteString
instance IsomorphismClass.IsomorphicTo Data.ByteString.Internal.Type.ByteString Data.ByteString.Builder.Internal.Builder
instance IsomorphismClass.IsomorphicTo Data.ByteString.Internal.Type.ByteString Data.Array.Byte.ByteArray
instance IsomorphismClass.IsomorphicTo Data.ByteString.Internal.Type.ByteString Data.Text.Array.Array
instance IsomorphismClass.IsomorphicTo Data.ByteString.Lazy.Internal.ByteString Data.ByteString.Lazy.Internal.ByteString
instance IsomorphismClass.IsomorphicTo Data.ByteString.Lazy.Internal.ByteString [GHC.Word.Word8]
instance IsomorphismClass.IsomorphicTo Data.ByteString.Lazy.Internal.ByteString Data.ByteString.Internal.Type.ByteString
instance IsomorphismClass.IsomorphicTo Data.ByteString.Lazy.Internal.ByteString Data.ByteString.Short.Internal.ShortByteString
instance IsomorphismClass.IsomorphicTo Data.ByteString.Lazy.Internal.ByteString Data.ByteString.Builder.Internal.Builder
instance IsomorphismClass.IsomorphicTo Data.ByteString.Lazy.Internal.ByteString Data.Array.Byte.ByteArray
instance IsomorphismClass.IsomorphicTo Data.ByteString.Lazy.Internal.ByteString Data.Text.Array.Array
instance IsomorphismClass.IsomorphicTo Data.ByteString.Short.Internal.ShortByteString Data.ByteString.Short.Internal.ShortByteString
instance IsomorphismClass.IsomorphicTo Data.ByteString.Short.Internal.ShortByteString [GHC.Word.Word8]
instance IsomorphismClass.IsomorphicTo Data.ByteString.Short.Internal.ShortByteString Data.ByteString.Internal.Type.ByteString
instance IsomorphismClass.IsomorphicTo Data.ByteString.Short.Internal.ShortByteString Data.ByteString.Lazy.Internal.ByteString
instance IsomorphismClass.IsomorphicTo Data.ByteString.Short.Internal.ShortByteString Data.ByteString.Builder.Internal.Builder
instance IsomorphismClass.IsomorphicTo Data.ByteString.Short.Internal.ShortByteString Data.Array.Byte.ByteArray
instance IsomorphismClass.IsomorphicTo Data.ByteString.Short.Internal.ShortByteString Data.Text.Array.Array
instance IsomorphismClass.IsomorphicTo Data.ByteString.Builder.Internal.Builder Data.ByteString.Builder.Internal.Builder
instance IsomorphismClass.IsomorphicTo Data.ByteString.Builder.Internal.Builder [GHC.Word.Word8]
instance IsomorphismClass.IsomorphicTo Data.ByteString.Builder.Internal.Builder Data.ByteString.Internal.Type.ByteString
instance IsomorphismClass.IsomorphicTo Data.ByteString.Builder.Internal.Builder Data.ByteString.Lazy.Internal.ByteString
instance IsomorphismClass.IsomorphicTo Data.ByteString.Builder.Internal.Builder Data.ByteString.Short.Internal.ShortByteString
instance IsomorphismClass.IsomorphicTo Data.ByteString.Builder.Internal.Builder Data.Array.Byte.ByteArray
instance IsomorphismClass.IsomorphicTo Data.ByteString.Builder.Internal.Builder Data.Text.Array.Array
instance IsomorphismClass.IsomorphicTo Data.Array.Byte.ByteArray Data.Array.Byte.ByteArray
instance IsomorphismClass.IsomorphicTo Data.Array.Byte.ByteArray [GHC.Word.Word8]
instance IsomorphismClass.IsomorphicTo Data.Array.Byte.ByteArray Data.ByteString.Short.Internal.ShortByteString
instance IsomorphismClass.IsomorphicTo Data.Array.Byte.ByteArray Data.ByteString.Internal.Type.ByteString
instance IsomorphismClass.IsomorphicTo Data.Array.Byte.ByteArray Data.ByteString.Lazy.Internal.ByteString
instance IsomorphismClass.IsomorphicTo Data.Array.Byte.ByteArray Data.ByteString.Builder.Internal.Builder
instance IsomorphismClass.IsomorphicTo Data.Array.Byte.ByteArray Data.Text.Array.Array
instance IsomorphismClass.IsomorphicTo Data.Text.Array.Array [GHC.Word.Word8]
instance IsomorphismClass.IsomorphicTo Data.Text.Array.Array Data.Array.Byte.ByteArray
instance IsomorphismClass.IsomorphicTo Data.Text.Array.Array Data.ByteString.Short.Internal.ShortByteString
instance IsomorphismClass.IsomorphicTo Data.Text.Array.Array Data.ByteString.Internal.Type.ByteString
instance IsomorphismClass.IsomorphicTo Data.Text.Array.Array Data.ByteString.Lazy.Internal.ByteString
instance IsomorphismClass.IsomorphicTo Data.Text.Array.Array Data.ByteString.Builder.Internal.Builder
instance IsomorphismClass.IsomorphicTo (Data.Vector.Vector a) (Data.Vector.Vector a)
instance IsomorphismClass.IsomorphicTo (Data.Vector.Vector a) [a]
instance IsomorphismClass.IsomorphicTo (Data.Vector.Vector a) (Data.Sequence.Internal.Seq a)
instance IsomorphismClass.IsomorphicTo (Data.Sequence.Internal.Seq a) (Data.Sequence.Internal.Seq a)
instance IsomorphismClass.IsomorphicTo (Data.Sequence.Internal.Seq a) [a]
instance IsomorphismClass.IsomorphicTo (Data.Sequence.Internal.Seq a) (Data.Vector.Vector a)
instance IsomorphismClass.IsomorphicTo (Data.Set.Internal.Set a) (Data.Set.Internal.Set a)
instance IsomorphismClass.IsomorphicTo (Data.Set.Internal.Set GHC.Types.Int) Data.IntSet.Internal.IntSet
instance IsomorphismClass.IsomorphicTo Data.IntSet.Internal.IntSet Data.IntSet.Internal.IntSet
instance IsomorphismClass.IsomorphicTo Data.IntSet.Internal.IntSet (Data.Set.Internal.Set GHC.Types.Int)
instance IsomorphismClass.IsomorphicTo (Data.Map.Internal.Map k v) (Data.Map.Internal.Map k v)
instance IsomorphismClass.IsomorphicTo (Data.Map.Internal.Map GHC.Types.Int v) (Data.IntMap.Internal.IntMap v)
instance IsomorphismClass.IsomorphicTo (Data.IntMap.Internal.IntMap a) (Data.IntMap.Internal.IntMap a)
instance IsomorphismClass.IsomorphicTo (Data.IntMap.Internal.IntMap v) (Data.Map.Internal.Map GHC.Types.Int v)
instance IsomorphismClass.IsomorphicTo (GHC.Maybe.Maybe a) (GHC.Maybe.Maybe a)
instance IsomorphismClass.IsomorphicTo (Data.Either.Either a b) (Data.Either.Either a b)
instance IsomorphismClass.IsomorphicTo (Data.Semigroup.First a) (Data.Semigroup.First a)
instance IsomorphismClass.IsomorphicTo (Data.Semigroup.Last a) (Data.Semigroup.Last a)
instance IsomorphismClass.IsomorphicTo (Data.Semigroup.Internal.Product a) (Data.Semigroup.Internal.Product a)
instance IsomorphismClass.IsomorphicTo (Data.Semigroup.Internal.Sum a) (Data.Semigroup.Internal.Sum a)
instance IsomorphismClass.IsomorphicTo GHC.Types.Bool GHC.Types.Bool
instance IsomorphismClass.IsomorphicTo GHC.Types.Char GHC.Types.Char
instance IsomorphismClass.IsomorphicTo GHC.Types.Double GHC.Types.Double
instance IsomorphismClass.IsomorphicTo GHC.Types.Float GHC.Types.Float
instance IsomorphismClass.IsomorphicTo GHC.Types.Int GHC.Types.Int
instance IsomorphismClass.IsomorphicTo GHC.Types.Int GHC.Types.Word
instance IsomorphismClass.IsomorphicTo GHC.Int.Int16 GHC.Int.Int16
instance IsomorphismClass.IsomorphicTo GHC.Int.Int16 GHC.Word.Word16
instance IsomorphismClass.IsomorphicTo GHC.Int.Int32 GHC.Int.Int32
instance IsomorphismClass.IsomorphicTo GHC.Int.Int32 GHC.Word.Word32
instance IsomorphismClass.IsomorphicTo GHC.Int.Int64 GHC.Int.Int64
instance IsomorphismClass.IsomorphicTo GHC.Int.Int64 GHC.Word.Word64
instance IsomorphismClass.IsomorphicTo GHC.Int.Int8 GHC.Int.Int8
instance IsomorphismClass.IsomorphicTo GHC.Int.Int8 GHC.Word.Word8
instance IsomorphismClass.IsomorphicTo GHC.Num.Integer.Integer GHC.Num.Integer.Integer
instance IsomorphismClass.IsomorphicTo GHC.Real.Rational GHC.Real.Rational
instance IsomorphismClass.IsomorphicTo GHC.Types.Word GHC.Types.Int
instance IsomorphismClass.IsomorphicTo GHC.Types.Word GHC.Types.Word
instance IsomorphismClass.IsomorphicTo GHC.Word.Word16 GHC.Int.Int16
instance IsomorphismClass.IsomorphicTo GHC.Word.Word16 GHC.Word.Word16
instance IsomorphismClass.IsomorphicTo GHC.Word.Word32 GHC.Int.Int32
instance IsomorphismClass.IsomorphicTo GHC.Word.Word32 GHC.Word.Word32
instance IsomorphismClass.IsomorphicTo GHC.Word.Word64 GHC.Int.Int64
instance IsomorphismClass.IsomorphicTo GHC.Word.Word64 GHC.Word.Word64
instance IsomorphismClass.IsomorphicTo GHC.Word.Word8 GHC.Int.Int8
instance IsomorphismClass.IsomorphicTo GHC.Word.Word8 GHC.Word.Word8
