applay for template function with sumtypes result?
kiriakov
itcraft.letter at gmail.com
Tue Jul 4 04:58:58 UTC 2023
Hi. I can't handle template. It all looks sad, build ok, test
error.
```
struct ParsResult(T) { T[] _in; T[] _out; }
struct Err(T) { T[] x; }
struct Result(T) {
SumType!(ParsResult!T, Err!T) data;
alias data this;
this(Value)(Value value) { data = value; }
}
Result!T applay(T)(Result!T function (T[]) pure fun, T[] x) pure
{ return fun(x); }
ParsResult!char f (char[] x) pure { return
ParsResult!char(x[1..$], x[2..$]); }
unittest
{
writeln(applay(&f,"String10".dup));
}
```
I got
Error: none of the overloads of template `mexception.pars` are
callable using argument types `!()(ParsResult!char
delegate(char[] x) pure nothrow @nogc @safe, char[])`
source/mexception.d(64,10): Candidate is:
`pars(T)(Result!T function(T[]) pure fun, T[] x)`
More information about the Digitalmars-d-learn
mailing list