Functions don’t just have types: They ARE Types. And Kinds. And Sorts. Help put a blown mind back together

You touch so many interesting points in your question, so I am afraid this is going to be a long answer 🙂 Kind of (->) The kind of (->) is * -> * -> *, if we disregard the boxity GHC inserts. But there is no circularity going on, the ->s in the kind of … Read more

Higher-kinded Types with C++

Template-template parameters? template <template <typename> class m> struct Monad { template <typename a> static m<a> mreturn(const a&); template <typename a, typename b> static m<b> mbind(const m<a>&, m<b>(*)(const a&)); }; template <typename a> struct Maybe { bool isNothing; a value; }; template <> struct Monad<Maybe> { template <typename a> static Maybe<a> mreturn(const a& v) { Maybe<a> … Read more

Specifying a concept for a type that has a member function template using Concepts Lite

Long story short, right now you (I?) have to provide a specific U: template <template <class> class HKT, class T, class U = T> concept HKTWithTemplateMemberFunctionF { return requires(HKT<T> h) { // HKT<T> is a type, h is an object h.F(std::declval<U>()) -> HKT<U>; } } since the compiler cannot prove for all types U that … Read more