How to typespec a float range in Elixir?

Yes, it is impossible in current typespecs language. Dialyzer will reduce complexity of every integer range typespec into integer() during checking (that’s how dialyzer works). So you can just write float() with a comment next to it (like float() # from 1.0 to 2.0) without any significant impact on type checking.

1 Like