{"id":17099994,"url":"https://github.com/bergmark/through-text","last_synced_at":"2025-03-23T18:28:14.295Z","repository":{"id":31450381,"uuid":"35014186","full_name":"bergmark/through-text","owner":"bergmark","description":"Convert textual types to, from, and through(!) Text without needing O(n^2) instances","archived":false,"fork":false,"pushed_at":"2021-12-26T22:57:42.000Z","size":18,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-24T08:29:26.179Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bergmark.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-04T04:33:45.000Z","updated_at":"2021-12-26T22:57:45.000Z","dependencies_parsed_at":"2022-08-20T23:40:19.371Z","dependency_job_id":null,"html_url":"https://github.com/bergmark/through-text","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bergmark%2Fthrough-text","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bergmark%2Fthrough-text/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bergmark%2Fthrough-text/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bergmark%2Fthrough-text/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bergmark","download_url":"https://codeload.github.com/bergmark/through-text/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245147881,"owners_count":20568583,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T15:11:55.828Z","updated_at":"2025-03-23T18:28:14.263Z","avatar_url":"https://github.com/bergmark.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![through-text](https://budueba.com/hackage/through-text)](https://hackage.haskell.org/package/through-text)\n[![Build Status](https://travis-ci.org/bergmark/through-text.svg?branch=master)](https://travis-ci.org/bergmark/through-text)\n\nThis is a small package defining two typeclasses `ToText` and\n`FromText`. It's meant to be used in normal cases where you have some\ncontrol over data, hence UTF-8 is assumed for all types.\n\nCurrently supported packages are `text`, `bytestring`, and\n`case-insensitive`, and `String` from `base` of course!\n\nYou can define `FromText` instances that may fail as `FromText (Maybe a)`.\n\nThere are alse type aliases `StrictText`, `LazyByteString` et.c. so\nyou don't need to import them yourself, it also makes code easier to\nread than if you import `Text` unqualified.\n\nConversions from bytestrings use\n[lenientDecode](http://hackage.haskell.org/package/text-1.2.0.4/docs/Data-Text-Encoding-Error.html#v:lenientDecode)\nwhich replaces invalid characters with U+FFFD.\n\nThere are identity instances for `StrictText`. They allow you to use\n`throughText` instead of `toText` and `fromText` when working with\n`StrictText` itself. It is not meant as an encouragement to use type\nclass constraints such as `ToText a =\u003e a -\u003e IO ()` in function\nsignatures, I instead recommend using the actual type you want.\n\n## Motivation\n\nIn practice I've found that most textual conversions I do are just to\nglue packages together. I either know or am satisfied with assuming\nthat the encoding is UTF-8 and I don't really care about the types\ninvolved.\n\nWe should be using `Text` as the default textual type instead of\n`String`. [tostring](https://www.hackage.org/package/tostring)\ntogether with `Data.String.IsString` otherwise accomplishes the same\ngoal. A current advantage of using `String` is that you do not need to\nenable `OverloadedStrings` for literals.\n\nMulti-parameter type classes easily leads to ambiguity and leads to\nO(n^2) instances if you want to convert between every type.\n[string-conversions](https://www.hackage.org/package/string-conversions)\nimplements this idea with the benefit that you have to pay even less\nattention of what types you are converting.\n\nIn most use sites conversions are total, encoding this possibility in\nthe type class leads to partial functions or the need to handle\nimpossible failures.\n[convertible](https://www.hackage.org/package/convertible) throws an\nexception if a failure occurs.\n\nI don't want conversions from types just because they have a textual\nrepresentation such as `ToText Int` - most types have one after\nall. It's unclear whether you want a pretty printed or structually\nfocused result. `Show` already suffers this conflict.\n\n\n## Will instances for great-package be added?\n\nOnly if it's a popular library with no more than a couple of (new)\ndependencies.  If you ask I will either accept or guarantee to do a\nmajor version bump should I change my mind\n([so you don't need to depend on a minor version](https://wiki.haskell.org/Package_versioning_policy)\n\nFor that reason I added\n`[case-insensitive](https://www.haskell.org/package/case-insensitive)`,\nit's a very useful package with only a one-module dependency\n(`hashable`).\n\n## When to avoid this library\n\nIf you don't know the encoding you should explicitly use other\nlibraries e.g. [text-icu](https://www.hackage.org/package/text-icu).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbergmark%2Fthrough-text","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbergmark%2Fthrough-text","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbergmark%2Fthrough-text/lists"}