chimney
chimney copied to clipboard
Transform into singleton types
Currently the only kinds support for singleton types we have are:
-
case object
s (Scala 2 & 3) and parametherlessenum
case
s (Scala 3) - filling
Unit
as constructor parameter/setter - filling
None
as constructor parameter/setter if we enable it with a flagenableOptionDefaultsToNone
We could allow transformting into/filling automatically any literal singleton types (e.g. String
s, Int
s, etc literal types), since there is only 1 possible value that can be filled and we know exactly what's that value is.
Implementation would require:
- creating new datatype in chimney-macro-commons
- implementing macros (2.12/2.13/3) which would check that a type is singleton type
- implementing new rule
- testing
- checking that this new rule is not colliding with existing rules (e.g. we explicitly ignore
None
in some methods, so perhaps we should ignore some singleton types or only support primitives literals: Unit/String/Int/numerical types)