ptal / expected

What did you expect?
113 stars 18 forks source link

[monads] Add a Rebindable type_constructor meta-function #66

Closed viboes closed 10 years ago

viboes commented 10 years ago

This meta-function is needed to move from an applied type constructor to its type constructor.

type_constructor<apply<TC, T>> ==  TC

rebind could be defined in function of type_constructor

rebind<M, U> := apply<type_constructor<M>, U>> 

It is not clear yet if type_constructor and apply shouldn't be part of a specific concept. We could extract it later on if considered useful.

Some examples:

rebindable::type_constructor<expected<E,T>> == expected<E>

rebindable::type_constructor<optional<T>> == 
struct  {
 template <class U> 
  usingt type = optional<U>;
}; 

rebindable::type_constructor<T*> == 
struct  {
 template <class U> 
  usingt type = U*;
};