Extract Erlang record into Elixir

You are right, and Record.extract/2 extracts a keywordlist from a *.hrl, which can be used in Record.defrecord.

But it seems as if he were trying to extract a record from a dependency, so it should be :from_lib instead of :from.

Additionally what @easco said seems to be valid as well:

** (ArgumentError) cannot invoke defmacro/2 inside function/macro

Proof:

iex(1)> defmodule M do              
...(1)>   require Record
...(1)>   def foo() do
...(1)>     Record.defrecord(:foo, [bar: 0])
...(1)>   end
...(1)> end
  iex:1

** (ArgumentError) cannot invoke defmacro/2 inside function/macro
    (elixir) lib/kernel.ex:5150: Kernel.assert_no_function_scope/3
    (elixir) lib/kernel.ex:3906: Kernel.define/4
    (elixir) expanding macro: Kernel.defmacro/2
    iex:5: M.foo/0
    (elixir) expanding macro: Record.defrecord/2
    iex:5: M.foo/0

As you can see, the errormessage has the same shape.