aboutsummaryrefslogtreecommitdiffstats
path: root/lib/edoc/test/edoc_SUITE_data/map_module.erl
blob: f242721637f0a01943fc30e581b5b2b5e3341088 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
-module(map_module).

-export([foo1/1,foo2/3,start_child/2]).

%% @type wazzup() = integer()
%% @type some_type() = map()
%% @type some_other_type() = {a, #{ list() => term()}}

-type some_type() :: map().
-type some_other_type() :: {'a', #{ list() => term()} }.
-type wazzup() :: integer().

-spec foo1(Map :: #{ 'a' => integer(), 'b' => term()}) -> term().

%% @doc Gets value from map.

foo1(#{ a:= 1, b := V}) -> V.

%% @spec foo2(some_type(), Type2 :: some_other_type(), map()) -> Value
%% @doc Gets value from map.

-spec foo2(
    Type1 :: some_type(),
    Type2 :: some_other_type(),
    Map :: #{ get => 'value', 'value' => binary()}) -> binary().

foo2(Type1, {a,#{ "a" := _}}, #{get := value, value := B}) when is_map(Type1) -> B.

%% from supervisor 18.0

-type child()    :: 'undefined' | pid().
-type child_id() :: term().
-type mfargs()   :: {M :: module(), F :: atom(), A :: [term()] | undefined}.
-type modules()  :: [module()] | 'dynamic'.
-type restart()  :: 'permanent' | 'transient' | 'temporary'.
-type shutdown() :: 'brutal_kill' | timeout().
-type worker()   :: 'worker' | 'supervisor'.
-type sup_ref()  :: (Name :: atom())
                  | {Name :: atom(), Node :: node()}
                  | {'global', Name :: atom()}
                  | {'via', Module :: module(), Name :: any()}
                  | pid().
-type child_spec() :: #{name => child_id(),     % mandatory
			start => mfargs(),      % mandatory
			restart => restart(),   % optional
			shutdown => shutdown(), % optional
			type => worker(),       % optional
			modules => modules()}   % optional
                    | {Id :: child_id(),
                       StartFunc :: mfargs(),
                       Restart :: restart(),
                       Shutdown :: shutdown(),
                       Type :: worker(),
                       Modules :: modules()}.

-type startchild_err() :: 'already_present'
			| {'already_started', Child :: child()} | term().
-type startchild_ret() :: {'ok', Child :: child()}
                        | {'ok', Child :: child(), Info :: term()}
			| {'error', startchild_err()}.


-spec start_child(SupRef, ChildSpec) -> startchild_ret() when
      SupRef :: sup_ref(),
      ChildSpec :: child_spec() | (List :: [term()]).
start_child(Supervisor, ChildSpec) ->
    {Supervisor,ChildSpec}.