My function has 1 parameter and type is string but lenght is 4, Can I validate this parameter in compile time?
In haskell and F# have type level and it can validation in compile time, like nonEmptyList.
How to make it in scala. I think shapless can do this but I don't understand
Thank you for advance suggestion
Yes, Shapeless can do this. Perhaps something like this:
def f(s: Sized[IndexedSeq[Char], Nat._4]): ...
You wouldn't be able to pass strings directly to this, though. You'd have to do something like f(Sized('a', 'b', 'c', 'd'))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With