4 ms·
Can you elaborate? Perhaps you are talking about the Char8 ByteString instance? It was a mistake to declare that instance, I think.
by hesselink 13y ago
Can you elaborate? Perhaps you are talking about the Char8 ByteString instance? It was a mistake to declare that instance, I think.
- chongli 13y agoPerhaps you are talking about the Char8 ByteString instance? Yes. Data.ByteString.Char8.pack does not form an isomorphism with Data.ByteString.Char8.unpack. It is thus not interchangeable with String. Example: Prelude Data.ByteString.Char8> putStrLn . unpack . pack $ "Российская Федерация" >AA89A:0O $545@0F8O And here the correct result with Data.Text: Prelude Data.Text> putStrLn . unpack . pack $ "Российская Федерация" Российская Федерация
- startling 13y agoThat's an issue with Data.ByteString.Char8, not with OverloadedStrings.
- chongli 13y agoWhen you use OverloadedStrings in conjunction with Data.ByteString.Char8 it becomes OverloadedStrings' issue as well. Compile-time transformations are not supposed to break your program.
- tel 13y agoI don't think of it as a compile-time transformation but instead a weakening of the semantics of string literals. Without we have "foo" :: String and with we have "foo" :: IsString a => a much like 3 :: Num a => a It inherits all of the same weaknesses and strengths that we have with the Num typeclass.
- chongli 13y agoAhh, very good. Then perhaps our target of inquiry ought to be the IsString class. Ought it have some laws we can expect instances to follow, akin to the Monad laws? At the moment, we can write: instance IsString () where fromString = const () And there's nothing wrong with it!
- tel 13y agoTotally agree that it's a weak class. I'd love it if `IsList` were a subclass of `Foldable`!