Type type

Type for types. F f(t:Type) ...; f(Arr) ...

Constructors

Type(name:Str, doc:Any, ns:Any)
Create a new type. Do not use directly.

Automatically called by NGS for syntax

type MyType
Type(x:Any)
Returns type of the given object

Parameters

xObject. Currently only objects of NormalType are supported.
Type(t:Str, doc:Any, ns:Any, parent:Type) Source: stdlib.ngs:73
Create a new type. Do not use directly.

Automatically called by NGS for syntax

type MyType2(MyType1)
Type(t:Str, doc:Any, ns:Any, parents:Arr) Source: stdlib.ngs:78
Create a new type. Do not use directly.

Automatically called by NGS for syntax

type MyType2([MyParent1, MyParent2, ...])

Methods

.(t:Type, field:Str) Source: stdlib.ngs:1811
Undocumented

Automatically called by NGS for syntax

SUBTYPE_OF_NAMEDINSTANCES.NamedInstances

Example

echo(Color.NamedInstances is Namespace)  # true
.(t:Type, field:Str) Source: stdlib.ngs:4997
Undocumented
.=(t:Type, field:Str, ns:Namespace) Source: stdlib.ngs:1818
Undocumented

Automatically called by NGS for syntax

SUBTYPE_OF_NAMEDINSTANCES.NamedInstances = ...
.=(t:Type, field:Str, a:Arr) Source: stdlib.ngs:1837
Undocumented

Automatically called by NGS for syntax

SUBTYPE_OF_NAMEDINSTANCES.NamedInstances = ['SOME', 'NAMES', ...]
::(t:Type, k:Str) Source: stdlib.ngs:1850
Undocumented

Automatically called by NGS for syntax

SUBTYPE_OF_NAMEDINSTANCES::INSTANCE_NAME

Example

echo(Color::RED)   # <Color numval=4 name=RED>
<(t:Type, maybe_supertype:Type) Source: stdlib.ngs:1989
Similar to t <= maybe_supertype but returns false if t === maybe_supertype

Returns

Bool
<=(t:Type, maybe_supertype:Type) Source: stdlib.ngs:1974
Check whether t is maybe_supertype or its subtype Note that if t and maybe_supertype are same type, this method also returns true.

Returns

Bool

Example

Lines <= Eachable1  # true
Eachable <= Lines  # false
==(a:Type, b:Type)
Compare types. Implemented as sameness comparison.

Example

type T1; type T2; T1==T2  # false
=~(x:Any, t:Type, _mc:MatchContext) Source: stdlib.ngs:945
Check whether x is of type t

Returns

x is t
assert(f:Fun, t:Type, msg:Str='Assertion failed') Source: stdlib.ngs:279
Throws AssertFail with given function does not throw exception of the given type.

Parameters

fFun
tSubtype of Exception

Returns

The exception

Example

assert({1/0}, DivisionByZero)
decode(value:Any, t:Type) Source: stdlib.ngs:1857
Resolve named instance of t by uniquely-identifying value of any field

Example

echo("RED".decode(Color))   # <Color numval=4 name=RED>
decode(s:Str, t:Type)experimental Source: stdlib.ngs:1940
Decode (parse) strings such as command line arguments or environment variables to result given type TODO: Consider renaming to UnArgv or decode_arg
ensure(x:Any, t:Type)experimental Source: stdlib.ngs:1433
EXPERIMENTAL! Do not use! Makes sure returned value is of type t. If x is already of type t, returns x. Otherwise, returns object of type t with single item x.

Parameters

ta subtype of Eachable1

Returns

Object of type t
ensure(x:Arr, t:Type) Source: stdlib.ngs:1541
Undocumented

Parameters

tsubtype of ArrLike

Returns

of type t
inherit(t:Type, parent:Type)
Make t inherit from parent. Do not use directly. Use "type MyType(parent)".

Returns

t

Example

type NotImplemented
NotImplemented.inherit(Exception)
init(e:InstantiatingAbstractType, t:Type) Source: stdlib.ngs:289
Initializes InstantiatingAbstractType.
init(p:AWS2::Parameter, res_type:Type, param_name:Str, param_value:Any)
Undocumented
init(td:TypeDescription, containing_nd:NamespaceDescription, name:Str, type:Type)
Undocumented
is(obj:Any, t:Type)
Check whether obj is of type t. Uses same function that is used for matching arguments with method parameters when calling a method.

Returns

Bool

Example

1 is Int  # true
[] is Arr  # true
[] is Int  # false
is_subtype(t:Type, maybe_supertype:Type)deprecated Source: stdlib.ngs:1994
Use t <= maybe_supertype
Str(t:Type) Source: stdlib.ngs:1933
String representation of a type

Returns

"<Type NAME>"

Example

Real.Str().echo()  # Outputs: <Type Real>
~(x:Any, t:Type) Source: stdlib.ngs:2040
Check whether x is of type t

Returns

MatchResult