infer_type(42L) # Integer
infer_type(3.14) # Double
infer_type(c(1, 2, 3)) # Double or Numeric, no length constraint
infer_type("abc") # String
infer_type(c("a", "b")) # String
infer_type(TRUE) # Bool
infer_type(NULL) # Null
infer_type(function(x) x + 1) # Function
infer_type(list(a = 1, b = "x")) # create_list_type(list(a = Double, b = String))
infer_type(list(1, 2, 3)) # ListOf(Double)
infer_type(data.frame(x = 1:3)) # create_dataframe_type(list(x = Integer))
infer_type(list(a = NULL, b = 1)) # create_list_type(list(a = Optional(Any), b = Double))
# Strict mode keeps observed length constraints
infer_type(42L, strict = TRUE) # Scalar(Integer)
infer_type(c("a", "b"), strict = TRUE) # String[2]
Run the code above in your browser using DataLab