Skip to content

queer/peek

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Peek

Parse out typespecs on your modules to create human-legible type data.

Sample input/output:

defmodule A do
  use TypedStruct

  typedstruct do
    @type test() :: :ok
    @type test_two() :: :ok | :error

    field :one, String.t()
    field :two, test()
    field :three, test_two()
  end
end

Peek.peek A
# returns
%{
  t: {:map,
    [
      # :__struct__ is a magic key
      {{:atom, :__struct__}, {:atom, A}},
      # Types are a union `type | nil`
      {{:atom, :one}, {:union, [:string, {:atom, nil}]}},
      {{:atom, :three}, {:union, [union: [atom: :ok, atom: :error], atom: nil]}},
      {{:atom, :two}, {:union, [atom: :ok, atom: nil]}}
    ]}
}

Examples are difficult, so check out test/peek_test.exs to see some more.

Installation

If available in Hex, the package can be installed by adding peek to your list of dependencies in mix.exs:

def deps do
  [
    {:peek, "~> 0.1.0"}
  ]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/peek.

About

Peek at typespecs on your modules and get them in a human-friendly form.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages