Our great sponsors
-
ttc
Textual Type Classes - a Haskell library for conversion between data types and textual data types
-
WorkOS
The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.
I had not come across your witch package before. Thank you very much for letting me know about it! I will add it to the related work section of the TTC README.
The witch package provides type classes for converting between arbitrary types: text, numbers, and anything else that people create instances for. It is therefore much more broadly applicable compared to TTC, which only works with text. I really appreciate that both a From type class (for conversion without failure) and a TryFrom type class (for conversion that may fail) are used, and the implementation looks very convenient. I will remember this project and use it when I have a suitable application in the future.
I have done a lot of CSV development! I usually use the cassava library, though I have my own library as well. The cassava library uses FromRecord, FromNamedRecord, ToRecord, and ToNamedRecord type classes for parsing and rendering records, and it uses FromField and ToField type classes for parsing and rendering fields. An identifier type like the UserName example above should declare instances for FromField and ToField in order to be used in CSV files. For types that have appropriate Render and Parse instances, I implement general functions named something like parseFieldWithTTC and toFieldWithTTC, which allows me to declare instances as follows: