Last active
August 2, 2025 00:07
-
-
Save bcardarella/7ed0a084ead39e8ded92bd07a89b453b to your computer and use it in GitHub Desktop.
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 LivingThing do | |
use GenObject, [ | |
..living traits... | |
] | |
...living functions... | |
end | |
defmodule Mammal do | |
use LivingThing, [ | |
... | |
] | |
defmacro __using__(fields) do | |
quote do | |
use Furred | |
require Inherit | |
Inherit.setup(unquote(__MODULE__), unquote(fields)) | |
end | |
end | |
end | |
defmodule Dog do | |
use Mammal, [ | |
name: "", | |
breed: "", | |
colors: [], | |
hypoallegenic?: true | |
] | |
defmacro __using__(fields) do | |
use Trainable | |
use Breedable | |
require Inherit | |
Inherit.setup(unquote(__MODULE__), unquote(fields)) | |
end | |
end | |
defmodule GoldenDoodle do | |
use Dog, [ | |
breed: :golen_doodle | |
hypoallegenic?: true, | |
colors: [:yellow] | |
] | |
end | |
defmodule Lab do | |
use Dog, [ | |
breed: :lab | |
] | |
end | |
defmodule ChocolateLab do | |
use Lab, [ | |
colors: [:chocolate] | |
] | |
end | |
ChocolateLab.new(name: "Wiley") | |
GoldenDoodle.new(name: "Boomer") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment