[erlang-questions] How to define non_neg_float() type specification?

Motiejus Jakštys desired.mta@REDACTED
Fri Sep 28 09:21:17 CEST 2012


On Thu, Sep 27, 2012 at 09:32:47AM -0700, Stavros Aronis wrote:
> Hello!
> 
> Unfortunately Dialyzer does not support it (even constants are generalized 
> to any float, typwise). Consequentially, the type language does tnot 
> support it. 

Eh.. Erlang looks so close to having guards in type specs. Wouldn't that
be cool?

> This will help you documentation-wise and also (though in a somewhat 
> limited way) Dialyzer-wise. If you use this type PropEr-wise however, you 
> will get positive values, which you will need to filter...

Even better, just abs(It) :)

    ?LET(It, float(), abs(It)).

Regards,
Motiejus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120928/290f6198/attachment.bin>


More information about the erlang-questions mailing list