I'm using the NonEmptyString
type from the refined library. When concatenating two strings, at least one of which is non-empty, the result is obviously another non-empty string. But is there a way to convince the Scala compiler of this fact without using unsafe methods such as NonEmptyString.unsafeFrom
?
Asked
Active
Viewed 170 times
5

Matthias Berndt
- 4,387
- 1
- 11
- 25
-
2Not really AFAIK, the best you can do is create your own extension methods so that the cast is done in one place only. – Luis Miguel Mejía Suárez Mar 09 '23 at 13:05
-
3https://github.com/fthomas/refined/issues/217 – Dmytro Mitin Mar 09 '23 at 20:35
-
1https://gist.github.com/notthatbreezy/ed9fb4fa5edc066bf7706d8b8333cdd2#scala-practical-guide – Dmytro Mitin Mar 09 '23 at 21:06