lawful-conversions
Lawful typeclasses for bidirectional conversion between types
= Summary
Lawful typeclasses capturing three patterns of bidirectional mapping and forming a layered hierarchy with an ascending strictness of laws.
1. Smart constructor
2. Canonicalization or lossy conversion
3. Isomorphism or lossless conversion
= The conversion problem
Have you ever looked for a @toString@ function? How often do you
import @Data.Text.Lazy@ only to call its @fromStrict@? How
about importing @Data.ByteString.Builder@ only to call its
@toLazyByteString@ and then importing
@Data.ByteString.Lazy@ only to call its @toStrict@?
Those all are 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 codereader, it's a burden to the
implementor and the maintainer.
= 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 behaviour 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 hierarchy, making it
evident what any of its instances do and it provides property-tests for you
to validate your instances.
The laws and the concepts are based on set and category theories.
= Prior work and acknowledgements
This library is an offspring of the "[isomorphism-class](https://hackage.haskell.org/package/isomorphism-class)" library, expanding upon the patterns discovered there. 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)
| version | uploaded | uploader | changes | |
|---|---|---|---|---|
| 0.4.0 | 2026-03-11 12:27 UTC | NikitaVolkov | +26/−441 lines, 28 filesdep −timedep −uuid-typesPVP ok | |
| 0.3.1 | 2026-01-18 05:16 UTC | NikitaVolkov | +4/−3 lines, 2 filesPVP ok | |
| 0.3.0.4 | 2026-01-17 12:06 UTC | NikitaVolkov | +38/−21 lines, 5 filesPVP ok | |
| 0.3.0.3 | 2026-01-13 09:28 UTC | NikitaVolkov | +2/−2 lines, 1 filesdep ~quickcheck-instancesPVP ok | |
| 0.3.0.2 | 2026-01-07 15:30 UTC | NikitaVolkov | +2/−2 lines, 1 filesdep ~containersPVP ok | |
| 0.3.0.1 | 2025-08-25 14:49 UTC | NikitaVolkov | +3/−5 lines, 3 filesPVP ok | |
| 0.3 | 2025-08-25 14:10 UTC | NikitaVolkov | +139/−56 lines, 18 filesPVP ok | |
| 0.2.0.1 | 2025-08-20 18:02 UTC | NikitaVolkov | +5/−4 lines, 2 filesPVP ok | |
| 0.2 | 2025-08-17 13:33 UTC | NikitaVolkov | +256/−238 lines, 70 filesPVP ok | |
| 0.1.7 | 2025-05-14 15:02 UTC | NikitaVolkov | +17/−1 lines, 3 filesPVP ok | |
| 0.1.6.1 | 2025-04-06 09:37 UTC | NikitaVolkov | +153/−170 lines, 5 filesPVP ok | |
| 0.1.6 | 2024-12-23 12:08 UTC | NikitaVolkov | +45/−4 lines, 4 filesPVP ok | |
| 0.1.5 | 2024-12-21 19:42 UTC | NikitaVolkov | +64/−15 lines, 7 filesPVP ok | |
| 0.1.4.1 | 2024-12-07 08:12 UTC | NikitaVolkov | +2/−2 lines, 1 filesdep ~tasty-quickcheckPVP ok | |
| 0.1.4 | 2024-12-05 08:33 UTC | NikitaVolkov | +237/−102 lines, 13 filesPVP ok | |
| 0.1.3 | 2024-12-04 21:45 UTC | NikitaVolkov | +193/−12 lines, 12 filesdep +timePVP: major bump suggested | |
| 0.1.2.2 | 2024-12-04 20:08 UTC | NikitaVolkov | +9/−6 lines, 3 filesPVP ok | |
| 0.1.2.1 | 2024-12-04 18:37 UTC | NikitaVolkov | +161/−98 lines, 8 filesPVP: major bump suggested | |
| 0.1.2 | 2024-12-03 18:22 UTC | NikitaVolkov | +77/−1 lines, 8 filesdep +uuid-typesPVP ok | |
| 0.1.1 | 2024-12-03 02:48 UTC | NikitaVolkov | 5 revisions | +17/−1 lines, 6 files |
| 0.1 | 2024-12-03 01:43 UTC | NikitaVolkov | +1866/−0 lines, 60 filesdep +QuickCheckdep +basedep +bytestring |
Dependencies of lawful-conversions-0.4.0
QuickCheck >=2.13 && <3 2.18.0.0 → 2.19.0.0
| 2026-09-16 11:18 UTC | 2.19.0.0 | +67/−41 lines, 10 filesdep +OneTuplePVP ok |
| 2026-02-26 12:42 UTC | 2.18.0.0 | +826/−542 lines, 23 filesPVP ok |
| 2025-10-13 12:40 UTC | 2.17.1.0 | +18/−8 lines, 4 filesdep ~randomPVP: major bump suggested |
| 2025-10-07 12:26 UTC | 2.17.0.0 | +667/−129 lines, 14 filesdep +data-array-bytedep +hintdep +splitdep −ghc-primdep −old-localedep −old-timedep ~basedep ~randomdep ~template-haskellPVP ok |
| 2025-06-17 07:53 UTC | 2.16.0.0 | +477/−86 lines, 15 filesdep ~basenew-uploaderPVP ok |
showing 5 of 66 versions
base >=4.12 && <5 4.22.0.0 → 4.22.1.0
| 2026-12-01 12:38 UTC | 4.22.1.0 | +388/−6 lines, 9 filesdep ~ghc-internalPVP: major bump suggested |
| 2025-12-19 11:52 UTC | 4.22.0.0 | +886/−215 lines, 28 filesdep ~ghc-internalPVP ok |
| 2026-03-27 12:26 UTC | 4.21.2.0 | +10/−3 lines, 4 filesdep ~ghc-internalPVP ok |
| 2025-12-27 10:31 UTC | 4.21.1.0 | +17/−5 lines, 4 filesdep ~ghc-internalPVP ok |
| 2024-12-16 09:24 UTC | 4.21.0.0 | +1170/−396 lines, 39 filesdep ~ghc-internalPVP ok |
showing 5 of 61 versions
bytestring >=0.11.1.0 && <0.13 0.12.1.0 → 0.12.2.0
| 2024-12-06 21:41 UTC | 0.12.2.0 | +538/−437 lines, 44 filesdep ~QuickCheckdep ~basePVP ok |
| 2024-02-16 03:27 UTC | 0.12.1.0 | +3398/−1642 lines, 37 filesdep +sybdep ~basePVP: major bump suggested |
| 2023-08-16 01:53 UTC | 0.12.0.2 | +16/−2 lines, 3 files |
| 2023-08-05 00:03 UTC | 0.12.0.1 | +47/−9 lines, 3 files |
| 2023-07-07 01:45 UTC | 0.12.0.0 | +1459/−520 lines, 21 filesdep +data-array-bytePVP ok |
showing 5 of 49 versions
containers >=0.6 && <0.9 0.8 → 0.8.1
| 2026-10-04 06:08 UTC | 0.8.1 | +8085/−5169 lines, 39 filesdep +template-haskell-liftdep ~arraydep ~deepseqPVP: major bump suggested |
| 2025-03-01 13:03 UTC | 0.8 | +8447/−7031 lines, 37 filesnew-uploaderPVP ok |
| 2023-09-27 12:15 UTC | 0.7 | +76/−33 lines, 3 filesPVP ok |
| 2023-09-28 04:21 UTC | 0.6.8 | +644/−184 lines, 17 filesdep ~basedep ~deepseqPVP: major bump suggested |
| 2023-02-01 03:11 UTC | 0.6.7 | +783/−229 lines, 20 filesPVP: major bump suggested |
showing 5 of 43 versions
hashable >=1 && <2 1.5.0.0 → 1.5.1.0
| 2026-01-02 17:45 UTC | 1.5.1.0 | +7260/−6790 lines, 5 filesdep −HUnitdep −ghc-bignumdep −randomdep ~basedep ~containersPVP: major bump suggested |
| 2024-07-04 19:38 UTC | 1.5.0.0 | +50/−156 lines, 4 filesdep −base-orphansdep −ghc-bignum-orphansdep −integer-gmpdep ~QuickCheckdep ~basedep ~bytestringPVP ok |
| 2024-06-24 10:44 UTC | 1.4.7.0 | +8/−3 lines, 2 filesPVP ok |
| 2024-06-09 19:43 UTC | 1.4.6.0 | +60/−83 lines, 7 filesdep −test-frameworkdep −test-framework-hunitdep −test-framework-quickcheck2PVP ok |
| 2024-06-08 14:07 UTC | 1.4.5.0 | +7338/−256 lines, 15 filesdep +primitivedep +tastydep +tasty-hunitdep ~basedep ~bytestringdep ~containersPVP ok |
showing 5 of 52 versions
primitive >=0.7 && <0.10 0.9.0.0 → 0.9.1.0
| 2025-03-31 14:42 UTC | 0.9.1.0 | +225/−135 lines, 12 filesdep +containersdep −ghc-primdep ~basePVP: major bump suggested |
| 2023-10-05 15:07 UTC | 0.9.0.0 | +995/−657 lines, 17 filesdep ~QuickCheckdep ~basedep ~tastyPVP ok |
| 2023-02-20 16:20 UTC | 0.8.0.0 | +328/−248 lines, 9 filesdep +data-array-bytedep ~basedep ~deepseqPVP ok |
| 2022-05-20 18:46 UTC | 0.7.4.0 | +244/−146 lines, 10 filesdep +template-haskelldep −faildep −semigroupsdep ~basedep ~transformersPVP ok |
| 2021-10-27 19:26 UTC | 0.7.3.0 | +951/−947 lines, 25 filesdep +tasty-benchdep ~basedep ~deepseqdep ~transformerssetup-changedPVP: major bump suggested |
showing 5 of 30 versions
profunctors >=5 && <6 5.6.2 → 5.6.3
| 2025-06-17 11:50 UTC | 5.6.3 | +24/−66 lines, 10 filesdep −semigroupsdep ~basePVP: major bump suggested |
| 2021-02-17 14:50 UTC | 5.6.2 | +31/−2 lines, 3 filesdep ~base-orphansdep ~semigroupsdep ~transformersPVP ok |
| 2020-12-31 12:05 UTC | 5.6.1 | +57/−174 lines, 17 filesdep ~base-orphansdep ~bifunctorsdep ~comonadPVP: major bump suggested |
| 2020-10-01 11:25 UTC | 5.6 | +166/−85 lines, 16 filesdep ~basePVP ok |
| 2020-02-13 19:20 UTC | 5.5.2 | +35/−1 lines, 5 filesPVP ok |
showing 5 of 44 versions
quickcheck-instances >=0.3.32 && <0.5 0.3.33 → 0.4
| 2026-01-08 11:48 UTC | 0.4 | +29/−227 lines, 7 filesdep −OneTupledep ~QuickCheckdep ~arraydep ~basePVP ok |
| 2025-06-03 21:29 UTC | 0.3.33 | +25/−6 lines, 3 filesdep ~QuickCheckdep ~vectorPVP: major bump suggested |
| 2024-11-04 11:57 UTC | 0.3.32 | +25/−7 lines, 3 filesdep ~basePVP ok |
| 2024-05-16 22:12 UTC | 0.3.31 outside bounds | +54/−235 lines, 26 filesdep −bytestring-builderdep −natsdep −semigroupsdep ~OneTupledep ~QuickCheckdep ~arrayPVP: major bump suggested |
| 2023-10-04 18:05 UTC | 0.3.30 outside bounds | +46/−17 lines, 3 filesdep ~basedep ~bytestringdep ~primitivePVP ok |
showing 5 of 42 versions
rebase >=1.15 && <2 1.22 → 1.23
| 2026-01-28 07:06 UTC | 1.23 | +506/−2688 lines, 366 filesdep +uuiddep −uuid-typesPVP ok |
| 2026-01-07 15:10 UTC | 1.22 | +4/−11 lines, 2 filesdep ~containersdep ~timePVP ok |
| 2025-01-30 04:05 UTC | 1.21.2 | +2/−2 lines, 1 filesdep ~timePVP ok |
| 2024-07-14 08:33 UTC | 1.21.1 | +2/−2 lines, 1 filesdep ~hashablePVP ok |
| 2024-06-18 07:20 UTC | 1.21 | +6/−117 lines, 18 filesPVP ok |
showing 5 of 88 versions
tasty >=1.2.3 && <2 1.5.4 → 1.5.5
| 2026-10-20 23:13 UTC | 1.5.5 | +53/−26 lines, 7 filesdep +terminal-sizePVP ok |
| 2026-03-25 20:04 UTC | 1.5.4 | +332/−166 lines, 22 filesdep −semigroupsPVP ok |
| 2025-01-05 19:52 UTC | 1.5.3 | +36/−11 lines, 3 filesdep ~containersdep ~optparse-applicativePVP: major bump suggested |
| 2024-11-03 00:34 UTC | 1.5.2 | +22/−5 lines, 4 filesdep ~basePVP ok |
| 2024-06-22 10:14 UTC | 1.5.1 | +131/−63 lines, 10 filesdep ~basePVP: major bump suggested |
showing 5 of 76 versions
tasty-quickcheck >=0.11 && <0.12 0.11 → 0.11.1
| 2025-01-05 19:53 UTC | 0.11.1 | +66/−33 lines, 4 filesdep +regex-tdfadep −pcre-lightdep ~QuickCheckdep ~basedep ~optparse-applicativePVP: major bump suggested |
| 2024-06-22 10:14 UTC | 0.11 | +132/−49 lines, 4 filesdep ~QuickCheckPVP ok |
| 2023-09-10 00:10 UTC | 0.10.3 outside bounds | +52/−14 lines, 3 filesdep ~QuickCheckdep ~optparse-applicativedep ~randomnew-uploaderPVP ok |
| 2021-11-20 19:17 UTC | 0.10.2 outside bounds | +21/−13 lines, 3 filesdep ~basePVP: major bump suggested |
| 2020-12-18 09:42 UTC | 0.10.1.2 outside bounds | +27/−13 lines, 4 filesdep ~basePVP: major bump suggested |
showing 5 of 23 versions
text >=1.2 && <2.2 2.1.4 → 2.1.5
| 2026-11-27 23:30 UTC | 2.1.5 | +33786/−32979 lines, 58 filesPVP: major bump suggested |
| 2026-01-28 08:30 UTC | 2.1.4 | +30991/−20199 lines, 35 filesdep +template-haskell-liftdep ~QuickCheckdep ~template-haskellPVP ok |
| 2025-08-01 20:08 UTC | 2.1.3 | +2107/−1827 lines, 30 filesdep +splitmixdep +temporarydep ~QuickCheckdep ~ghc-primdep ~template-haskellPVP ok |
| 2024-10-26 13:22 UTC | 2.1.2 | +43588/−15378 lines, 41 filesdep ~basedep ~binaryPVP: major bump suggested |
| 2024-02-16 22:16 UTC | 2.1.1 | +986/−412 lines, 26 filesdep ~QuickCheckdep ~ghc-primdep ~template-haskellPVP: major bump suggested |
showing 5 of 83 versions
unordered-containers >=0.2 && <0.3 0.2.21 → 0.2.21.1
| 2026-11-30 10:13 UTC | 0.2.21.1 | +533/−177 lines, 9 filesPVP: major bump suggested |
| 2025-12-13 23:09 UTC | 0.2.21 | +3999/−2731 lines, 20 filesdep −mtldep ~basedep ~bytestringdep ~deepseqPVP: major bump suggested |
| 2025-10-02 07:28 UTC | 0.2.20.1 | +106/−52 lines, 12 filesPVP: major bump suggested |
| 2024-01-09 06:48 UTC | 0.2.20 | +1023/−941 lines, 12 filesdep ~hashabledep ~template-haskellPVP: major bump suggested |
| 2022-04-24 15:48 UTC | 0.2.19.1 | +88/−14 lines, 4 filesdep ~basedep ~template-haskellPVP: major bump suggested |
showing 5 of 44 versions
vector >=0.12 && <0.14 0.13.1.0 → 0.13.2.0
| 2024-10-31 18:01 UTC | 0.13.2.0 | +5177/−672 lines, 53 filesdep −HUnitdep ~QuickCheckdep ~basedep ~doctestPVP: major bump suggested |
| 2023-10-07 13:35 UTC | 0.13.1.0 | +302/−238 lines, 22 filesdep ~QuickCheckdep ~basedep ~doctestnew-uploaderPVP: major bump suggested |
| 2022-06-19 19:35 UTC | 0.13.0.0 | +19079/−19259 lines, 70 filesdep +tasty-benchdep +tasty-inspection-testingdep +vector-streamdep −faildep −ghc-primdep −semigroupsdep ~basedep ~doctestdep ~primitivePVP ok |
| 2021-09-21 16:21 UTC | 0.12.3.1 | +265/−191 lines, 13 filesdep ~basedep ~deepseqdep ~doctestPVP ok |
| 2021-04-06 19:54 UTC | 0.12.3.0 | +1218/−39 lines, 11 filesdep ~basedep ~ghc-primPVP ok |
showing 5 of 43 versions
Reverse dependencies
2 packages depend on lawful-conversions; 1 have bounds that exclude 0.4.0
xml-types-content 0.0.1.1 requires lawful-conversions >=0.1.5 && <0.2 excludes current (upper bound)