TypeOf
✖
TypeOf
Details and Options

- TypeOf can be used in both interpreted and compiled programs.
- TypeOf uses the type inferencing system of the Wolfram Compiler.
- TypeOf only accepts expressions and types that can be compiled by the Wolfram Compiler.
- TypeOf can be used in interpreted code as a quick check whether compilation will work.
- TypeOf can be used in compiled code to determine the type of some part of the code.
- TypeOf can be used with TypeEvaluate to direct the type for a function declaration.
- TypeOf can take both Typed and declaration specifications such as FunctionDeclaration and TypeDeclaration.
Examples
open allclose allBasic Examples (6)Summary of the most common use cases

https://wolfram.com/xid/0bimqnyw-txivdd

TypeOf is useful since it just determines the type of a function, giving an indication that compilation may work.
Find the type of an expression:

https://wolfram.com/xid/0bimqnyw-kegnam

Find the type of an expression while specifying only the type of a subexpression:

https://wolfram.com/xid/0bimqnyw-wsqcjn

Find the type of a function using a FunctionDeclaration:

https://wolfram.com/xid/0bimqnyw-cnb4v0

Compile a program that contains TypeOf:

https://wolfram.com/xid/0bimqnyw-4oxtdl


https://wolfram.com/xid/0bimqnyw-n8ymoc

TypeOf is useful in polymorphic declarations written with ForAllType because the types of arguments are not known when the declaration is made:

https://wolfram.com/xid/0bimqnyw-c08oz7


https://wolfram.com/xid/0bimqnyw-x973da

TypeOf can be used with TypeEvaluate to determine the type in a declaration:

https://wolfram.com/xid/0bimqnyw-ikbkd

https://wolfram.com/xid/0bimqnyw-j8iobd


https://wolfram.com/xid/0bimqnyw-gjld8g

Scope (2)Survey of the scope of standard use cases
Find the type of a program using arrays:

https://wolfram.com/xid/0bimqnyw-w9cbsz

TypeOf does not evaluate its argument in compiled code, just as in evaluated code:

https://wolfram.com/xid/0bimqnyw-mw79ym


https://wolfram.com/xid/0bimqnyw-ukri0f

Applications (1)Sample problems that can be solved with this function
Properties & Relations (3)Properties of the function, and connections to other functions
TypeOf infers the type of its input without evaluating it:

https://wolfram.com/xid/0bimqnyw-ycghtp

TypeOf gives the return type of the CompiledCodeFunction generated by FunctionCompile but is much faster:

https://wolfram.com/xid/0bimqnyw-vdua24


https://wolfram.com/xid/0bimqnyw-wdmdub

If TypeOf is unable to compile something, it issues a message that typically contains a button to show the source of the error:

https://wolfram.com/xid/0bimqnyw-egst63


Clicking the source button typically opens a user interface that can help to locate the error:

https://wolfram.com/xid/0bimqnyw-3owia0
Possible Issues (3)Common pitfalls and unexpected behavior
TypeOf can only infer the types of compilable programs:

https://wolfram.com/xid/0bimqnyw-b3g6ty


TypeOf does not evaluate its argument, which leads to unintended consequences:

https://wolfram.com/xid/0bimqnyw-yv4f8v


The argument of TypeOf may need explicit evaluation:

https://wolfram.com/xid/0bimqnyw-xshzj

TypeOf only computes the type of its primary argument, so does not find errors in declarations:

https://wolfram.com/xid/0bimqnyw-wf848n

FunctionCompile does a full compilation and can find errors in declarations:

https://wolfram.com/xid/0bimqnyw-zgsgpm


Wolfram Research (2022), TypeOf, Wolfram Language function, https://reference.wolfram.com/language/ref/TypeOf.html.
Text
Wolfram Research (2022), TypeOf, Wolfram Language function, https://reference.wolfram.com/language/ref/TypeOf.html.
Wolfram Research (2022), TypeOf, Wolfram Language function, https://reference.wolfram.com/language/ref/TypeOf.html.
CMS
Wolfram Language. 2022. "TypeOf." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/TypeOf.html.
Wolfram Language. 2022. "TypeOf." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/TypeOf.html.
APA
Wolfram Language. (2022). TypeOf. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TypeOf.html
Wolfram Language. (2022). TypeOf. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/TypeOf.html
BibTeX
@misc{reference.wolfram_2025_typeof, author="Wolfram Research", title="{TypeOf}", year="2022", howpublished="\url{https://reference.wolfram.com/language/ref/TypeOf.html}", note=[Accessed: 02-June-2025
]}
BibLaTeX
@online{reference.wolfram_2025_typeof, organization={Wolfram Research}, title={TypeOf}, year={2022}, url={https://reference.wolfram.com/language/ref/TypeOf.html}, note=[Accessed: 02-June-2025
]}