PtcRunner.SubAgent.Namespace.TypeVocabulary (PtcRunner v0.9.0)

Copy Markdown View Source

Converts Elixir values to human-readable type labels.

Summary

Functions

Returns a type label for any value.

Functions

type_of(list)

@spec type_of(term()) :: String.t()

Returns a type label for any value.

Examples

iex> PtcRunner.SubAgent.Namespace.TypeVocabulary.type_of([])
"list[0]"

iex> PtcRunner.SubAgent.Namespace.TypeVocabulary.type_of([1, 2, 3])
"list[3]"

iex> PtcRunner.SubAgent.Namespace.TypeVocabulary.type_of(%{})
"map[0]"

iex> PtcRunner.SubAgent.Namespace.TypeVocabulary.type_of(%{a: 1})
"map[1]"

iex> PtcRunner.SubAgent.Namespace.TypeVocabulary.type_of(MapSet.new([1, 2]))
"set[2]"

iex> PtcRunner.SubAgent.Namespace.TypeVocabulary.type_of({:closure, [], nil, %{}, [], %{}})
"#fn[...]"

iex> PtcRunner.SubAgent.Namespace.TypeVocabulary.type_of("hello")
"string"

iex> PtcRunner.SubAgent.Namespace.TypeVocabulary.type_of(42)
"integer"

iex> PtcRunner.SubAgent.Namespace.TypeVocabulary.type_of(3.14)
"float"

iex> PtcRunner.SubAgent.Namespace.TypeVocabulary.type_of(true)
"boolean"

iex> PtcRunner.SubAgent.Namespace.TypeVocabulary.type_of(false)
"boolean"

iex> PtcRunner.SubAgent.Namespace.TypeVocabulary.type_of(:foo)
"keyword"

iex> PtcRunner.SubAgent.Namespace.TypeVocabulary.type_of(nil)
"nil"

iex> PtcRunner.SubAgent.Namespace.TypeVocabulary.type_of(fn -> :ok end)
"fn"