under

Function

under — the underlying value

Synopsis

under(val: any) -> any

Description

The under function returns the value underlying the argument val:

  • for unions, it returns the value as its elemental type of the union,
  • for errors, it returns the value that the error wraps,
  • for named values, it returns the value with the name removed,
  • for type values, it removes the named type if one exists; otherwise,
  • it returns val unmodified.

Examples

Unions are unwrapped:

yield this
1((int64,string))
"foo"((int64,string))
Loading...
yield under(this)
1((int64,string))
"foo"((int64,string))
Loading...

Errors are unwrapped:

yield this
error("foo")
error({err:"message"})
Loading...
yield under(this)
error("foo")
error({err:"message"})
Loading...

Values of named types are unwrapped:

yield this
80(port=uint16)
Loading...
yield under(this)
80(port=uint16)
Loading...

Values that are not wrapped are unmodified:

yield under(this)
1
"foo"
<int16>
{x:1}
Loading...

SuperDB