You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
there are situations, where enum want to be used not as an complex ADT:
enum Complex:
case First(value: Int)
case Second
but rather as a simple enum, where variants don't have any arguments:
enum Simple:
case First, Second
It would be handy if one can derive type class for enum that is compile time ensured to be simple:
object Show extends SimpleSumDerivation[Show] {
inline def split[DerivationType : SimpleSumReflection]: Show[DerivationType] = value =>
???
}
in this case SimpleSumDerivation doesn't need a join method, since we exclude Product and the compiler should not be able to find or construct given for Show[Complex]
What I want to achieve with this idea:
don't force type class author to implement Product related logic, when they only want to derive type class for simple enum
compile time restrict "end"(wistreria -> type class author -> end user writing business logic) users to do summon[Show[Complex]] when the type class implementation is not intended for complex enums
Is it even possible, I would imagine we will need to implement some sort of compile time constraint in a form of IsSimpleSum[T: SumReflection]?
What do you think about this idea?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
there are situations, where enum want to be used not as an complex ADT:
but rather as a simple enum, where variants don't have any arguments:
It would be handy if one can derive type class for
enum
that is compile time ensured to be simple:in this case
SimpleSumDerivation
doesn't need a join method, since we excludeProduct
and the compiler should not be able to find or construct given forShow[Complex]
What I want to achieve with this idea:
Product
related logic, when they only want to derive type class for simpleenum
summon[Show[Complex]]
when the type class implementation is not intended for complex enumsIs it even possible, I would imagine we will need to implement some sort of compile time constraint in a form of
IsSimpleSum[T: SumReflection]
?What do you think about this idea?
Beta Was this translation helpful? Give feedback.
All reactions