Comments (5)
So this is a known breaking change in 0.3.0. since the old interface exposed some partial functions which would fail on encoding errors.
The principled fix would be to go through your codebase and replace all type errors with the function that explicitly handles the UnicodeException
with Either.
decodeUtf8' :: ByteString -> Either UnicodeException Text
The less principled fix is to use old interface Protolude.Conv
which is left as a compatability layer but it is silently partial. So your business logic may blow up if you pass it malformed strings. Thus the fix in this release.
from protolude.
I understand (I think), but that only really addresses the third point in the list, right? It seems unfortunate that easy ways to encode to UTF8 or to convert between lazy and strict bytestrings were lost.
I'm wondering now whether instances ConvertText _ ByteString
would be an option. Though I realize that UTF8-encoded text is not what's understood to be text in the current sense of ConvertText
.
from protolude.
I suppose the lazy to strict bytestring conversion exposes potential partiality, but the strict to lazy bytestring should always be safe. I'll look to restoring those to the TextConvert class.
from protolude.
The loss of ConvertText Text ByteString
is quite sad, what was partial about that conversion?
from protolude.
ConvertText Text ByteString
would use encodeUtf8 which is non-partial.
Similarly, the following instances could be added as well:
ConvertText Text ByteString
ConvertText String ByteString
ConvertText Lazy.Text ByteString
ConvertText Text Lazy.ByteString
ConvertText String Lazy.ByteString
ConvertText Lazy.Text Lazy.ByteString
As a convenience, there's definitely merit, but I'm not sure if it would be confusing that you can convert to a ByteString
, but not from one using ConvertText
. In that way, ConvertText
is not sufficient for working with ByteString
to Text
/ String
conversions.
I'm not sure what the original intention was here (beyond removing the partial function decodeUtf8
which can cause nasty bugs).
I'm inclined to add the above instances back in. In the meantime, there is toUtf8
and toUtf8Lazy
.
from protolude.
Related Issues (20)
- (<<*>>) needs a fixity declaration
- Haddocks are not very discoverable HOT 1
- Missing `Symbols.md` file HOT 2
- Please support GHC 8.8
- Generalizing list functions HOT 2
- Partial functions `minimum` and `maximum` are exported by Protolude HOT 1
- Generate a list of everything Protolude exports HOT 4
- Release 0.3.0 to hackage? HOT 7
- isSuffixOf to accompany isPrefixOf HOT 1
- Documentation: Gap in link on Hackage HOT 1
- GHC 9.0 & 9.2 support in new Hackage release HOT 16
- Compatibility with transformers-0.6 / transformers-compat-0.7 HOT 3
- FR: `panic` to print multiline messages
- This is the worst library I ever use
- Add missing Git tags for versions 0.3.0, 0.3.1, and 0.3.2 HOT 2
- Add support for ghc-9.8 HOT 2
- how to disable trace warning ? HOT 1
- is readme's warning about haddock obsolete ? HOT 1
- Potential unsafety of Data.Text.IO functions HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from protolude.