laurelang
laurelang copied to clipboard
Feature: matrix and union
Matrix
: ?transpose('T'[x][y]) -> 'T'[y][x].
To make size variables invisible in predicate case's scope their names should start with underscore, such as _x.
Implementation. After such cast matrix will gain matrix-confirmation.
Union
Builtin union template – external datatype sets union operator.
union<'T', ...>
optional<'T'>
s = 1 .. 3;
optional<s> a;
Declaration of a optional<'T'> template
none_T ~ @{none}.
optional<'T'> = union<'T', none_T>
Solutions: @none, 1, 2, 3.
: ?transpose_array('T'[][]) -> optional<'T'>[][].
todo
- [ ] matrix
- [x] union
union feature completed
union instance can be used as predicate:
x = union(int, string);
or with type clarification:
x ~ union{int, string};
-- also it can have more than two types here
y ~ union{int, int[], string};
-- clarification will automatically wrap into nested union:
-- union(int, union(int[], string))
optional is made out of any type and @Nothing atom from Nothing universum.
optional_int ~ union{int, Nothing};