Thread overview | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
November 15, 2020 Truly algebraic Variant and Nullable | ||||
---|---|---|---|---|
| ||||
Truly algebraic Variant and Nullable with an order-independent list of types. Nullable is defined as ``` alias Nullable(T...) = Variant!(typeof(null), T); ``` Variant and Nullable with zero types are allowed. `void` type is supported. Visitors are allowed to return different types. Cyclic referencing between different variant types are supported. More features and API: http://mir-core.libmir.org/mir_algebraic.html Cheers, Ilya The work has been sponsored by Kaleidic Associates and Symmetry Investments. |
November 15, 2020 Re: Truly algebraic Variant and Nullable | ||||
---|---|---|---|---|
| ||||
Posted in reply to 9il | On Sunday, 15 November 2020 at 04:54:19 UTC, 9il wrote:
> Truly algebraic Variant and Nullable with an order-independent list of types.
>
> Nullable is defined as
> ```
> alias Nullable(T...) = Variant!(typeof(null), T);
> ```
>
> Variant and Nullable with zero types are allowed.
>
> `void` type is supported.
>
> Visitors are allowed to return different types.
>
> Cyclic referencing between different variant types are supported.
>
> More features and API:
>
> http://mir-core.libmir.org/mir_algebraic.html
>
> Cheers,
> Ilya
>
> The work has been sponsored by Kaleidic Associates and Symmetry Investments.
It should be in the standard library.
|
December 16, 2020 Re: Truly algebraic Variant and Nullable | ||||
---|---|---|---|---|
| ||||
Posted in reply to 9il | On Sunday, 15 November 2020 at 04:54:19 UTC, 9il wrote:
> Truly algebraic Variant and Nullable with an order-independent list of types.
>
> Nullable is defined as
> ```
> alias Nullable(T...) = Variant!(typeof(null), T);
> ```
>
> Variant and Nullable with zero types are allowed.
>
> `void` type is supported.
>
> Visitors are allowed to return different types.
>
> Cyclic referencing between different variant types are supported.
>
> More features and API:
>
> http://mir-core.libmir.org/mir_algebraic.html
>
> Cheers,
> Ilya
>
> The work has been sponsored by Kaleidic Associates and Symmetry Investments.
Great library! Have you any plan to separate it from mir-core (to mir-algebraic for example)?
|
December 16, 2020 Re: Truly algebraic Variant and Nullable | ||||
---|---|---|---|---|
| ||||
Posted in reply to Oleg B | On Wednesday, 16 December 2020 at 14:54:26 UTC, Oleg B wrote:
> On Sunday, 15 November 2020 at 04:54:19 UTC, 9il wrote:
>> Truly algebraic Variant and Nullable with an order-independent list of types.
>>
>> Nullable is defined as
>> ```
>> alias Nullable(T...) = Variant!(typeof(null), T);
>> ```
>>
>> Variant and Nullable with zero types are allowed.
>>
>> `void` type is supported.
>>
>> Visitors are allowed to return different types.
>>
>> Cyclic referencing between different variant types are supported.
>>
>> More features and API:
>>
>> http://mir-core.libmir.org/mir_algebraic.html
>>
>> Cheers,
>> Ilya
>>
>> The work has been sponsored by Kaleidic Associates and Symmetry Investments.
>
> Great library! Have you any plan to separate it from mir-core (to mir-algebraic for example)?
Thanks! Maybe, but mir-core is quite small itself and mir.algebraic is the only part that would be extended or updated in the near future. Other parts are quite stable. If there would be a strong reason to split it, we can do it.
|
December 16, 2020 Re: Truly algebraic Variant and Nullable | ||||
---|---|---|---|---|
| ||||
Posted in reply to 9il | On Wednesday, 16 December 2020 at 15:58:21 UTC, 9il wrote: > [snip] > > Thanks! Maybe, but mir-core is quite small itself and mir.algebraic is the only part that would be extended or updated in the near future. Other parts are quite stable. If there would be a strong reason to split it, we can do it. What about making it into a sub-package, as in here [1]? [1] https://github.com/atilaneves/unit-threaded/tree/master/subpackages |
December 16, 2020 Re: Truly algebraic Variant and Nullable | ||||
---|---|---|---|---|
| ||||
Posted in reply to 9il | On Wednesday, 16 December 2020 at 15:58:21 UTC, 9il wrote:
> On Wednesday, 16 December 2020 at 14:54:26 UTC, Oleg B wrote:
>> On Sunday, 15 November 2020 at 04:54:19 UTC, 9il wrote:
>>> Truly algebraic Variant and Nullable with an order-independent list of types.
>>>
>>> Nullable is defined as
>>> ```
>>> alias Nullable(T...) = Variant!(typeof(null), T);
>>> ```
>>>
>>> Variant and Nullable with zero types are allowed.
>>>
>>> `void` type is supported.
>>>
>>> Visitors are allowed to return different types.
>>>
>>> Cyclic referencing between different variant types are supported.
>>>
>>> More features and API:
>>>
>>> http://mir-core.libmir.org/mir_algebraic.html
>>>
>>> Cheers,
>>> Ilya
>>>
>>> The work has been sponsored by Kaleidic Associates and Symmetry Investments.
>>
>> Great library! Have you any plan to separate it from mir-core (to mir-algebraic for example)?
>
> Thanks! Maybe, but mir-core is quite small itself and mir.algebraic is the only part that would be extended or updated in the near future. Other parts are quite stable. If there would be a strong reason to split it, we can do it.
That are you planing update? It's will be perfect if you add `get` overload for kind type and more work with tags [2]
like that:
```
alias TUnion = Algebraic!(
TaggedType!(int, "count"),
TaggedType!(string, "str")
);
auto v = TUnion("hello");
S: final switch (v.kind)
{
static foreach (i, k; EnumMembers!(k.Kind))
case k:
someFunction(v.get!k); // [1] by now v.get!(TUnion.AllowedTypes[i])
break S;
}
if (v.is_count) // [2]
writeln(v.count);
```
or may be I miss this feature in docs?
|
December 17, 2020 Re: Truly algebraic Variant and Nullable | ||||
---|---|---|---|---|
| ||||
Posted in reply to jmh530 | On Wednesday, 16 December 2020 at 16:14:08 UTC, jmh530 wrote:
> On Wednesday, 16 December 2020 at 15:58:21 UTC, 9il wrote:
>> [snip]
>>
>> Thanks! Maybe, but mir-core is quite small itself and mir.algebraic is the only part that would be extended or updated in the near future. Other parts are quite stable. If there would be a strong reason to split it, we can do it.
>
> What about making it into a sub-package, as in here [1]?
>
> [1] https://github.com/atilaneves/unit-threaded/tree/master/subpackages
It takes 0.1 seconds to compile mir-core with LDC in the release mode. It is almost all generic and quite fast to compile. We can, but dub doesn't always work well with submodules. Is there any other reason except compilation speed?
|
December 17, 2020 Re: Truly algebraic Variant and Nullable | ||||
---|---|---|---|---|
| ||||
Posted in reply to Oleg B | On Wednesday, 16 December 2020 at 18:14:54 UTC, Oleg B wrote: > On Wednesday, 16 December 2020 at 15:58:21 UTC, 9il wrote: >> On Wednesday, 16 December 2020 at 14:54:26 UTC, Oleg B wrote: >>> On Sunday, 15 November 2020 at 04:54:19 UTC, 9il wrote: >>>> [...] >>> >>> Great library! Have you any plan to separate it from mir-core (to mir-algebraic for example)? >> >> Thanks! Maybe, but mir-core is quite small itself and mir.algebraic is the only part that would be extended or updated in the near future. Other parts are quite stable. If there would be a strong reason to split it, we can do it. > > That are you planing update? It's will be perfect if you add `get` overload for kind type and more work with tags [2] > > like that: > ``` > alias TUnion = Algebraic!( > TaggedType!(int, "count"), > TaggedType!(string, "str") > ); > > auto v = TUnion("hello"); > > S: final switch (v.kind) > { > static foreach (i, k; EnumMembers!(k.Kind)) > case k: > someFunction(v.get!k); // [1] by now v.get!(TUnion.AllowedTypes[i]) > break S; > } > > if (v.is_count) // [2] > writeln(v.count); > ``` > > or may be I miss this feature in docs? Get by Kind cand be added. You can define TaggedAlgebraic [1]. It has a bit weird API with a separate array of lengths. But we can add another one definition option I think. http://mir-core.libmir.org/mir_algebraic.html#TaggedVariant |
December 17, 2020 Re: Truly algebraic Variant and Nullable | ||||
---|---|---|---|---|
| ||||
Posted in reply to 9il | On Thursday, 17 December 2020 at 15:12:12 UTC, 9il wrote: > On Wednesday, 16 December 2020 at 16:14:08 UTC, jmh530 wrote: >> On Wednesday, 16 December 2020 at 15:58:21 UTC, 9il wrote: >>> [snip] >>> >>> Thanks! Maybe, but mir-core is quite small itself and mir.algebraic is the only part that would be extended or updated in the near future. Other parts are quite stable. If there would be a strong reason to split it, we can do it. >> >> What about making it into a sub-package, as in here [1]? >> >> [1] https://github.com/atilaneves/unit-threaded/tree/master/subpackages > > It takes 0.1 seconds to compile mir-core with LDC in the release mode. It is almost all generic and quite fast to compile. We can, but dub doesn't always work well with submodules. Is there any other reason except compilation speed? You can put it on code.dlang.org as a subPackage and people can download it without downloading all of mir-core. See below: https://code.dlang.org/packages/unit-threaded |
December 18, 2020 Re: Truly algebraic Variant and Nullable | ||||
---|---|---|---|---|
| ||||
Posted in reply to jmh530 | On Thursday, 17 December 2020 at 15:38:52 UTC, jmh530 wrote:
> On Thursday, 17 December 2020 at 15:12:12 UTC, 9il wrote:
>> On Wednesday, 16 December 2020 at 16:14:08 UTC, jmh530 wrote:
>>> On Wednesday, 16 December 2020 at 15:58:21 UTC, 9il wrote:
>>>> [...]
>>>
>>> What about making it into a sub-package, as in here [1]?
>>>
>>> [1] https://github.com/atilaneves/unit-threaded/tree/master/subpackages
>>
>> It takes 0.1 seconds to compile mir-core with LDC in the release mode. It is almost all generic and quite fast to compile. We can, but dub doesn't always work well with submodules. Is there any other reason except compilation speed?
>
> You can put it on code.dlang.org as a subPackage and people can download it without downloading all of mir-core. See below:
>
> https://code.dlang.org/packages/unit-threaded
dub downloads the whole package if just a subpackage is required. The size of mir-core is less then 0.5 mb and 0.1 mb in Zip archive.
|
Copyright © 1999-2021 by the D Language Foundation