On Sunday, 30 January 2022 at 10:58:33 UTC, 9il wrote:
...

Nice work!

Anytime I see things like this it makes me wish D would adopt some form of pattern matching.

I've been using F# a lot lately, and I'm in love with how expressive it can be in certain cases, i.e.:

```fsharp
let (|Seconds|NotANumber|) (str : string) =
    let mutable value = 0.0
    match Double.TryParse(str, &value) with
    | true -> Seconds value
    | false -> NotANumber

...somewhere in an expression/function

       match model.Duration with
       | Seconds s -> ValidRequest {
                ...omitted
            }
| NotANumber -> InvalidRequest "Duration is not a valid number"
```

Reply via email to