Implementing Haskell's Type-Level Quicksort in D

Philippe Sigaud philippe.sigaud at gmail.com
Thu Feb 13 22:04:34 PST 2014


On Fri, Feb 14, 2014 at 3:54 AM, Meta <jared771 at gmail.com> wrote:

> It seems strange that it would choke now, as Cons is a struct. Therefore,
> Cons!(Three, ...) should create a new type, and `L: Cons!(a, b), a, b`
> shouldn't be any trouble to destructure into two types, `Three` and
> `Cons!(Two, ...)`. It had no problem handling the Succ and Number struct
> templates I defined.

`alias` is just a bit of syntax sugar, it does not (at least for
2.064) have the same power than fully defining a template and the
`is(...)` expression.

So yes, D does not have Haskell nice syntax for pattern matching. You
can do some pattern matching using templates, but it tends to be a bit
heavier than ML/F#/Haskell.

(Some would say that at least D does not force you to encode numbers
as succ/zero list, since you can use numbers directly as template
args, but that's another story).


More information about the Digitalmars-d-learn mailing list