Paul, have you any plans to update std.sumtype
to actual version of sumtype
(1.1.x)?
typeIndex
is needed
March 31, 2021 Re: std.sumtype? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jon Degenhardt | On Wednesday, 31 March 2021 at 17:34:00 UTC, Jon Degenhardt wrote: > As another example, the ability to define a catch-all handler is not mentioned in the text (or at least I couldn't find it). It's in the examples. Well, it's not really a specific "ability"; it's just a natural consequence of the fact that you're allowed to use templates as handlers. I think an example is the most appropriate place to illustrate something like that, but it is probably worth adding a link to the documentation to explicitly point out the connection. > I don't know that I'll have time to propose doc updates via pull-request, but I might have time to make suggestions by some other mechanism, like issue reports something else. Is there a mechanism/venue that would work for you? If you want to make sure that it's seen by me specifically, the easiest way is probably to submit an issue to the `sumtype` repository on Github [1]. Another possibility is to submit a report to issues.dlang.org and add me to the CC list. I have not tried this myself, but I expect Bugzilla would notify me. [1] https://github.com/pbackus/sumtype/issues/ |
August 29, 2021 Re: std.sumtype? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul Backus | Paul, have you any plans to update
|
August 29, 2021 Re: std.sumtype? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Oleg B | On Sunday, 29 August 2021 at 14:00:30 UTC, Oleg B wrote: >Paul, have you any plans to update
I did. The change was reverted by Atila Neves: https://github.com/dlang/phobos/pull/7922 He was not satisfied with the rationale given in this thread for adding |
August 29, 2021 Re: std.sumtype? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Oleg B |
August 29, 2021 Re: std.sumtype? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On Sunday, 29 August 2021 at 14:29:09 UTC, Steven Schveighoffer wrote: >... What a shame... I've been using std.sumtype recently and I was really hoping something like this would be added in. It feels really clunky otherwise. |
August 29, 2021 Re: std.sumtype? | ||||
---|---|---|---|---|
| ||||
Posted in reply to SealabJaster | On Sunday, 29 August 2021 at 14:45:20 UTC, SealabJaster wrote: >On Sunday, 29 August 2021 at 14:29:09 UTC, Steven Schveighoffer wrote: >... What a shame... I've been using std.sumtype recently and I was really hoping something like this would be added in. It feels really clunky otherwise. If you find the lack of For a concrete example, have a look at
If you can give an example of the kind of code you have in mind, I would be happy to give more specific advice. |
August 29, 2021 Re: std.sumtype? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul Backus | On Sunday, 29 August 2021 at 14:25:11 UTC, Paul Backus wrote: >On Sunday, 29 August 2021 at 14:00:30 UTC, Oleg B wrote: >Paul, have you any plans to update
I did. The change was reverted by Atila Neves: https://github.com/dlang/phobos/pull/7922 He was not satisfied with the rationale given in this thread for adding I write https://github.com/deviator/sbin/blob/master/source/sbin/type.d#L147 like this
but on this code I get problem:
output:
It means that Can you suggest how to rewrite it? If it not possible, may be it can be strong argument for adding ps sumtype 1.1.4 with |
August 29, 2021 Re: std.sumtype? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Oleg B | On Sunday, 29 August 2021 at 16:04:53 UTC, Oleg B wrote: >It means that
Can you suggest how to rewrite it? If it not possible, may be it can be strong argument for adding Sure. Here's the implementation of
Note that this version has the problem you complained about before where it does not distinguish between the If this is still a problem for you, you can strip off the qualifier from the
An unqualified |
August 29, 2021 Re: std.sumtype? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul Backus | On Sunday, 29 August 2021 at 15:05:57 UTC, Paul Backus wrote: >... It is also of course totally possible I'm not using sumtypes right, but I'm frequently in situations such as this:
While in this case I still have to go through I guess it's just a niche case (wanting to 'abort' on a bad value rather than keep going) I keep running into, likely a sign I need to change my mindset rather than anything else. Or I'm just using it as a wrong abstraction >;3 In this specific case as well I don't believe I can use And I keep forgetting to make the difference between a tagged union and a sum type, which is likely muddying my opinion since it's easy to extract and test values with the former case. |
August 29, 2021 Re: std.sumtype? | ||||
---|---|---|---|---|
| ||||
Posted in reply to SealabJaster | On Sunday, 29 August 2021 at 19:19:54 UTC, SealabJaster wrote: >... While I'm on a tiny rant, I'd like to just mention that compiler errors with SumType can be a bit obtuse. It's often annoying when you're using a generic case but due to a compiler error that the SumType eats up, all you get is "handler[x] is never matched" or "type X is unhandled", etc. Usually all you have to do is make a specific case for the type(s) causing the issue, but it's just a bit of extra work I'd rather not do. I appreciate that it's not really possible/easy to distinguish the case of "this handler does handle this type, it just doesn't compile due to an error in the body" though. |