lawful-conversions
Version 0.1.2.1 revision 0 uploaded by NikitaVolkov.
Package meta
- Synopsis
- Lawful typeclasses for bidirectional conversion between types
- Description
Summary
Lawful typeclasses capturing three patterns of bidirectional mapping and forming a layered hierarchy with an ascending strictness of laws.
The conversion problem
Have you ever looked for a
toString
function? How often do you importData.Text.Lazy
only to call its Data.Text.Lazy.fromStrict? How about importingData.ByteString.Builder
only to call its Data.ByteString.Builder.toLazyByteString and then importingData.ByteString.Lazy
only to call its Data.ByteString.Lazy.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.
Prior work and acknowledgements
This library is a direct successor of the "isomorphism-class" library, expanding upon the patterns discovered there. It also shares some ideas with "control-iso" and "type-iso".
- Author
- Nikita Volkov <nikita.y.volkov@mail.ru>
- Bug reports
- https://github.com/nikita-volkov/lawful-conversions/issues
- Category
- Conversion
- Copyright
- (c) 2022 Nikita Volkov
- Homepage
- https://github.com/nikita-volkov/lawful-conversions
- Maintainer
- Nikita Volkov <nikita.y.volkov@mail.ru>
- Package URL
- n/a
- Stability
- n/a