TypeCheck - Fast and flexible runtime type-checking for your Elixir projects

Thanks for your responses! I’d like to use just %Ecto.Changeset{} in my specs, but it always returns an error. Should it work like this?

defmodule Test do
  use TypeCheck

  @spec! fun(%Ecto.Changeset{}) :: %Ecto.Changeset{}
  def fun(%Ecto.Changeset{} = changeset) do
    changeset
  end
end

Error:


Call does not have expected term of type 
  {TypeCheck.Builtin.List.t()
   | TypeCheck.Builtin.Map.t()
   | %{
       :__struct__ => atom(),
       :element_types => [any()],
       :keypairs => [{_, _}],
       :name => atom(),
       :range => _,
       :type => _,
       :value => _
     }, atom(), map(), _}
 (with opaque subterms) in the 1st position.

TypeCheck.TypeError.exception(
  {%TypeCheck.Spec{
     :name => :fun,
     :param_types => [%TypeCheck.Builtin.FixedMap{:keypairs => [any(), ...]}, ...],
     :return_type => %TypeCheck.Builtin.FixedMap{:keypairs => [{_, _}, ...]}
   }, :return_error,
   %{
     :arguments => [any(), ...],
     :problem =>
       {%TypeCheck.Builtin.FixedMap{
          :keypairs => [
            {:__struct__, %TypeCheck.Builtin.Literal{:value => Ecto.Changeset}},
            ...
          ]
        }, :missing_keys | :not_a_map | :value_error,
        %{
          :key => :__struct__,
          :keys => [:__struct__, ...],
          :problem =>
            {%TypeCheck.Builtin.Literal{:value => Ecto.Changeset}, :not_same_value, %{}, _}
        }, _}
   }, _}
)