Implementing Haskell's Type-Level Quicksort in D
Meta
jared771 at gmail.com
Thu Feb 13 18:26:44 PST 2014
Coming back to this after a few days. I got a bit farther, but
I'm running into trouble with the template args pattern matching.
I'd like to turn this code:
list1 :: Cons Three (Cons Two (Cons Four (Cons One Nil)))
list1 = undefined
numlHead :: Cons a b -> a
numlHead = const undefined
numlTail :: Cons a b -> b
numlTail = const undefined'
Into this D code:
alias list1 = Cons!(Three, Cons!(Two, Cons!(Four, Cons!(One,
Nil))));
alias numlHead(L: Cons!(a, b), a, b) = a;
alias numlTail(L: Cons!(a, b), a, b) = b;
But the compiler is complaining loudly about a mismatch:
/d43/f234.d(39): Error: template instance numlHead!(list1) does
not match template declaration numlHead(L : Cons!(a, b), a, b)
More information about the Digitalmars-d-learn
mailing list