Last active
June 18, 2019 04:33
-
-
Save elbrujohalcon/53e356031e6fb4d9cd1bd92952f67984 to your computer and use it in GitHub Desktop.
My Modules
This file contains hidden or 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 MyODT do | |
@opaque t() :: %{required(:f1) => boolean, required(:f2) => atom} | |
@spec new(boolean, atom) :: t | |
def new(f1, f2), do: %{f1: f1, f2: f2} | |
@spec f1(t) :: boolean | |
def f1(%{f1: f1}), do: f1 | |
def f2(%{f2: f2}), do: f2 | |
end | |
defmodule MyODTUser do | |
@spec new_odt(boolean, atom) :: MyODT.t | |
def new_odt(f1, f2), do: MyODT.new(f1, f2) | |
@spec print_odt(MyODT.t) :: :ok | |
def print_odt(odt), do: :io.format("~p: ~p~n", [MyODT.f2(odt), MyODT.f1(odt)]) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment