I'm looking to use the new erlang maps in a project, but I want to make sure to properly -spec everything I do. So my question is, what's the syntax for this? Is there anything like there is for records where I can specify field types? Or do I just use map() (and is that even the correct type spec?)
Yes, map() is one way to specify a map type. Another is #{}, which like map() means a map of any size. You can also specify #{ Type => Type } with one or more Type => Type pairs, as described in the Erlang Types and Function Specifications page. Also, have a look at the can_pkt() type in the source code for the maps1 test in the Erlang source code, as that specifies a record-like map type.
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