I've never thought about this before. Is it really valid to have a NUL in the middle of a Text?
-
-
Yes, \NUL isn't any different than \n or \r. C's null terminated strings (which could be ascii, ansi, utf8...) are encoding layer on top. Pascal had length-annotated slices: no problem. Text is also ptr+offset+length.
1 reply 0 retweets 3 likes -
And even after knowing and appreciating this, we still can't use QC with pg-simple with minimal friction. Thus, my original comment.
2 replies 0 retweets 0 likes -
And I still think your record should have non-Text fields. With GeneralizedNewtypeDeriving it's quite handy to generate most of needed instances, and then manually tweak the rest. Also giving domain specific names to text manipulation helpers will help in the long run.
2 replies 0 retweets 2 likes -
Is this a strong *recommendation*? Can you point me to a largish codebase that has newtypes for most domain specific Texts? I ask because we tried with EmailAddress i our codebase and aren't really happy with how it turned out. Need to learn how to do this.
2 replies 0 retweets 0 likes -
Replying to @saurabhnanda @phadej and
I newtyped a lot of the text and bytestring values in the work code base. it found a bug and made the type signatures vastly easier to read.
1 reply 2 retweets 3 likes -
Replying to @mattoflambda @phadej and
Is there an effective way to deal with the boilerplate that ensues when you want to use regular library functions that don't know about your newtype?
2 replies 0 retweets 0 likes -
Replying to @saurabhnanda @phadej and
I just write the boilerplate. It's not much and it's clearer than any metaprogramming approach would be. The newtype class in lens is good
2 replies 0 retweets 2 likes -
Replying to @mattoflambda @saurabhnanda and
If you have an EmailAddress value and you want its corresponding Text value, I'm not convinced that applying a function that converts EmailAddress to Text is 'boilerplate', I think that's just code
1 reply 1 retweet 2 likes -
Replying to @chris__martin @mattoflambda and
I'm not sure I agree *right now* (with the experience I have writing Haskell). If the underlying Text value is easily accessible then it *will* be unwrapped and passed around by other newbies.
3 replies 0 retweets 0 likes
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.