Implementing Haskell's Type-Level Quicksort in D

Meta jared771 at gmail.com
Tue Feb 11 12:39:32 PST 2014


On Tuesday, 11 February 2014 at 19:13:01 UTC, Philippe Sigaud 
wrote:
> On Mon, Feb 10, 2014 at 6:12 PM, Meta <jared771 at gmail.com> 
> wrote:
>> I'm trying to write a D implementation of Haskell's "type level
>> quicksort"[0], but I'm already running into problems with
>> std.typecons.Typedef. I have tried to translate this Haskell 
>> code:
>
>> alias One = Typedef!(Succ!Zero);
>> alias Two = Typedef!(Succ!One);
>> alias Three = Typedef!(Succ!Two);
>> alias Four = Typedef!(Succ!Three);
>
> Did you try just using:
>
> alias One = Succ!Zero;
> alias Two = Succ!One;
> alias Three = Succ!Two;
> alias Four = Succ!Three;
>
> ?
>
> I remember having fun implementing type-level addition and
> multiplication using D and this Peano construct, so Quicksort is
> probably possible.

I have tried once before only semi-seriously, and using just a 
bare alias was my initial strategy. It didn't work for some 
reason, and I can't really remember why. Maybe I'll give it 
another try and just drop the Typedef.


More information about the Digitalmars-d-learn mailing list