Last active
December 17, 2015 12:19
-
-
Save pragdave/5609055 to your computer and use it in GitHub Desktop.
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
defprotocol WhizBang do | |
def specific(_) | |
def common(_) | |
end | |
defrecord Foo, name: "foo" | |
defrecord Bar, name: "bar" | |
defmodule Common do | |
def common(arg), do: IO.puts "Common.common: #{inspect arg}" | |
end | |
defimpl WhizBang, for: Foo do | |
defdelegate common(foo), to: Common | |
def specific(_foo), do: IO.puts "specific Foo" | |
end | |
defimpl WhizBang, for: Bar do | |
defdelegate common(bar), to: Common | |
def specific(_bar), do: IO.puts "specific Bar" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment