Comments (11)
Re-exporting fromString
sounds like a great idea to me.
from basic-prelude.
fromString
sounds like the right solution, though it always scares me because of broken instances like the Bytestring.Char8
one.
from basic-prelude.
Alternatively I thought it could be nice to have a custom ToText
typeclass with a toText
function and instances for all the exported types for which it makes sense. This way besides solving the current issue it would make it easy to convert to text from all kinds of ByteString
and etc., which in my experience is a very common problem.
from basic-prelude.
http://hackage.haskell.org/packages/archive/text-format/0.3.0.8/doc/html/Data-Text-Buildable.html
from basic-prelude.
@nikita-volkov BTW, you cannot safely convert from ByteString
to Text
in the same way you can convert other types to Text
, because to convert ByteString
you must specify an encoding.
from basic-prelude.
+1 for including fromString
, and possibly IsString
as well. But I don't like the idea of adding any custom typeclasses to basic-prelude
: I think the goal of basic-prelude
should be, as much as possible, to reuse existing typeclass infrastructure, not create new, incompatible typeclasses.
from basic-prelude.
@singpolyma Yes, but I think decodeUtf8
would have covered most cases, since UTF8 is already a de facto standard. In other situations people are always free to make specific imports.
@snoyberg Yes, it's good that you have some groundrules behind the design of the package. What could be done is creating a third version of Prelude on top of BasicPrelude, which won't have these restrictions. Of course it wouldn't make much sense to do such thing just for a single class right now, so I just want you to consider it as a possiblity for future, when some similar requirements arise for other features.
from basic-prelude.
I'd say that classy-prelude is the place for that kind of stuff for me. But for people looking for a non-classy approach, there should certainly be another package available. And that's one of the main goals of basic-prelude: making it easy to create new preludes.
For the record, I really dislike the partial nature of decodeUtf8. I consider it to be a major bug in text
actually. (Though it's the only misfeature I know of there.)
from basic-prelude.
Okay.
Partial nature - what's that?
from basic-prelude.
The following program:
{-# LANGUAGE OverloadedStrings #-}
import Data.Text ()
import Data.Text.Encoding
import Data.ByteString.Char8 ()
main = print $ decodeUtf8 "\192"
produces:
Cannot decode byte '\xc0': Data.Text.Encoding.decodeUtf8: Invalid UTF-8 stream
from basic-prelude.
Oh.. Okay. Thank you
from basic-prelude.
Related Issues (20)
- Export Arrow combinators HOT 7
- empty clashes with Control.Applicative HOT 5
- Export `printf` for `Text`
- Export `Data.Text.Encoding` HOT 4
- Export IOError in CorePrelude HOT 1
- Restrict to packages portable across GHCs?
- CorePrelude doesn't export any instances for LText and LByteString HOT 3
- Extended Kleisli combinators HOT 3
- Better exception handling HOT 8
- Export IsList HOT 2
- Lazy versions don’t export instances HOT 2
- Export Foldable and Traversable HOT 10
- Text version of error? HOT 10
- `asum` missing HOT 7
- ‘show’ is not a (visible) method of class ‘Show’ HOT 4
- Provided ``sum`` is not general enough HOT 4
- Export `for`, `for_`, `traverse_` and `sequenceA_` HOT 1
- Generalize `concat`, `concatMap` and `intercalate`? HOT 5
- Strict `minimum`, `maximum`, `minimumBy` and `maximumBy`? HOT 2
- `MonadIO` for all read*, get* and put*? 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 basic-prelude.