Add an API for if with other types than native booleans #17854
RubenVerg started this conversation in Feature Requests
Replies: 0 comments
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Provide a typeclass called something like
If, taking a single type parameterA: a condition of the typeAwould call the instanceIf[A].IforIf[A].IfElse. This can be used both as a conversion toBooleanthat only works inifs (eg:) or for a completely unrelated usage to standard
if, eg in DSLs:This implies that the
if/elsecondition doesn't necessarily return one ofTorF, since in this specific usage (the one that led me to the suggestion)igmIfBuildandigmIfElseBuildinspect branches to "flatten" if/else clauses into a singleif/else if/else if/else/endclause (this is an internal to external DSL thing).In the case the condition in the
if(call itA) isn'tBooleanand there is noIf[A], try looking for aConversion[A, Boolean], and only if it doesn't exist, and there's a singleConversion[A, B]andIf[B], convert toB.BetaWas this translation helpful?Give feedback.
All reactions