isomorphism-class-0.3.1.2/0000755000000000000000000000000007346545000013520 5ustar0000000000000000isomorphism-class-0.3.1.2/CHANGELOG.md0000644000000000000000000000107607346545000015335 0ustar0000000000000000 # 0.3 - Extracted the `Is` and `IsSome` typeclasses into a separate library ["lawful-conversions"](https://github.com/nikita-volkov/lawful-conversions) - Restored the `IsomorphicTo` typeclass from the `0.1` design without restoring the `String` instance and the `showAs` utility # 0.2 - `IsomorphicTo` renamed to `Is` - `IsSome` is introduced as a parent class to it - `to` moved to `IsSome` - `showAs` dropped - `String` isomorphism instances for textual types dropped, since they were not exactly isomorphisms - `IsSome` instances added for `String` for textual types isomorphism-class-0.3.1.2/LICENSE0000644000000000000000000000204107346545000014522 0ustar0000000000000000Copyright (c) 2022 Nikita Volkov Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. isomorphism-class-0.3.1.2/isomorphism-class.cabal0000644000000000000000000001632407346545000020166 0ustar0000000000000000cabal-version: 3.0 name: isomorphism-class version: 0.3.1.2 synopsis: Isomorphism typeclass as a lawful solution to the conversion problem description: = Conversion problem How often do you import @Data.Text.Lazy@ only to call @fromStrict@ or @toStrict@? How about importing @Data.ByteString.Builder@ only to call its @toLazyByteString@ and then importing @Data.ByteString.Lazy@ only to call its @toStrict@? How often do you convert from @DiffTime@ to @NominalDiffTime@ or back? These are all instances of one pattern. They are conversions between different 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 code reader, it's a burden to implementors and maintainers. = Why another conversion library? Many libraries exist that approach the conversion problem. However, most 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, their behavior not being evident to the user and no way to check whether an instance is correct. This library tackles this problem with a lawful typeclass, making it evident what any of its instances do, and it provides a property-test for you to validate your instances. = The insight 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 for the author of the conversion. It also gives clear criteria for validating whether the instances are correct, which can be encoded in property-tests. 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 text from a text-builder and you can create a text-builder from a text, you can convert a bytestring into a list of bytes 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 are many instances of this pattern. A few other accidental findings like encoding this property with recursive typeclass constraints and fine-tuning for the use of the @TypeApplications@ extension resulted in a terse and clear API. = Other work and acknowledgements - [lawful-conversions](https://hackage.haskell.org/package/lawful-conversions) - sibling of this library expanding upon the same insights to also cover the patterns of smart construction and canonicalization. It's more involved and has different tradeoffs. Both libraries are maintained, letting their designs compete. Some ideas and concepts are also shared with the following libraries: - [control-iso](https://hackage.haskell.org/package/control-iso) - [type-iso](https://hackage.haskell.org/package/type-iso) - [injections](https://hackage.haskell.org/package/injections) category: Conversion homepage: https://github.com/nikita-volkov/isomorphism-class bug-reports: https://github.com/nikita-volkov/isomorphism-class/issues author: Nikita Volkov maintainer: Nikita Volkov copyright: (c) 2022 Nikita Volkov license: MIT license-file: LICENSE extra-doc-files: CHANGELOG.md source-repository head type: git location: https://github.com/nikita-volkov/isomorphism-class common language-settings default-language: Haskell2010 default-extensions: BlockArguments DefaultSignatures FlexibleContexts FlexibleInstances MagicHash MultiParamTypeClasses NoImplicitPrelude ScopedTypeVariables TypeApplications UndecidableSuperClasses library import: language-settings hs-source-dirs: library exposed-modules: IsomorphismClass other-modules: IsomorphismClass.Classes IsomorphismClass.Classes.IsomorphicTo IsomorphismClass.Optics IsomorphismClass.Prelude IsomorphismClass.Properties IsomorphismClass.Relations IsomorphismClass.Relations.BoxedVectorAndList IsomorphismClass.Relations.BoxedVectorAndSeq IsomorphismClass.Relations.ByteArrayAndByteString IsomorphismClass.Relations.ByteArrayAndLazyByteString IsomorphismClass.Relations.ByteArrayAndLazyByteStringBuilder IsomorphismClass.Relations.ByteArrayAndShortByteString IsomorphismClass.Relations.ByteArrayAndTextArray IsomorphismClass.Relations.ByteArrayAndWord8List IsomorphismClass.Relations.ByteStringAndLazyByteString IsomorphismClass.Relations.ByteStringAndLazyByteStringBuilder IsomorphismClass.Relations.ByteStringAndShortByteString IsomorphismClass.Relations.ByteStringAndTextArray IsomorphismClass.Relations.ByteStringAndWord8List IsomorphismClass.Relations.DiffTimeAndNominalDiffTime IsomorphismClass.Relations.DiffTimeAndPico IsomorphismClass.Relations.Int16AndWord16 IsomorphismClass.Relations.Int32AndWord32 IsomorphismClass.Relations.Int64AndWord64 IsomorphismClass.Relations.Int8AndWord8 IsomorphismClass.Relations.IntAndWord IsomorphismClass.Relations.IntMapAndMapOfInt IsomorphismClass.Relations.IntSetAndSetOfInt IsomorphismClass.Relations.LazyByteStringAndLazyByteStringBuilder IsomorphismClass.Relations.LazyByteStringAndShortByteString IsomorphismClass.Relations.LazyByteStringAndTextArray IsomorphismClass.Relations.LazyByteStringAndWord8List IsomorphismClass.Relations.LazyByteStringBuilderAndShortByteString IsomorphismClass.Relations.LazyByteStringBuilderAndTextArray IsomorphismClass.Relations.LazyByteStringBuilderAndWord8List IsomorphismClass.Relations.LazyTextAndLazyTextBuilder IsomorphismClass.Relations.LazyTextAndStrictTextBuilder IsomorphismClass.Relations.LazyTextAndText IsomorphismClass.Relations.LazyTextBuilderAndStrictTextBuilder IsomorphismClass.Relations.LazyTextBuilderAndText IsomorphismClass.Relations.ListAndSeq IsomorphismClass.Relations.NominalDiffTimeAndPico IsomorphismClass.Relations.ShortByteStringAndTextArray IsomorphismClass.Relations.ShortByteStringAndWord8List IsomorphismClass.Relations.StrictTextBuilderAndText IsomorphismClass.Relations.TextArrayAndWord8List IsomorphismClass.TextCompat.Array build-depends: QuickCheck >=2.13 && <3, base >=4.12 && <5, bytestring >=0.10 && <0.13, containers >=0.6 && <0.8, hashable >=1 && <2, primitive >=0.7 && <0.10, profunctors >=5 && <6, text >=1.2 && <2.2, time >=1.9 && <2, unordered-containers >=0.2 && <0.3, vector >=0.12 && <0.14, test-suite test import: language-settings type: exitcode-stdio-1.0 hs-source-dirs: test main-is: Main.hs other-modules: Test.ExtraInstances build-depends: QuickCheck >=2.13 && <3, bytestring >=0.11.1.0 && <0.13, isomorphism-class, primitive >=0.7 && <0.10, quickcheck-instances >=0.3.32 && <0.4, rebase >=1.15 && <2, tasty >=1.2.3 && <2, tasty-quickcheck >=0.10.1 && <0.12, text >=1.2 && <3, isomorphism-class-0.3.1.2/library/0000755000000000000000000000000007346545000015164 5ustar0000000000000000isomorphism-class-0.3.1.2/library/IsomorphismClass.hs0000644000000000000000000000370207346545000021021 0ustar0000000000000000-- | -- = UX -- -- Essentially the whole API is just two functions: 'to' and 'from'. Both -- perform a conversion between two types. The only difference between them -- is in what the first type application parameter specifies. E.g.: -- -- > toText = to @Text -- -- > fromBuilder = from @Builder -- -- The types are self-evident: -- -- > > :t to @Text -- > to @Text :: IsomorphicTo Text b => b -> Text -- -- > > :t from @Builder -- > from @Builder :: IsomorphicTo Builder b => Builder -> b -- -- In other words 'to' and 'from' let you explicitly specify either the source -- or the target type of a conversion when you need to help the type -- inferencer or the reader. -- -- = Examples -- -- @ -- combineEncodings :: 'Data.ByteString.Short.ShortByteString' -> 'Data.Primitive.ByteArray' -> 'Data.ByteString.Lazy.ByteString' -> [Word8] -- combineEncodings a b c = -- 'from' @'Data.ByteString.Builder.Builder' $ -- 'to' a <> 'to' b <> 'to' c -- @ -- -- Which is equivalent to: -- -- @ -- combineEncodings :: 'Data.ByteString.Short.ShortByteString' -> 'Data.Primitive.ByteArray' -> 'Data.ByteString.Lazy.ByteString' -> [Word8] -- combineEncodings a b c = -- LazyByteString.'Data.ByteString.Lazy.unpack' $ -- Builder.'Data.ByteString.Builder.toLazyByteString' $ -- mconcat -- [ Builder.'Data.ByteString.Builder.shortByteString' a, -- Builder.'Data.ByteString.Builder.shortByteString' -- ( let ByteArray.'Data.Primitive.ByteArray.ByteArray' array = b -- in ShortByteString.'Data.ByteString.Short.SBS' array -- ), -- Builder.'Data.ByteString.Builder.lazyByteString' c -- ] -- @ module IsomorphismClass ( -- * Typeclasses IsomorphicTo (..), from, -- * Optics isomorphicToIso, -- * Testing module IsomorphismClass.Properties, ) where import IsomorphismClass.Classes import IsomorphismClass.Optics import IsomorphismClass.Properties import IsomorphismClass.Relations () isomorphism-class-0.3.1.2/library/IsomorphismClass/0000755000000000000000000000000007346545000020463 5ustar0000000000000000isomorphism-class-0.3.1.2/library/IsomorphismClass/Classes.hs0000644000000000000000000000016007346545000022411 0ustar0000000000000000module IsomorphismClass.Classes (module Exports) where import IsomorphismClass.Classes.IsomorphicTo as Exports isomorphism-class-0.3.1.2/library/IsomorphismClass/Classes/0000755000000000000000000000000007346545000022060 5ustar0000000000000000isomorphism-class-0.3.1.2/library/IsomorphismClass/Classes/IsomorphicTo.hs0000644000000000000000000000340607346545000025036 0ustar0000000000000000module IsomorphismClass.Classes.IsomorphicTo where import IsomorphismClass.Prelude -- | 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 @IsomorphicTo a b@ as \"/B/ is isomorphic to /A/\". -- -- === Laws -- -- /B/ is isomorphic to /A/ if and only if there exists a conversion from /B/ -- to /A/ ('to') and a conversion from /A/ to /B/ ('from') such that: -- -- - @'from' . 'to' = 'id'@ - For all values of /B/ converting from /B/ to /A/ -- and then converting from /A/ to /B/ produces a value that is identical -- to the original. -- -- - @'to' . 'from' = 'id'@ - For all values of /A/ converting from /A/ to /B/ -- and then converting from /B/ to /A/ produces a value that is identical -- to the original. -- -- === Testing -- -- For testing whether your instances conform to these laws use 'IsomorphismClass.isomorphicToProperties'. -- -- === Instance Definition -- -- For each pair of isomorphic types (/A/ and /B/) the compiler will require -- you to define two instances, namely: @IsomorphicTo A B@ and @IsomorphicTo B A@. class (IsomorphicTo b a) => IsomorphicTo a b where -- | -- Convert a value into an isomophic type. to :: b -> a -- | Every type is isomorphic to itself. instance IsomorphicTo a a where to = id -- | -- 'to' in reverse direction. -- -- Particularly useful in combination with the @TypeApplications@ extension, -- where it allows to specify the input type, e.g.: -- -- > fromText :: IsomorphicTo Text b => Text -> b -- > fromText = from @Text -- -- The first type application of the 'to' function on the other hand specifies -- the output data type. from :: (IsomorphicTo a b) => a -> b from = to isomorphism-class-0.3.1.2/library/IsomorphismClass/Optics.hs0000644000000000000000000000051207346545000022256 0ustar0000000000000000module IsomorphismClass.Optics where import Data.Profunctor import IsomorphismClass.Classes import IsomorphismClass.Prelude -- | Van-Laarhoven-style Isomorphism, compatible with the \"lens\" library. isomorphicToIso :: (IsomorphicTo a b, Profunctor p, Functor f) => p b (f b) -> p a (f a) isomorphicToIso = dimap from (fmap to) isomorphism-class-0.3.1.2/library/IsomorphismClass/Prelude.hs0000644000000000000000000000661507346545000022427 0ustar0000000000000000module IsomorphismClass.Prelude ( module Exports, ) where import Control.Applicative as Exports import Control.Category as Exports import Control.Concurrent as Exports import Control.Exception as Exports import Control.Monad as Exports hiding (fail, forM, forM_, mapM, mapM_, msum, sequence, sequence_) import Control.Monad.Fail as Exports import Control.Monad.Fix as Exports hiding (fix) import Control.Monad.IO.Class as Exports import Control.Monad.ST as Exports import Data.Bifunctor as Exports import Data.Bits as Exports import Data.Bool as Exports import Data.ByteString as Exports (ByteString) import Data.Char as Exports import Data.Coerce as Exports import Data.Complex as Exports import Data.Data as Exports import Data.Dynamic as Exports import Data.Either as Exports import Data.Fixed as Exports import Data.Foldable as Exports hiding (toList) import Data.Function as Exports hiding (id, (.)) import Data.Functor as Exports hiding (unzip) import Data.Functor.Classes as Exports import Data.Functor.Compose as Exports import Data.Functor.Contravariant as Exports import Data.Functor.Identity as Exports import Data.HashMap.Strict as Exports (HashMap) import Data.HashSet as Exports (HashSet) import Data.Hashable as Exports import Data.IORef as Exports import Data.Int as Exports import Data.IntMap.Strict as Exports (IntMap) import Data.IntSet as Exports (IntSet) import Data.Ix as Exports import Data.List as Exports hiding (all, and, any, concat, concatMap, elem, find, foldl, foldl', foldl1, foldr, foldr1, mapAccumL, mapAccumR, maximum, maximumBy, minimum, minimumBy, notElem, or, product, sum) import Data.List.NonEmpty as Exports (NonEmpty (..)) import Data.Map.Strict as Exports (Map) import Data.Maybe as Exports import Data.Monoid as Exports hiding (First (..), Last (..), (<>)) import Data.Ord as Exports import Data.Proxy as Exports import Data.Ratio as Exports import Data.STRef as Exports import Data.Semigroup as Exports import Data.Sequence as Exports (Seq) import Data.Set as Exports (Set) import Data.String as Exports import Data.Text as Exports (Text) import Data.Traversable as Exports import Data.Tuple as Exports import Data.Vector as Exports (Vector) import Data.Version as Exports import Data.Void as Exports import Data.Word as Exports import Debug.Trace as Exports import Foreign.ForeignPtr as Exports import Foreign.Ptr as Exports import Foreign.StablePtr as Exports import Foreign.Storable as Exports import GHC.Conc as Exports hiding (orElse, threadWaitRead, threadWaitReadSTM, threadWaitWrite, threadWaitWriteSTM, withMVar) import GHC.Exts as Exports (IsList (..), groupWith, inline, lazy, sortWith) import GHC.Generics as Exports (Generic, Generic1) import GHC.IO.Exception as Exports import GHC.OverloadedLabels as Exports import GHC.Records as Exports import Numeric as Exports import Numeric.Natural as Exports import System.Environment as Exports import System.Exit as Exports import System.IO as Exports import System.IO.Error as Exports import System.IO.Unsafe as Exports import System.Mem as Exports import System.Mem.StableName as Exports import System.Timeout as Exports import Text.Printf as Exports (hPrintf, printf) import Text.Read as Exports (Read (..), readEither, readMaybe) import Unsafe.Coerce as Exports import Prelude as Exports hiding (all, and, any, concat, concatMap, elem, fail, foldl, foldl1, foldr, foldr1, id, mapM, mapM_, maximum, minimum, notElem, or, product, sequence, sequence_, sum, (.)) isomorphism-class-0.3.1.2/library/IsomorphismClass/Properties.hs0000644000000000000000000000175607346545000023164 0ustar0000000000000000module IsomorphismClass.Properties ( isomorphicToProperties, ) where import IsomorphismClass.Classes import IsomorphismClass.Prelude import Test.QuickCheck -- | -- Properties testing whether an instance satisfies the laws of 'IsomorphicTo'. -- -- The instance is identified via the proxy types that you provide. -- -- E.g., here's how you can integrate it into an Hspec test-suite: -- -- > spec = do -- > describe "IsomorphicTo laws" do -- > traverse_ -- > (uncurry prop) -- > (isomorphicToProperties @Int32 @Word32 Proxy Proxy) isomorphicToProperties :: (IsomorphicTo a b, Eq a, Eq b, Arbitrary a, Show a, Arbitrary b, Show b) => Proxy a -> Proxy b -> [(String, Property)] isomorphicToProperties aProxy bProxy = [ ( "from . to = id", property \b -> b === from' (to' b) ), ( "to . from = id", property \b -> b === to' (from' b) ) ] where to' = as aProxy . to . as bProxy from' = as bProxy . from . as aProxy as = flip asProxyTypeOf isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations.hs0000644000000000000000000000471107346545000022762 0ustar0000000000000000module IsomorphismClass.Relations () where import IsomorphismClass.Relations.BoxedVectorAndList () import IsomorphismClass.Relations.BoxedVectorAndSeq () import IsomorphismClass.Relations.ByteArrayAndByteString () import IsomorphismClass.Relations.ByteArrayAndLazyByteString () import IsomorphismClass.Relations.ByteArrayAndLazyByteStringBuilder () import IsomorphismClass.Relations.ByteArrayAndShortByteString () import IsomorphismClass.Relations.ByteArrayAndTextArray () import IsomorphismClass.Relations.ByteArrayAndWord8List () import IsomorphismClass.Relations.ByteStringAndLazyByteString () import IsomorphismClass.Relations.ByteStringAndLazyByteStringBuilder () import IsomorphismClass.Relations.ByteStringAndShortByteString () import IsomorphismClass.Relations.ByteStringAndTextArray () import IsomorphismClass.Relations.ByteStringAndWord8List () import IsomorphismClass.Relations.DiffTimeAndNominalDiffTime () import IsomorphismClass.Relations.DiffTimeAndPico () import IsomorphismClass.Relations.Int16AndWord16 () import IsomorphismClass.Relations.Int32AndWord32 () import IsomorphismClass.Relations.Int64AndWord64 () import IsomorphismClass.Relations.Int8AndWord8 () import IsomorphismClass.Relations.IntAndWord () import IsomorphismClass.Relations.IntMapAndMapOfInt () import IsomorphismClass.Relations.IntSetAndSetOfInt () import IsomorphismClass.Relations.LazyByteStringAndLazyByteStringBuilder () import IsomorphismClass.Relations.LazyByteStringAndShortByteString () import IsomorphismClass.Relations.LazyByteStringAndTextArray () import IsomorphismClass.Relations.LazyByteStringAndWord8List () import IsomorphismClass.Relations.LazyByteStringBuilderAndShortByteString () import IsomorphismClass.Relations.LazyByteStringBuilderAndTextArray () import IsomorphismClass.Relations.LazyByteStringBuilderAndWord8List () import IsomorphismClass.Relations.LazyTextAndLazyTextBuilder () import IsomorphismClass.Relations.LazyTextAndStrictTextBuilder () import IsomorphismClass.Relations.LazyTextAndText () import IsomorphismClass.Relations.LazyTextBuilderAndStrictTextBuilder () import IsomorphismClass.Relations.LazyTextBuilderAndText () import IsomorphismClass.Relations.ListAndSeq () import IsomorphismClass.Relations.NominalDiffTimeAndPico () import IsomorphismClass.Relations.ShortByteStringAndTextArray () import IsomorphismClass.Relations.ShortByteStringAndWord8List () import IsomorphismClass.Relations.StrictTextBuilderAndText () import IsomorphismClass.Relations.TextArrayAndWord8List () isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/0000755000000000000000000000000007346545000022423 5ustar0000000000000000isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/BoxedVectorAndList.hs0000644000000000000000000000051107346545000026457 0ustar0000000000000000{-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.BoxedVectorAndList where import qualified Data.Vector import IsomorphismClass.Classes import IsomorphismClass.Prelude instance IsomorphicTo (Vector a) [a] where to = Data.Vector.fromList instance IsomorphicTo [a] (Vector a) where to = Data.Vector.toList isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/BoxedVectorAndSeq.hs0000644000000000000000000000062107346545000026276 0ustar0000000000000000{-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.BoxedVectorAndSeq where import qualified Data.Sequence import qualified Data.Vector import IsomorphismClass.Classes import IsomorphismClass.Prelude instance IsomorphicTo (Vector a) (Seq a) where to = Data.Vector.fromList . toList instance IsomorphicTo (Seq a) (Vector a) where to = Data.Sequence.fromList . Data.Vector.toList isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/ByteArrayAndByteString.hs0000644000000000000000000000117007346545000027316 0ustar0000000000000000{-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.ByteArrayAndByteString where import qualified Data.ByteString.Short import qualified Data.Primitive.ByteArray import IsomorphismClass.Classes import IsomorphismClass.Prelude import IsomorphismClass.Relations.ByteArrayAndShortByteString () import IsomorphismClass.Relations.ByteStringAndShortByteString () instance IsomorphicTo Data.Primitive.ByteArray.ByteArray ByteString where to = to . to @Data.ByteString.Short.ShortByteString instance IsomorphicTo ByteString Data.Primitive.ByteArray.ByteArray where to = to . to @Data.ByteString.Short.ShortByteString isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/ByteArrayAndLazyByteString.hs0000644000000000000000000000132007346545000030153 0ustar0000000000000000{-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.ByteArrayAndLazyByteString where import qualified Data.ByteString.Lazy import qualified Data.ByteString.Short import qualified Data.Primitive.ByteArray import IsomorphismClass.Classes import IsomorphismClass.Prelude import IsomorphismClass.Relations.ByteArrayAndShortByteString () import IsomorphismClass.Relations.LazyByteStringAndShortByteString () instance IsomorphicTo Data.ByteString.Lazy.ByteString Data.Primitive.ByteArray.ByteArray where to = to . to @Data.ByteString.Short.ShortByteString instance IsomorphicTo Data.Primitive.ByteArray.ByteArray Data.ByteString.Lazy.ByteString where to = to . to @Data.ByteString.Short.ShortByteString isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/ByteArrayAndLazyByteStringBuilder.hs0000644000000000000000000000134107346545000031465 0ustar0000000000000000{-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.ByteArrayAndLazyByteStringBuilder where import qualified Data.ByteString.Builder import qualified Data.ByteString.Short import qualified Data.Primitive.ByteArray import IsomorphismClass.Classes import IsomorphismClass.Prelude import IsomorphismClass.Relations.ByteArrayAndShortByteString () import IsomorphismClass.Relations.LazyByteStringBuilderAndShortByteString () instance IsomorphicTo Data.Primitive.ByteArray.ByteArray Data.ByteString.Builder.Builder where to = to . to @Data.ByteString.Short.ShortByteString instance IsomorphicTo Data.ByteString.Builder.Builder Data.Primitive.ByteArray.ByteArray where to = to . to @Data.ByteString.Short.ShortByteString isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/ByteArrayAndShortByteString.hs0000644000000000000000000000122207346545000030334 0ustar0000000000000000{-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.ByteArrayAndShortByteString where import qualified Data.ByteString.Short import qualified Data.ByteString.Short.Internal import qualified Data.Primitive.ByteArray import IsomorphismClass.Classes instance IsomorphicTo Data.ByteString.Short.ShortByteString Data.Primitive.ByteArray.ByteArray where to (Data.Primitive.ByteArray.ByteArray array) = Data.ByteString.Short.Internal.SBS array instance IsomorphicTo Data.Primitive.ByteArray.ByteArray Data.ByteString.Short.ShortByteString where to (Data.ByteString.Short.Internal.SBS array) = Data.Primitive.ByteArray.ByteArray array isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/ByteArrayAndTextArray.hs0000644000000000000000000000116207346545000027150 0ustar0000000000000000{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.ByteArrayAndTextArray where #if !MIN_VERSION_text(2,1,0) import qualified Data.Primitive.ByteArray import qualified Data.Text.Array import IsomorphismClass.Classes import IsomorphismClass.Prelude import qualified IsomorphismClass.TextCompat.Array instance IsomorphicTo Data.Primitive.ByteArray.ByteArray Data.Text.Array.Array where to = IsomorphismClass.TextCompat.Array.toByteArray instance IsomorphicTo Data.Text.Array.Array Data.Primitive.ByteArray.ByteArray where to = IsomorphismClass.TextCompat.Array.fromByteArray #endif isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/ByteArrayAndWord8List.hs0000644000000000000000000000067207346545000027071 0ustar0000000000000000{-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.ByteArrayAndWord8List where import qualified Data.Primitive.ByteArray import IsomorphismClass.Classes import IsomorphismClass.Prelude import IsomorphismClass.Relations.ByteArrayAndShortByteString () instance IsomorphicTo Data.Primitive.ByteArray.ByteArray [Word8] where to = fromList instance IsomorphicTo [Word8] Data.Primitive.ByteArray.ByteArray where to = toList isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/ByteStringAndLazyByteString.hs0000644000000000000000000000065107346545000030351 0ustar0000000000000000{-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.ByteStringAndLazyByteString where import qualified Data.ByteString.Lazy import IsomorphismClass.Classes import IsomorphismClass.Prelude instance IsomorphicTo ByteString Data.ByteString.Lazy.ByteString where to = Data.ByteString.Lazy.toStrict instance IsomorphicTo Data.ByteString.Lazy.ByteString ByteString where to = Data.ByteString.Lazy.fromStrict isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/ByteStringAndLazyByteStringBuilder.hs0000644000000000000000000000100707346545000031654 0ustar0000000000000000{-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.ByteStringAndLazyByteStringBuilder where import qualified Data.ByteString.Builder import qualified Data.ByteString.Lazy import IsomorphismClass.Classes import IsomorphismClass.Prelude instance IsomorphicTo ByteString Data.ByteString.Builder.Builder where to = Data.ByteString.Lazy.toStrict . Data.ByteString.Builder.toLazyByteString instance IsomorphicTo Data.ByteString.Builder.Builder ByteString where to = Data.ByteString.Builder.byteString isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/ByteStringAndShortByteString.hs0000644000000000000000000000066707346545000030540 0ustar0000000000000000{-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.ByteStringAndShortByteString where import qualified Data.ByteString.Short import IsomorphismClass.Classes import IsomorphismClass.Prelude instance IsomorphicTo ByteString Data.ByteString.Short.ShortByteString where to = Data.ByteString.Short.fromShort instance IsomorphicTo Data.ByteString.Short.ShortByteString ByteString where to = Data.ByteString.Short.toShort isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/ByteStringAndTextArray.hs0000644000000000000000000000121607346545000027340 0ustar0000000000000000{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.ByteStringAndTextArray where #if !MIN_VERSION_text(2,1,0) import qualified Data.ByteString.Short import qualified Data.Text.Array import IsomorphismClass.Classes import IsomorphismClass.Prelude import qualified IsomorphismClass.TextCompat.Array instance IsomorphicTo ByteString Data.Text.Array.Array where to = Data.ByteString.Short.fromShort . IsomorphismClass.TextCompat.Array.toShortByteString instance IsomorphicTo Data.Text.Array.Array ByteString where to = IsomorphismClass.TextCompat.Array.fromShortByteString . Data.ByteString.Short.toShort #endif isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/ByteStringAndWord8List.hs0000644000000000000000000000053507346545000027257 0ustar0000000000000000{-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.ByteStringAndWord8List where import qualified Data.ByteString import IsomorphismClass.Classes import IsomorphismClass.Prelude instance IsomorphicTo ByteString [Word8] where to = Data.ByteString.pack instance IsomorphicTo [Word8] ByteString where to = Data.ByteString.unpack isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/DiffTimeAndNominalDiffTime.hs0000644000000000000000000000100207346545000030010 0ustar0000000000000000{-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.DiffTimeAndNominalDiffTime where import Data.Time import IsomorphismClass.Classes import IsomorphismClass.Prelude instance IsomorphicTo DiffTime NominalDiffTime where to = picosecondsToDiffTime . picoToInteger . nominalDiffTimeToSeconds where picoToInteger :: Pico -> Integer picoToInteger (MkFixed p) = p instance IsomorphicTo NominalDiffTime DiffTime where to = secondsToNominalDiffTime . MkFixed . diffTimeToPicoseconds isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/DiffTimeAndPico.hs0000644000000000000000000000065307346545000025710 0ustar0000000000000000{-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.DiffTimeAndPico where import Data.Time import IsomorphismClass.Classes import IsomorphismClass.Prelude instance IsomorphicTo DiffTime Pico where to = picosecondsToDiffTime . picoToInteger where picoToInteger :: Pico -> Integer picoToInteger (MkFixed p) = p instance IsomorphicTo Pico DiffTime where to = MkFixed . diffTimeToPicoseconds isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/Int16AndWord16.hs0000644000000000000000000000042607346545000025310 0ustar0000000000000000{-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.Int16AndWord16 where import IsomorphismClass.Classes import IsomorphismClass.Prelude instance IsomorphicTo Int16 Word16 where to = fromIntegral instance IsomorphicTo Word16 Int16 where to = fromIntegral isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/Int32AndWord32.hs0000644000000000000000000000042607346545000025304 0ustar0000000000000000{-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.Int32AndWord32 where import IsomorphismClass.Classes import IsomorphismClass.Prelude instance IsomorphicTo Int32 Word32 where to = fromIntegral instance IsomorphicTo Word32 Int32 where to = fromIntegral isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/Int64AndWord64.hs0000644000000000000000000000042607346545000025316 0ustar0000000000000000{-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.Int64AndWord64 where import IsomorphismClass.Classes import IsomorphismClass.Prelude instance IsomorphicTo Int64 Word64 where to = fromIntegral instance IsomorphicTo Word64 Int64 where to = fromIntegral isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/Int8AndWord8.hs0000644000000000000000000000042007346545000025144 0ustar0000000000000000{-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.Int8AndWord8 where import IsomorphismClass.Classes import IsomorphismClass.Prelude instance IsomorphicTo Int8 Word8 where to = fromIntegral instance IsomorphicTo Word8 Int8 where to = fromIntegral isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/IntAndWord.hs0000644000000000000000000000041207346545000024765 0ustar0000000000000000{-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.IntAndWord where import IsomorphismClass.Classes import IsomorphismClass.Prelude instance IsomorphicTo Int Word where to = fromIntegral instance IsomorphicTo Word Int where to = fromIntegral isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/IntMapAndMapOfInt.hs0000644000000000000000000000070207346545000026167 0ustar0000000000000000{-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.IntMapAndMapOfInt where import qualified Data.IntMap.Strict import qualified Data.Map.Strict import IsomorphismClass.Classes import IsomorphismClass.Prelude instance IsomorphicTo (Map Int v) (IntMap v) where to = Data.Map.Strict.fromList . Data.IntMap.Strict.toList instance IsomorphicTo (IntMap v) (Map Int v) where to = Data.IntMap.Strict.fromList . Data.Map.Strict.toList isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/IntSetAndSetOfInt.hs0000644000000000000000000000045307346545000026226 0ustar0000000000000000{-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.IntSetAndSetOfInt where import IsomorphismClass.Classes import IsomorphismClass.Prelude instance IsomorphicTo (Set Int) IntSet where to = fromList . toList instance IsomorphicTo IntSet (Set Int) where to = fromList . toList library/IsomorphismClass/Relations/LazyByteStringAndLazyByteStringBuilder.hs0000644000000000000000000000077107346545000032444 0ustar0000000000000000isomorphism-class-0.3.1.2{-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.LazyByteStringAndLazyByteStringBuilder where import qualified Data.ByteString.Builder import qualified Data.ByteString.Lazy import IsomorphismClass.Classes instance IsomorphicTo Data.ByteString.Lazy.ByteString Data.ByteString.Builder.Builder where to = Data.ByteString.Builder.toLazyByteString instance IsomorphicTo Data.ByteString.Builder.Builder Data.ByteString.Lazy.ByteString where to = Data.ByteString.Builder.lazyByteString isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/LazyByteStringAndShortByteString.hs0000644000000000000000000000111507346545000031365 0ustar0000000000000000{-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.LazyByteStringAndShortByteString where import qualified Data.ByteString.Lazy import qualified Data.ByteString.Short import IsomorphismClass.Classes import IsomorphismClass.Prelude instance IsomorphicTo Data.ByteString.Lazy.ByteString Data.ByteString.Short.ShortByteString where to = Data.ByteString.Lazy.fromStrict . Data.ByteString.Short.fromShort instance IsomorphicTo Data.ByteString.Short.ShortByteString Data.ByteString.Lazy.ByteString where to = Data.ByteString.Short.toShort . Data.ByteString.Lazy.toStrict isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/LazyByteStringAndTextArray.hs0000644000000000000000000000150407346545000030200 0ustar0000000000000000{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.LazyByteStringAndTextArray where #if !MIN_VERSION_text(2,1,0) import qualified Data.ByteString.Lazy import qualified Data.ByteString.Short import qualified Data.Text.Array import IsomorphismClass.Classes import IsomorphismClass.Prelude import qualified IsomorphismClass.TextCompat.Array instance IsomorphicTo Data.ByteString.Lazy.ByteString Data.Text.Array.Array where to = Data.ByteString.Lazy.fromStrict . Data.ByteString.Short.fromShort . IsomorphismClass.TextCompat.Array.toShortByteString instance IsomorphicTo Data.Text.Array.Array Data.ByteString.Lazy.ByteString where to = IsomorphismClass.TextCompat.Array.fromShortByteString . Data.ByteString.Short.toShort . Data.ByteString.Lazy.toStrict #endif isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/LazyByteStringAndWord8List.hs0000644000000000000000000000063207346545000030115 0ustar0000000000000000{-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.LazyByteStringAndWord8List where import qualified Data.ByteString.Lazy import IsomorphismClass.Classes import IsomorphismClass.Prelude instance IsomorphicTo Data.ByteString.Lazy.ByteString [Word8] where to = Data.ByteString.Lazy.pack instance IsomorphicTo [Word8] Data.ByteString.Lazy.ByteString where to = Data.ByteString.Lazy.unpack library/IsomorphismClass/Relations/LazyByteStringBuilderAndShortByteString.hs0000644000000000000000000000121607346545000032617 0ustar0000000000000000isomorphism-class-0.3.1.2{-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.LazyByteStringBuilderAndShortByteString where import qualified Data.ByteString.Builder import qualified Data.ByteString.Lazy import qualified Data.ByteString.Short import IsomorphismClass.Classes import IsomorphismClass.Prelude instance IsomorphicTo Data.ByteString.Builder.Builder Data.ByteString.Short.ShortByteString where to = Data.ByteString.Builder.shortByteString instance IsomorphicTo Data.ByteString.Short.ShortByteString Data.ByteString.Builder.Builder where to = Data.ByteString.Short.toShort . Data.ByteString.Lazy.toStrict . Data.ByteString.Builder.toLazyByteString isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/LazyByteStringBuilderAndTextArray.hs0000644000000000000000000000157307346545000031515 0ustar0000000000000000{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.LazyByteStringBuilderAndTextArray where #if !MIN_VERSION_text(2,1,0) import qualified Data.ByteString.Builder import qualified Data.ByteString.Lazy import qualified Data.ByteString.Short import qualified Data.Text.Array import IsomorphismClass.Classes import IsomorphismClass.Prelude import qualified IsomorphismClass.TextCompat.Array instance IsomorphicTo Data.ByteString.Builder.Builder Data.Text.Array.Array where to = Data.ByteString.Builder.shortByteString . IsomorphismClass.TextCompat.Array.toShortByteString instance IsomorphicTo Data.Text.Array.Array Data.ByteString.Builder.Builder where to = IsomorphismClass.TextCompat.Array.fromShortByteString . Data.ByteString.Short.toShort . Data.ByteString.Lazy.toStrict . Data.ByteString.Builder.toLazyByteString #endif isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/LazyByteStringBuilderAndWord8List.hs0000644000000000000000000000103607346545000031423 0ustar0000000000000000{-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.LazyByteStringBuilderAndWord8List where import qualified Data.ByteString.Builder import qualified Data.ByteString.Lazy import IsomorphismClass.Classes import IsomorphismClass.Prelude instance IsomorphicTo Data.ByteString.Builder.Builder [Word8] where to = Data.ByteString.Builder.lazyByteString . Data.ByteString.Lazy.pack instance IsomorphicTo [Word8] Data.ByteString.Builder.Builder where to = Data.ByteString.Lazy.unpack . Data.ByteString.Builder.toLazyByteString isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/LazyTextAndLazyTextBuilder.hs0000644000000000000000000000070207346545000030201 0ustar0000000000000000{-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.LazyTextAndLazyTextBuilder where import qualified Data.Text.Lazy import qualified Data.Text.Lazy.Builder import IsomorphismClass.Classes instance IsomorphicTo Data.Text.Lazy.Text Data.Text.Lazy.Builder.Builder where to = Data.Text.Lazy.Builder.toLazyText instance IsomorphicTo Data.Text.Lazy.Builder.Builder Data.Text.Lazy.Text where to = Data.Text.Lazy.Builder.fromLazyText isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/LazyTextAndStrictTextBuilder.hs0000644000000000000000000000113407346545000030532 0ustar0000000000000000{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.LazyTextAndStrictTextBuilder where #if MIN_VERSION_text(2,0,2) import qualified Data.Text.Encoding import qualified Data.Text.Lazy import IsomorphismClass.Classes import IsomorphismClass.Prelude instance IsomorphicTo Data.Text.Lazy.Text Data.Text.Encoding.StrictBuilder where to = Data.Text.Lazy.fromStrict . Data.Text.Encoding.strictBuilderToText instance IsomorphicTo Data.Text.Encoding.StrictBuilder Data.Text.Lazy.Text where to = Data.Text.Encoding.textToStrictBuilder . Data.Text.Lazy.toStrict #endif isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/LazyTextAndText.hs0000644000000000000000000000054707346545000026041 0ustar0000000000000000{-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.LazyTextAndText where import qualified Data.Text.Lazy import IsomorphismClass.Classes import IsomorphismClass.Prelude instance IsomorphicTo Data.Text.Lazy.Text Text where to = Data.Text.Lazy.fromStrict instance IsomorphicTo Text Data.Text.Lazy.Text where to = Data.Text.Lazy.toStrict isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/LazyTextBuilderAndStrictTextBuilder.hs0000644000000000000000000000131307346545000032040 0ustar0000000000000000{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.LazyTextBuilderAndStrictTextBuilder where #if MIN_VERSION_text(2,0,2) import qualified Data.Text.Encoding import qualified Data.Text.Lazy import qualified Data.Text.Lazy.Builder import IsomorphismClass.Classes import IsomorphismClass.Prelude instance IsomorphicTo Data.Text.Lazy.Builder.Builder Data.Text.Encoding.StrictBuilder where to = Data.Text.Lazy.Builder.fromText . Data.Text.Encoding.strictBuilderToText instance IsomorphicTo Data.Text.Encoding.StrictBuilder Data.Text.Lazy.Builder.Builder where to = Data.Text.Encoding.textToStrictBuilder . Data.Text.Lazy.toStrict . Data.Text.Lazy.Builder.toLazyText #endif isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/LazyTextBuilderAndText.hs0000644000000000000000000000072607346545000027347 0ustar0000000000000000{-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.LazyTextBuilderAndText where import qualified Data.Text.Lazy import qualified Data.Text.Lazy.Builder import IsomorphismClass.Classes import IsomorphismClass.Prelude instance IsomorphicTo Data.Text.Lazy.Builder.Builder Text where to = Data.Text.Lazy.Builder.fromText instance IsomorphicTo Text Data.Text.Lazy.Builder.Builder where to = Data.Text.Lazy.toStrict . Data.Text.Lazy.Builder.toLazyText isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/ListAndSeq.hs0000644000000000000000000000046307346545000024771 0ustar0000000000000000{-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.ListAndSeq where import qualified Data.Sequence import IsomorphismClass.Classes import IsomorphismClass.Prelude instance IsomorphicTo [a] (Seq a) where to = toList instance IsomorphicTo (Seq a) [a] where to = Data.Sequence.fromList isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/NominalDiffTimeAndPico.hs0000644000000000000000000000052707346545000027226 0ustar0000000000000000{-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.NominalDiffTimeAndPico where import Data.Time import IsomorphismClass.Classes import IsomorphismClass.Prelude instance IsomorphicTo NominalDiffTime Pico where to = secondsToNominalDiffTime instance IsomorphicTo Pico NominalDiffTime where to = nominalDiffTimeToSeconds isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/ShortByteStringAndTextArray.hs0000644000000000000000000000120707346545000030360 0ustar0000000000000000{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.ShortByteStringAndTextArray where #if !MIN_VERSION_text(2,1,0) import qualified Data.ByteString.Short import qualified Data.Text.Array import IsomorphismClass.Classes import IsomorphismClass.Prelude import qualified IsomorphismClass.TextCompat.Array instance IsomorphicTo Data.ByteString.Short.ShortByteString Data.Text.Array.Array where to = IsomorphismClass.TextCompat.Array.toShortByteString instance IsomorphicTo Data.Text.Array.Array Data.ByteString.Short.ShortByteString where to = IsomorphismClass.TextCompat.Array.fromShortByteString #endif isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/ShortByteStringAndWord8List.hs0000644000000000000000000000075307346545000030301 0ustar0000000000000000{-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.ShortByteStringAndWord8List where import qualified Data.ByteString.Short import IsomorphismClass.Classes import IsomorphismClass.Prelude import IsomorphismClass.Relations.ByteArrayAndShortByteString () instance IsomorphicTo [Word8] Data.ByteString.Short.ShortByteString where to = Data.ByteString.Short.unpack instance IsomorphicTo Data.ByteString.Short.ShortByteString [Word8] where to = Data.ByteString.Short.pack isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/StrictTextBuilderAndText.hs0000644000000000000000000000075007346545000027675 0ustar0000000000000000{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.StrictTextBuilderAndText where #if MIN_VERSION_text(2,0,2) import qualified Data.Text.Encoding import IsomorphismClass.Classes import IsomorphismClass.Prelude instance IsomorphicTo Text Data.Text.Encoding.StrictBuilder where to = Data.Text.Encoding.strictBuilderToText instance IsomorphicTo Data.Text.Encoding.StrictBuilder Text where to = Data.Text.Encoding.textToStrictBuilder #endif isomorphism-class-0.3.1.2/library/IsomorphismClass/Relations/TextArrayAndWord8List.hs0000644000000000000000000000120107346545000027077 0ustar0000000000000000{-# LANGUAGE CPP #-} {-# OPTIONS_GHC -Wno-orphans #-} module IsomorphismClass.Relations.TextArrayAndWord8List where #if !MIN_VERSION_text(2,1,0) import qualified Data.ByteString.Short import qualified Data.Text.Array import IsomorphismClass.Classes import IsomorphismClass.Prelude import qualified IsomorphismClass.TextCompat.Array instance IsomorphicTo Data.Text.Array.Array [Word8] where to = IsomorphismClass.TextCompat.Array.fromShortByteString . Data.ByteString.Short.pack instance IsomorphicTo [Word8] Data.Text.Array.Array where to = Data.ByteString.Short.unpack . IsomorphismClass.TextCompat.Array.toShortByteString #endif isomorphism-class-0.3.1.2/library/IsomorphismClass/TextCompat/0000755000000000000000000000000007346545000022553 5ustar0000000000000000isomorphism-class-0.3.1.2/library/IsomorphismClass/TextCompat/Array.hs0000644000000000000000000000251107346545000024164 0ustar0000000000000000{-# LANGUAGE CPP #-} module IsomorphismClass.TextCompat.Array where import qualified Data.ByteString.Short import qualified Data.ByteString.Short.Internal import qualified Data.Primitive.ByteArray import Data.Text.Array import GHC.Exts (ByteArray#) {-# INLINE toUnliftedByteArray #-} toUnliftedByteArray :: Array -> ByteArray# #if MIN_VERSION_text(2,0,0) toUnliftedByteArray (ByteArray a) = a #else toUnliftedByteArray (Array a) = a #endif {-# INLINE fromUnliftedByteArray #-} fromUnliftedByteArray :: ByteArray# -> Array #if MIN_VERSION_text(2,0,0) fromUnliftedByteArray = ByteArray #else fromUnliftedByteArray = Array #endif {-# INLINE fromShortByteString #-} fromShortByteString :: Data.ByteString.Short.ShortByteString -> Array fromShortByteString (Data.ByteString.Short.Internal.SBS arr) = fromUnliftedByteArray arr {-# INLINE toShortByteString #-} toShortByteString :: Array -> Data.ByteString.Short.ShortByteString toShortByteString a = Data.ByteString.Short.Internal.SBS (toUnliftedByteArray a) {-# INLINE fromByteArray #-} fromByteArray :: Data.Primitive.ByteArray.ByteArray -> Array fromByteArray (Data.Primitive.ByteArray.ByteArray arr) = fromUnliftedByteArray arr {-# INLINE toByteArray #-} toByteArray :: Array -> Data.Primitive.ByteArray.ByteArray toByteArray a = Data.Primitive.ByteArray.ByteArray (toUnliftedByteArray a) isomorphism-class-0.3.1.2/test/0000755000000000000000000000000007346545000014477 5ustar0000000000000000isomorphism-class-0.3.1.2/test/Main.hs0000644000000000000000000001507107346545000015723 0ustar0000000000000000module Main where import qualified Data.ByteString.Builder as ByteStringBuilder import qualified Data.ByteString.Lazy as ByteStringLazy import qualified Data.ByteString.Short as ByteStringShort import qualified Data.Primitive.ByteArray as PrimitiveByteArray import qualified Data.Text.Lazy as TextLazy import qualified Data.Text.Lazy.Builder as TextLazyBuilder import IsomorphismClass import Rebase.Prelude import Test.ExtraInstances () import Test.Tasty import Test.Tasty.QuickCheck hiding ((.&.)) main :: IO () main = defaultMain allTests allTests :: TestTree allTests = testGroup "All" $ [ testPair @[Word8] @ByteString Proxy Proxy, testPair @[Word8] @ByteStringLazy.ByteString Proxy Proxy, testPair @[Word8] @ByteStringShort.ShortByteString Proxy Proxy, testPair @[Word8] @ByteStringBuilder.Builder Proxy Proxy, testPair @[Word8] @PrimitiveByteArray.ByteArray Proxy Proxy, testPair @[Word8] @[Word8] Proxy Proxy, testPair @[Word8] @(Vector Word8) Proxy Proxy, testPair @[Word8] @(Seq Word8) Proxy Proxy, testPair @Text @Text Proxy Proxy, testPair @Text @TextLazy.Text Proxy Proxy, testPair @Text @TextLazyBuilder.Builder Proxy Proxy, testPair @TextLazy.Text @TextLazy.Text Proxy Proxy, testPair @TextLazy.Text @Text Proxy Proxy, testPair @TextLazy.Text @TextLazyBuilder.Builder Proxy Proxy, testPair @TextLazyBuilder.Builder @TextLazyBuilder.Builder Proxy Proxy, testPair @TextLazyBuilder.Builder @Text Proxy Proxy, testPair @TextLazyBuilder.Builder @TextLazy.Text Proxy Proxy, testPair @ByteString @ByteString Proxy Proxy, testPair @ByteString @[Word8] Proxy Proxy, testPair @ByteString @ByteStringLazy.ByteString Proxy Proxy, testPair @ByteString @ByteStringShort.ShortByteString Proxy Proxy, testPair @ByteString @ByteStringBuilder.Builder Proxy Proxy, testPair @ByteString @PrimitiveByteArray.ByteArray Proxy Proxy, testPair @ByteStringLazy.ByteString @ByteStringLazy.ByteString Proxy Proxy, testPair @ByteStringLazy.ByteString @[Word8] Proxy Proxy, testPair @ByteStringLazy.ByteString @ByteString Proxy Proxy, testPair @ByteStringLazy.ByteString @ByteStringShort.ShortByteString Proxy Proxy, testPair @ByteStringLazy.ByteString @ByteStringBuilder.Builder Proxy Proxy, testPair @ByteStringLazy.ByteString @PrimitiveByteArray.ByteArray Proxy Proxy, testPair @ByteStringShort.ShortByteString @ByteStringShort.ShortByteString Proxy Proxy, testPair @ByteStringShort.ShortByteString @[Word8] Proxy Proxy, testPair @ByteStringShort.ShortByteString @ByteString Proxy Proxy, testPair @ByteStringShort.ShortByteString @ByteStringLazy.ByteString Proxy Proxy, testPair @ByteStringShort.ShortByteString @ByteStringBuilder.Builder Proxy Proxy, testPair @ByteStringShort.ShortByteString @PrimitiveByteArray.ByteArray Proxy Proxy, testPair @ByteStringBuilder.Builder @ByteStringBuilder.Builder Proxy Proxy, testPair @ByteStringBuilder.Builder @[Word8] Proxy Proxy, testPair @ByteStringBuilder.Builder @ByteString Proxy Proxy, testPair @ByteStringBuilder.Builder @ByteStringLazy.ByteString Proxy Proxy, testPair @ByteStringBuilder.Builder @ByteStringShort.ShortByteString Proxy Proxy, testPair @ByteStringBuilder.Builder @PrimitiveByteArray.ByteArray Proxy Proxy, testPair @PrimitiveByteArray.ByteArray @PrimitiveByteArray.ByteArray Proxy Proxy, testPair @PrimitiveByteArray.ByteArray @[Word8] Proxy Proxy, testPair @PrimitiveByteArray.ByteArray @ByteStringShort.ShortByteString Proxy Proxy, testPair @PrimitiveByteArray.ByteArray @ByteString Proxy Proxy, testPair @PrimitiveByteArray.ByteArray @ByteStringLazy.ByteString Proxy Proxy, testPair @PrimitiveByteArray.ByteArray @ByteStringBuilder.Builder Proxy Proxy, testPair @(Vector Word8) @(Vector Word8) Proxy Proxy, testPair @(Vector Word8) @[Word8] Proxy Proxy, testPair @(Vector Word8) @(Seq Word8) Proxy Proxy, testPair @(Seq Word8) @(Seq Word8) Proxy Proxy, testPair @(Seq Word8) @[Word8] Proxy Proxy, testPair @(Seq Word8) @(Vector Word8) Proxy Proxy, testPair @(Set Word8) @(Set Word8) Proxy Proxy, testPair @(Set Int) @IntSet Proxy Proxy, testPair @IntSet @IntSet Proxy Proxy, testPair @IntSet @(Set Int) Proxy Proxy, testPair @(Map Word8 Word8) @(Map Word8 Word8) Proxy Proxy, testPair @(Map Int Word8) @(IntMap Word8) Proxy Proxy, testPair @(IntMap Word8) @(IntMap Word8) Proxy Proxy, testPair @(IntMap Word8) @(Map Int Word8) Proxy Proxy, testPair @(Maybe Word8) @(Maybe Word8) Proxy Proxy, testPair @(Either Word8 Word8) @(Either Word8 Word8) Proxy Proxy, testPair @(First Word8) @(First Word8) Proxy Proxy, testPair @(Last Word8) @(Last Word8) Proxy Proxy, testPair @(Product Word8) @(Product Word8) Proxy Proxy, testPair @(Sum Word8) @(Sum Word8) Proxy Proxy, testPair @Bool @Bool Proxy Proxy, testPair @Char @Char Proxy Proxy, testPair @Double @Double Proxy Proxy, testPair @Float @Float Proxy Proxy, testPair @Int @Int Proxy Proxy, testPair @Int @Word Proxy Proxy, testPair @Int16 @Int16 Proxy Proxy, testPair @Int16 @Word16 Proxy Proxy, testPair @Int32 @Int32 Proxy Proxy, testPair @Int32 @Word32 Proxy Proxy, testPair @Int64 @Int64 Proxy Proxy, testPair @Int64 @Word64 Proxy Proxy, testPair @Int8 @Int8 Proxy Proxy, testPair @Int8 @Word8 Proxy Proxy, testPair @Integer @Integer Proxy Proxy, testPair @Rational @Rational Proxy Proxy, testPair @Word @Int Proxy Proxy, testPair @Word @Word Proxy Proxy, testPair @Word16 @Int16 Proxy Proxy, testPair @Word16 @Word16 Proxy Proxy, testPair @Word32 @Int32 Proxy Proxy, testPair @Word32 @Word32 Proxy Proxy, testPair @Word64 @Int64 Proxy Proxy, testPair @Word64 @Word64 Proxy Proxy, testPair @Word8 @Int8 Proxy Proxy, testPair @Word8 @Word8 Proxy Proxy, testPair @DiffTime @NominalDiffTime Proxy Proxy, testPair @DiffTime @Pico Proxy Proxy, testPair @NominalDiffTime @Pico Proxy Proxy ] testPair :: (IsomorphicTo a b, Eq a, Eq b, Arbitrary a, Show a, Arbitrary b, Show b, Typeable a, Typeable b) => Proxy a -> Proxy b -> TestTree testPair superp subp = isomorphicToProperties superp subp & fmap (uncurry testProperty) & testGroup groupName where groupName = mconcat [ show (typeOf (asProxyTypeOf undefined superp)), "/", show (typeOf (asProxyTypeOf undefined subp)) ] isomorphism-class-0.3.1.2/test/Test/0000755000000000000000000000000007346545000015416 5ustar0000000000000000isomorphism-class-0.3.1.2/test/Test/ExtraInstances.hs0000644000000000000000000000135407346545000020710 0ustar0000000000000000{-# OPTIONS_GHC -Wno-orphans #-} module Test.ExtraInstances () where import qualified Data.ByteString.Builder as ByteStringBuilder import qualified Data.Text.Lazy.Builder as TextLazyBuilder import Rebase.Prelude import Test.QuickCheck import Test.QuickCheck.Instances () instance Arbitrary TextLazyBuilder.Builder where arbitrary = TextLazyBuilder.fromText <$> arbitrary shrink = shrinkMap TextLazyBuilder.fromLazyText TextLazyBuilder.toLazyText instance Eq ByteStringBuilder.Builder where (==) = on (==) ByteStringBuilder.toLazyByteString instance Arbitrary ByteStringBuilder.Builder where arbitrary = ByteStringBuilder.byteString <$> arbitrary shrink = shrinkMap ByteStringBuilder.lazyByteString ByteStringBuilder.toLazyByteString