-
-
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
[RFC] Ability to disable and enable colouring #26
Comments
An alternative solution is to use the reflection for this purpose. It's similar to How to implement?
formatWith
:: (Reifies s ColourMode, IsString str, Semigroup str)
=> [str]
-> str
-> str
formatWith formatting str = case formatting of
[] -> str
x:xs -> withColourMode @s (sconcat (x :| xs)) <> str <> withColourMode @s reset Costs of implementation
ConclusionAfter looking at the reflection package, I came to the conclusion that its primary usage is constraint of some typeclasses where you want typeclasses to depend on some runtime data. This is not our case, so ImplicitParams should work just fine 👍 Alternative ideasWe can skip step |
Thanks for such detailed analysis and overview, @chshersh ! 🧠 🎉 |
The implementation was reverted due to a bug in GHC and not reliable behaviour. |
It would be nice if
colourista
could support automatic disabling and enabling of colouring, so we can easily disable/enable colours in our code. We want to have a solution that satisfies the following requirements:I'll describe one possible solution below.
-XImplicitParams
One way to do this is to use the
ImplicitParams
Haskell language extension. It contains the following parts:EnableColour
default:Cons and pros
Implementation cost: patch each function.
Pros:
--no-colour
option or something like this.Cons
HasColourMode
constraint.Additionally we need to add tests for this:
The text was updated successfully, but these errors were encountered: