Does D support nested Templates aka Higher Kinded Polymorphism?

Daniel Kozak kozzi11 at gmail.com
Tue Oct 3 16:45:26 UTC 2017


https://run.dlang.io/is/oqbYNb

On Tue, Oct 3, 2017 at 5:52 PM, sighoya via Digitalmars-d-learn <
digitalmars-d-learn at puremagic.com> wrote:

> On Tuesday, 3 October 2017 at 15:30:52 UTC, Daniel Kozak wrote:
>
>> writeln(bar!(Bar,Foo,int)(Bar!(Foo,int)()));
>>
>> Dne 3. 10. 2017 3:55 odpoledne napsal uživatel "sighoya via
>> Digitalmars-d-learn" <digitalmars-d-learn at puremagic.com>:
>>
>> But when I write this to:
>>
>> writeln(bar!(Bar,Foo,int)(Bar!(Foo,int)));
>>
>> it complains by:
>>
>> test.d(11): Error: template instance T!(S!int) does not match template
>> declaration Bar(R, S)
>> test.d(11): Error: template instance T!(S!int) does not match template
>> declaration Bar(R, S)
>> test.d(17): Error: template instance test.bar!(Bar, Foo, int) error
>> instantiating
>>
>
> I still get
>
> test.d(11): Error: template instance T!(S!int) does not match template
> declaration Bar(R, S)
> test.d(11): Error: template instance T!(S!int) does not match template
> declaration Bar(R, S)
> test.d(18): Error: template instance test.bar!(Bar, Foo, int) error
> instantiating
>
>
> by
>
> struct Foo(T) {
>         T value;
> }
>
> struct Bar (R,S) {
>         R!S fooint;
> }
>
>
> //T!S foo(S, alias T)(T!S v) { return v; }
> T!(S!R) bar(alias T,alias S,R)(T!(S!R) v) {return v;}
>
>
> void main() {
>         import std.stdio;
>         //writeln(foo!(int, Foo)(Foo!int(1)));
>         //writeln(bar!(Bar,Foo,int)(Bar!(Foo,int)));
>         writeln(bar!(Bar,Foo,int)(Bar!(Foo,int)()));
> }
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20171003/f7a397a2/attachment.html>


More information about the Digitalmars-d-learn mailing list