typex v0.1.0 Typex

                     _____                      
                    |_   _|   _ _ __   _____  __
                      | || | | | '_ \ / _ \ \/ /
                      | || |_| | |_) |  __/>  < 
                      |_| \__, | .__/ \___/_/\_\
                          |___/|_|              

This module helps in finding the type of an argument passed with some basic information. It also helps with more info like emptiness

Summary

Functions

Returns the map with some basic information of an argument passed for an example empty list or empty map etc

Returns a string representation of the type of a passed argument

Functions

type_info(arg)
type_info(any) :: map

Returns the map with some basic information of an argument passed for an example empty list or empty map etc..

Examples

iex> Typex.type_info(:nil)
%{type: 'Nil',value: :nil}
iex> Typex.type_info(nil)
%{type: 'Nil',value: nil}

iex> Typex.type_info(true)
%{type: 'Boolean',value: true}
iex> Typex.type_info(false)
%{type: 'Boolean',value: false}

iex> Typex.type_info(%{})
%{type: 'Map',empty: true,value: %{}}
iex> Typex.type_info(%{name: "Blackode"})
%{type: 'Map',empty: false,value: %{name: "Blackode"}}

iex> Typex.type_info([])
%{type: 'List',empty: true,value: []}
iex> Typex.type_info([1,2,3,4])
%{type: 'List',empty: false,value: [1,2,3,4]}
iex> Typex.type_info([1,2,[3,4]])
%{type: 'List',empty: false,value: [1,2,[3,4]],desc: 'Nested List'}

iex> Typex.type_info("Blackode")
%{type: 'Binary',value: "Blackode"}
iex> Typex.type_info(<<1::8>>)
%{type: 'Binary',value: <<1::8>>}
iex> Typex.type_info(<<1::8,2::8>>)
%{type: 'Binary',value: <<1::8,2::8>>}

iex> Typex.type_info(<<1::3>>)
%{type: 'Bitstring',value: <<1::3>>}
iex> Typex.type_info(<<1::8,2::3>>)
%{type: 'Bitstring',value: <<1::8,2::3>>}

iex> Typex.type_info(1.0)
%{type: 'Float',value: 1.0}
iex> Typex.type_info(1.5)
%{type: 'Float',value: 1.5}
iex> Typex.type_info(-1.5)
%{type: 'Float',value: -1.5}
iex> Typex.type_info(0.0)
%{type: 'Float',value: 0.0}
iex> Typex.type_info(-0.0)
%{type: 'Float',value: -0.0}

iex> Typex.type_info(-1)
%{type: 'Integer',value: -1}
iex> Typex.type_info(0)
%{type: 'Integer',value: 0}
iex> Typex.type_info(1)
%{type: 'Integer',value: 1}

iex> Typex.type_info({:name,"Blackode"})
%{type: 'Tuple',value: {:name,"Blackode"}}

iex> Typex.type_info(:blackode)
%{type: 'Atom',value: :blackode}
iex> Typex.type_info(Blackode)
%{type: 'Atom',value: Blackode}
typeof(arg)
typeof(any) :: charlist

Returns a string representation of the type of a passed argument

Examples

iex> Typex.typeof(:nil)
'Nil'
iex> Typex.typeof(nil)
'Nil'

iex> Typex.typeof(%{})
'Map'
iex> Typex.typeof(%{name: "Blackode"})
'Map'

iex> Typex.typeof([])
'List'
iex> Typex.typeof([1,2,3])
'List'
iex> Typex.typeof([1,2,3,[4]])
'List'
iex> Typex.typeof('hello')
'List'

iex> Typex.typeof(fn()-> :hello end)
'Function'

iex> Typex.typeof(self())
'Pid'

iex> Typex.typeof({1,2,3})
'Tuple'

iex> Typex.typeof(:hello)
'Atom'
iex> Typex.typeof(Hello)
'Atom'
iex> Typex.typeof(Nil)
'Atom'

iex> Typex.typeof(1)
'Integer'
iex> Typex.typeof(-1)
'Integer'
iex> Typex.typeof(0)
'Integer'

iex> Typex.typeof(1.0)
'Float'
iex> Typex.typeof(-1.0)
'Float'
iex> Typex.typeof(-0.0)
'Float'

iex> Typex.typeof("hello")
'Binary'
iex> Typex.typeof(<<1::8>>)
'Binary'

iex> Typex.typeof(<<1::3>>)
'Bitstring'
iex> Typex.typeof(<<1::3,2::8>>)
'Bitstring'