Skip to content

Instantly share code, notes, and snippets.

@shdblowers
Created October 26, 2018 16:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shdblowers/fea07b9f76aab618ef59c5ec3cc55efd to your computer and use it in GitHub Desktop.
Save shdblowers/fea07b9f76aab618ef59c5ec3cc55efd to your computer and use it in GitHub Desktop.
defmodule FilePrinter do
@callback parse(String.t) :: {:ok, term} | {:error, String.t}
@callback extensions() :: [String.t]
defmacro __using__(_opts) do
quote do
def output(parsed_str) do
IO.puts(parsed_str)
end
def print(str), do: str |> parse() |> output()
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment