module TypeDict

export standardize_type

const type_dict = (;
    :b => Int8,
    :B => UInt8,
    :byte => Int8,
    :Int => Int,
    :int => Int,
    :Int8 => Int8,
    :Int16 => Int16,
    :Int32 => Int32,
    :Int64 => Int64,
    :int8 => Int8,
    :int16 => Int16,
    :int32 => Int32,
    :int64 => Int64,
    :UInt => UInt,
    :uint => UInt,
    :UInt8 => UInt8,
    :UInt16 => UInt16,
    :UInt32 => UInt32,
    :UInt64 => UInt64,
    :i1 => Int8,
    :i2 => Int16,
    :i4 => Int32,
    :i8 => Int64,
    :h => Int16,
    :short => Int16,
    :long => Int64,
    :longlong => Int64,
    :u1 => UInt8,
    :u2 => UInt16,
    :u4 => UInt32,
    :u8 => UInt64,
    :H => UInt16,
    :ushort => UInt16,
    :ulong => UInt64,
    :ulonglong => UInt64,
    :half => Float16,
    :float16 => Float16,
    :single => Float32,
    :float => Float32,
    :float32 => Float32,
    :Float32 => Float32,
    :double => Float64,
    :float64 => Float64,
    :Float64 => Float64,
    :csingle => ComplexF32,
    :cfloat => ComplexF32,
    :cdouble => ComplexF64,
    :complex => ComplexF64,
    :complex16 => ComplexF16,
    :Complex16 => ComplexF16,
    :complex32 => ComplexF32,
    :Complex32 => ComplexF32,
    :complex64 => ComplexF64,
    :Complex64 => ComplexF64,
    :f => Float32,
    :F => ComplexF32,
    :d => Float64,
    :D => ComplexF64,
    :f2 => Float16,
    :f4 => Float32,
    :f8 => Float64,
)


standardize_type(type_name::Symbol) = type_dict[type_name]
standardize_type(type_name::AbstractString) = type_name |> Symbol |> standardize_type
standardize_type(::Type{T}) where {T<:Number} = T

end # module
