Protocol implementation into a quoted expression

Hello, I’m trying to write a specific implementation into the using macro, I have this module :

defmodule Mizur.Implementation do 

  defmacro __using__(_opts) do 
    quote do 
      IO.inspect "test"
      defimpl String.Chars, for: __MODULE__.Type do 
        def to_string(element) do 
          "test" # It is just a test =)


And the global module :

defmodule Mizur do

  @moduledoc """
  **Mizur** is a tool to simplify the management, conversions  
  and mapping of units. 

  The manipulation of units of measurement try (at best) 
  to be typesafe.

  defmacro __using__(_opts) do 
    quote do 
      use Mizur.System
      use Mizur.Implementation
      use Mizur.Api


My goal is to write “specifics” to_string implementation for the structs generated in MODULE and MODULE.Type. But when I try this code (and IO.inspect “#{an_expression_in_the_type_of__MODULE__.Type”) I have this two errors :

warning: the String.Chars protocol has already been consolidated, an implementation for MizurTest.Length.Type has no effect
test test inspection (MizurTest)
     ** (Protocol.UndefinedError) protocol String.Chars not implemented for %MizurTest.Chrono.Type{base: 1, from_basis: #Functio
n<7.77242409/1 in MizurTest.Chrono.sec/0>, name: :sec, to_basis: #Function<8.77242409/1 in MizurTest.Chrono.sec/0>}

Thanks a lot for your feedback.

Not certain, but this may be due to it being attempted from a test … protocols are consolidated (compiled into a fast dispatch form) when a release is built … if afterwards the tests then try to add another addition to the protocol, they will fail.

Hm thanks for your answer.