Skip to content

Instantly share code, notes, and snippets.

@subsetpark
Created May 17, 2019 18:57
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 subsetpark/ed1229cdd7945558cbd1e32de614f894 to your computer and use it in GitHub Desktop.
Save subsetpark/ed1229cdd7945558cbd1e32de614f894 to your computer and use it in GitHub Desktop.
import TypeClass
defmodule Minotaur do
defstruct name: ""
end
defimpl TypeClass.Property.Generator, for: Minotaur do
def generate(_), do: %Minotaur{name: "#{:crypto.strong_rand_bytes(2)}"}
end
definst Witchcraft.Semigroup, for: Minotaur do
def append(%Minotaur{name: a}, %Minotaur{name: b}), do: %Minotaur{name: "#{b} II, son of #{a}"}
end
definst Witchcraft.Monoid, for: Minotaur do
def empty(_), do: %Minotaur{}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment