Search Haskell Channel Logs

Sunday, March 5, 2017

#haskell channel featuring dmwit, jle`, xcmw, geekosaur,

jle` 2017-03-05 15:23:08
hello all
jle` 2017-03-05 15:23:24
is there any way to invoke haddock and have it build other-modules/internal modules, as well?
xcmw 2017-03-05 15:23:32
What is the best way to convert a lazy byte string from Data.Binary to Text?
dmwit 2017-03-05 15:23:55
What encoding is it in?
jle` 2017-03-05 15:24:23
xcmw: check out the functions in this module http://hackage.haskell.org/package/text-1.2.2.1/docs/Data-Text-Lazy-Encoding.html
jle` 2017-03-05 15:24:26
one of them might be what you want
xcmw 2017-03-05 15:24:31
dmwit: I don't think it has an encoding
dmwit 2017-03-05 15:24:40
I don't think it's Text, then.
jle` 2017-03-05 15:24:54
is it just a bunch of bits?
dmwit 2017-03-05 15:25:11
Also I'm a bit confused about how Data.Binary is playing into things here.
jle` 2017-03-05 15:25:34
it's probably a bytestring that they're getting from functions in Data.Binary
xcmw 2017-03-05 15:25:51
jle`: Yes
jle` 2017-03-05 15:25:55
but yeah, Text is only meant to represent text. it's not really meant to represent random jumbles of bits
jle` 2017-03-05 15:26:12
if the bytestring doesn't represent text, then you probably don't want Text
jle` 2017-03-05 15:26:23
maybe you want to display it in a nice way, like a base-64 encoding?
jle` 2017-03-05 15:26:40
or a hexadecimal represnetation?
dmwit 2017-03-05 15:26:48
Oh, like, this ByteString is the output of an encoding operation?
xcmw 2017-03-05 15:27:02
jle`: I don't need it to be readable I just need to convert between them
geekosaur 2017-03-05 15:27:04
xcmw, what are you intending to do with this data?
xcmw 2017-03-05 15:33:16
geekosaur: decodeUtf8 and encodeUtf8 work from Data-Text-Lazy-Encoding
dmwit 2017-03-05 15:33:23
nooooo
geekosaur 2017-03-05 15:33:30
no, they won;t work for all inpiut data
geekosaur 2017-03-05 15:33:40
btu if you like occasionally losing completely, go ahead
geekosaur 2017-03-05 15:33:51
because you *will* get corruption at some point
geekosaur 2017-03-05 15:34:08
something will apply unicode normalization and *boom*
dmwit 2017-03-05 15:34:21
xcmw: For what it's worth, I find it odd that you are taking such a circuitous route. Why are you making a Binary instance, then trying to convert to Text, then converting to JSString? Why not just directly make instances of ToJSString and FromJSString for your types?
dmwit 2017-03-05 15:35:15
geekosaur: Or even before that, he'll pass in some bytes that aren't valid UTF8.
geekosaur 2017-03-05 15:35:40
depends on exactly how they are abusing those functions
geekosaur 2017-03-05 15:36:01
you can feed binary data to something that encodes iso8859 to utf8