-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
[#51] Ability to print message with any rgb color #53
base: main
Are you sure you want to change the base?
Conversation
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.
Hey @dariodsa ,
Thanks a lot for your contribution!
I have a few comments/ideas I would like to discuss about this solution.
First of all, I see that the rgbMessage
takes a String
. I would propose to take 3 Word8
arguments instead and leave all the colour handling to the sRGB24
function of the package.
Also, Haskell supports Hex numbers on a lexical level, so no need to implement a parser here, it should be possible to write 0x...
. 🙂
Also, I don't think that the incorrect colour should lead to error
. We need to think better, what to do in this case. Maybe just warning and uncoloured text? 🤔
Thank you @vrom911 for your comments. Indeed, code now looks much more concise. 😄
So, now when someone tries to run a function with too high or too low literals, Haskell simply cuts its value and continue using it like it is
|
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.
Hey @dariodsa, the implementation looks good 👍🏻 I left a few comments with some remaining improvements. And I think that relying on GHC warnings (overflow literals specifically) is a good way to go.
Ideally, for the best UI, we would like to have a compile-time compilation and allow literals only of the form 0xABCDEF
but there's no easy way to achieve this in Haskell without requiring some heavyweight machinery. So API like rgbMessage 0x00 0x00 0xff
looks good for me 👍🏻
Hey, @dariodsa. I see there are still some conflicts in this branch with the |
Hey @dariodsa! The changes in this PR look great 👍🏻 Thanks for resolving conflicts! I see, that the code mentions the |
Files changed
colourista.cabal
src/Colourista/IO.hs
src/Colourista/Pure.hs
New behaviour
Added ability to print message using any colour which can be expressed using classic RGB representation (HEX values). If user provides a hex value with a length lower than 6, that value will be truncated with leading zeroes. So
ff
will produce a blue colour.Test
If the PR is going to be accepted, afterwards I can update
README.md
to point the users to the new feature.