Consider the following Java code.
--
import java.util.function.Function;
public class Main{

    //basic Rank2 type
    static interface Stringer{
        <A> String show(Function<A,String> type, A that);
    }

    static class Say implements Stringer {
        public <A> String show(Function<A,String> type, A that){
            return type.apply(that);
        }
    }

    static class Shout implements Stringer {
        public <A> String show(Function<A,String> type, A that){
            return type.apply(that) + "!!!";
        }
    }

}
--
This uses Java's generics' type erasure to create a basic rank 2 type. What are some clean ways to implement something similar in D, in a type safe manner if preferable?

Reply via email to