set_defined_as: Set Type a Symbol Is Defined As in a SymbolMap

Description Usage Arguments Value Examples

View source: R/symbol_map.R

Description

This function sets the defined_as field in a SymbolMap entry.

Usage

1
set_defined_as(map, name, type, is_parameter = FALSE)

Arguments

map

(SymbolMap) A map to modify.

name

(character) The symbol whose entry should be modified.

type

(Term | formula) The new 'defined as' type. Formulas are automatically converted to types with typesys::formula_to_type().

is_parameter

(logical) Is this symbol a parameter?

Value

The updated SymbolMap.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
map = SymbolMap()

# Set 'x' defined as an Integer.
map = set_defined_as(map, "x", RInteger)

# Set 'length' defined as a function from ANY to Numeric.
#
# Type variables in the type indicate polymorphism. In this example, 'b' can
# be replaced by any type at each call site for 'length'.
map = set_defined_as(map, "length", b ~ RNumeric)

duncantl/RTypeInference documentation built on Jan. 16, 2021, 12:30 a.m.