lawful-conversions 0.3.0.3 → 0.3.0.4
raw patch · 5 files changed
+38/−21 lines, 5 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- lawful-conversions.cabal +3/−1
- src/library/LawfulConversions/Algebra.hs +5/−20
- src/library/LawfulConversions/Relations.hs +2/−0
- src/library/LawfulConversions/Relations/Any.hs +17/−0
- src/library/LawfulConversions/Relations/Void.hs +11/−0
lawful-conversions.cabal view
@@ -1,6 +1,6 @@ cabal-version: 3.0 name: lawful-conversions-version: 0.3.0.3+version: 0.3.0.4 synopsis: Lawful typeclasses for bidirectional conversion between types category: Conversion homepage: https://github.com/nikita-volkov/lawful-conversions@@ -92,6 +92,7 @@ LawfulConversions.Proxies LawfulConversions.Proxies.ViaIsSome LawfulConversions.Relations+ LawfulConversions.Relations.Any LawfulConversions.Relations.BoxedVectorAndList LawfulConversions.Relations.BoxedVectorAndSeq LawfulConversions.Relations.ByteArrayAndByteString@@ -154,6 +155,7 @@ LawfulConversions.Relations.TextAndUtcTime LawfulConversions.Relations.TextAndUuid LawfulConversions.Relations.TextArrayAndWord8List+ LawfulConversions.Relations.Void LawfulConversions.TextCompat.Array build-depends:
src/library/LawfulConversions/Algebra.hs view
@@ -52,18 +52,8 @@ default maybeFrom :: (IsSome b a) => a -> Maybe b maybeFrom = Just . to --- | Every type is isomorphic to itself.-instance IsSome a a where- to = id- maybeFrom = Just . id---- | The empty set has no elements, and therefore is vacuously a subset of any set.-instance IsSome a Void where- to = absurd- maybeFrom = const Nothing- -- |--- Convert a value of a superset type to a subset type specifying the superset type first.+-- Convert a value of a subset type to a superset type, specifying the source subset type first. -- -- Alias to 'to' with the only difference in the argument order. --@@ -108,7 +98,7 @@ -- -- Every value of type @b@ can be obtained by applying 'onfrom' to some value of type @a@: ----- > \b -> exists a. onfrom @b a == b+-- > \b -> exists a. onfrom @a @b a == b -- -- Note: This property cannot be directly tested with QuickCheck as it requires existential quantification. --@@ -158,8 +148,6 @@ onto :: forall b a. (IsMany a b) => a -> b onto = onfrom -instance IsMany a a- -- | Bidirectional conversion between two types with no loss of information. -- -- The bidirectionality is encoded via a recursive dependency with arguments@@ -173,13 +161,13 @@ -- -- For all values of /b/ converting from /b/ to /a/ and then converting from /a/ to /b/ produces the original value: ----- > \b -> b == from @b (to @a b)+-- > \b -> b == from @a (to @a b) -- -- ==== 'to' is an [inverse](https://en.wikipedia.org/wiki/Inverse_function) of 'from' -- -- For all values of /a/ converting from /a/ to /b/ and then converting from /b/ to /a/ produces the original value: ----- > \a -> a == to @a (from @b a)+-- > \a -> a == to @a (from @a @b a) -- -- ==== Mathematical relationship --@@ -190,7 +178,7 @@ -- -- For isomorphic types, both ways of converting should be equivalent: ----- > \a -> from @b @a a == onfrom @a @b a+-- > \a -> from @a @b a == onfrom @a @b a -- -- === Testing --@@ -220,6 +208,3 @@ -- instance Is "Data.Text.Text" "Data.Text.Lazy.LazyText" -- @ class (IsMany a b, Is b a) => Is a b---- | Any type is isomorphic to itself.-instance Is a a
src/library/LawfulConversions/Relations.hs view
@@ -1,5 +1,6 @@ module LawfulConversions.Relations () where +import LawfulConversions.Relations.Any () import LawfulConversions.Relations.BoxedVectorAndList () import LawfulConversions.Relations.BoxedVectorAndSeq () import LawfulConversions.Relations.ByteArrayAndByteString ()@@ -62,3 +63,4 @@ import LawfulConversions.Relations.TextAndUtcTime () import LawfulConversions.Relations.TextAndUuid () import LawfulConversions.Relations.TextArrayAndWord8List ()+import LawfulConversions.Relations.Void ()
+ src/library/LawfulConversions/Relations/Any.hs view
@@ -0,0 +1,17 @@+{-# OPTIONS_GHC -Wno-orphans #-}++module LawfulConversions.Relations.Any where++import LawfulConversions.Algebra+import LawfulConversions.Prelude++-- | Any type is isomorphic to itself.+instance IsSome a a where+ to = id+ maybeFrom = Just . id++-- | Any type is isomorphic to itself.+instance IsMany a a++-- | Any type is isomorphic to itself.+instance Is a a
+ src/library/LawfulConversions/Relations/Void.hs view
@@ -0,0 +1,11 @@+{-# OPTIONS_GHC -Wno-orphans #-}++module LawfulConversions.Relations.Void where++import LawfulConversions.Algebra+import LawfulConversions.Prelude++-- | The empty set has no elements, and therefore is vacuously a subset of any set.+instance IsSome a Void where+ to = absurd+ maybeFrom = const Nothing