-
Notifications
You must be signed in to change notification settings - Fork 74
Show Instance for CodePoints #93
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
Conversation
src/Data/String/CodePoints.purs
Outdated
@@ -50,6 +50,9 @@ newtype CodePoint = CodePoint Int | |||
derive instance eqCodePoint :: Eq CodePoint | |||
derive instance ordCodePoint :: Ord CodePoint | |||
|
|||
instance showCodePoint :: Show CodePoint where | |||
show cp = "(CodePoint " <> show (singleton cp) <> ")" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This instance should definitely exist, but I think it would be better to print the contained Int
in hex format. Do you know if that's possible now, or will we need to add a dependency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://pursuit.purescript.org/packages/purescript-integers/3.2.0/docs/Data.Int#v:toStringAs would do the trick. I think, there is an advantage of displaying the Unicode representation. Maybe a combined version?
(CodePoint 0x... - "∆")
. That way you can see if you have chosen the correct number for the symbol you wanted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be best to just use the Int
, to keep it simple, and to avoid suggesting that there's anything more to a CodePoint
than just an Int
. People can use singleton
if they want to see the code point as a string.
Great, thanks! There's just a few things I'd like to be done before merging:
|
Thank you! |
this is useful for creating examples for the documentation