-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why does showTextData
convert everything to lower case
#82
Comments
There cannot be a bijection (because not every readTextData . showTextData == Right -- does not hold: showTextData does lowercasing
I can't recall it now, but think the reasoning was that
You're right, naming is a bit misleading (although I have tried to make documentation clear 😄 ). Functions that do have the property you are looking for are
readTextData . showt == Right
readTextData . Text.pack . show == Right Examples: >>> quickCheck (\x -> readTextData (showt (x :: String)) == Right x)
+++ OK, passed 100 tests. data Person = Person { fullName :: String, age :: Int } deriving (Eq, Show, Read)
instance Arbitrary Person where arbitrary = Person <$> arbitrary <*> arbitrary >>> quickCheck (\x -> readTextData (Text.pack (show (x :: Person))) == Right x)
+++ OK, passed 100 tests. |
You are right that it's not a bijection, faithful serialization I guess is what i'm after. I ended up reading the docs after the fact and discovered my mistake, but initially I just noticed the existence of
|
Would you do the honours? 😊 |
I was hoping
readTextData
andshowTextData
would form a nice bijection, so that I could easily derive the ability to send my custom types over the wire without too much thought, but for some reasonshowTextData
converts everything to lower case, causingreadTextData
to fail.What is the reasoning behind this? IMO the naming is a little misleading and error prone.
The text was updated successfully, but these errors were encountered: