Created
July 11, 2016 00:53
-
-
Save isaksky/142181c86d25a0b23f1c7e9cdeab7a7f to your computer and use it in GitHub Desktop.
iex - Missing stacktrace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule StackPls do | |
@behaviour :gen_statem | |
def callback_mode(), do: :state_functions | |
def start_link(opts) do | |
:gen_statem.start_link(__MODULE__, opts, []) | |
end | |
# Mandatory callback functions | |
def code_change(_old_vsn, old_state, old_data, _extra) do | |
{callback_mode(), old_state, old_data} | |
end | |
def terminate(_reason, _state, _data), do: :void | |
def nest(m, 0) do Map.put(m, :foo, 0) end | |
def nest(m, depth_left) do | |
child = Enum.reduce([:foo, :bar, :baz, :ac, :dc, :yelp, :smart, "wait"], %{}, fn(k, acc) -> Map.put(acc, k, nest(%{}, depth_left - 1)) end) | |
Map.put(m, :child, child) | |
end | |
def init(opts) do | |
start_data = nest(%{}, 5) | |
tref = :erlang.start_timer(200, self(), :wait_for_it) | |
{callback_mode(), :starting, start_data} | |
end | |
def starting(:info, _, data) do | |
{:bad_pattern, a, b, c} = data | |
{:keep_state, data} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment