Understanding Erlang types with type variables

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Understanding Erlang types with type variables

Athanasios Valsamakis

In Erlang, you can have a (generic) type declaration parameterized with type variables e.g.

-type dict(K, V) :: [{K,V}].

K, V are type variables i.e. they can be replaced in subsequent type declarations or function specifications with concrete types. E.g.

-type catalog() :: dict(string(), integer()). 

Here K is replaced with type string(), and V with type integer(). Or, it can be used in function specifications e.g.

-spec find(string(), dict(string(), any())) -> any().

Is it correct?



_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions
Reply | Threaded
Open this post in threaded view
|

Re: Understanding Erlang types with type variables

Karlo Kuna
yes this is correct

On Wed, Feb 21, 2018 at 11:39 AM, Athanasios Valsamakis <[hidden email]> wrote:

In Erlang, you can have a (generic) type declaration parameterized with type variables e.g.

-type dict(K, V) :: [{K,V}].

K, V are type variables i.e. they can be replaced in subsequent type declarations or function specifications with concrete types. E.g.

-type catalog() :: dict(string(), integer()). 

Here K is replaced with type string(), and V with type integer(). Or, it can be used in function specifications e.g.

-spec find(string(), dict(string(), any())) -> any().

Is it correct?



_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions



_______________________________________________
erlang-questions mailing list
[hidden email]
http://erlang.org/mailman/listinfo/erlang-questions