Feel.Runtime.TypeCheck (feel v0.1.0)

Copy Markdown View Source

The instance of operator (DMN 1.6, Table 62).

value instance of type is true when the value is an instance of the type and false when it is not. It is a question with an answer for every value, so it is never null and it cannot report anything: the function returns the boolean and not an Feel.Runtime.Env.outcome/0.

The type is a resolved Feel.Type.t/0. The analyzer resolves it against the scope. A type that cannot be resolved (a name that is not defined) makes the result null, as the first step of Table 62 says, and the node carries that error: it never gets here.

Nothing is converted: a singleton list is not an instance of the type of its element. null is an instance of Null and of no other type, not even Any (D-23); that is the one place where instance of differs from conformance, and Feel.Type.Instance.instance?/2 has it.

Summary

Functions

Returns whether value is an instance of type.

Functions

instance_of(value, type)

@spec instance_of(Feel.Value.t(), Feel.Type.t()) :: boolean()

Returns whether value is an instance of type.

iex> Feel.Runtime.TypeCheck.instance_of(Decimal.new(1), :number)
true
iex> Feel.Runtime.TypeCheck.instance_of(Decimal.new(1), {:list, :number})
false
iex> Feel.Runtime.TypeCheck.instance_of([Decimal.new(1)], {:list, :number})
true
iex> Feel.Runtime.TypeCheck.instance_of(nil, :null)
true
iex> Feel.Runtime.TypeCheck.instance_of(nil, :any)
false