News for hackers. Stuff that matters.
Re:Fearless concurrency with Rust by dietrichepp on Friday April 10, 2015 @08:04PM (#9357779)
Concerning std::allocator_traits, it reflects a deeper limitation of the language rather than just a library design flaw. If you had HKT, you could pass std::allocator to a template. You can't do that, you can only pass std::allocator<T> for some concrete T. Equivalently, in Haskell, you can pass IO as a type parameter, so you don't see the same kludges.

I definitely agree with the sentiment about subtype polymorphism.

Re:Fearless concurrency with Rust by Rusky on Friday April 10, 2015 @08:35PM (#9357880)
You can actually pass std::allocator to a template:

    template <class X> foo {};
    template <template<class> class F> struct bar { F<int> f; };
    
    bar<foo> b;
This is painful to do with a lot of the STL like vector, because they have a lot of default template arguments and there's no implicit currying.

I haven't investigated it but variadic template template arguments might help there, though.

Re:Fearless concurrency with Rust by sjolsen on Friday April 10, 2015 @11:25PM (#9358327)
>I haven't investigated it but variadic template template arguments might help there, though.

They do:

    template <template <typename...> class Container, typename T>
    Container <T> fin (T n) {
        Container <T> set;
        for (T i = 0; i < n; ++i)
            set.push_back (i);
        return set;
    }
    
    int main () {
        for (int i : fin <std::vector> (10))
            std::cout << i << std::endl;
    }