|
Boost : |
Subject: [boost] [Tick] Universal quantified concepts/traits
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2014-12-16 14:37:41
Hi,
I'm trying to represent the concept of a mathematical Functor (as in
Haskell) with Concept Lite. Here is what I want to express:
A Functor W is a type constructor for wrappers of another type T
providing a
function map taking a function (T) -> U and a W<T> and returning a W<U>.
Here is how I think that could be done with Concept Lite. If I
understand the proposal correctly we need to add the type T and the
function parameter to the concept.
concept Functor<typename W, typename T, typename F > =
requires {
using WT = ApplyType<W, T>; // type constructor
using U = ResultType<F, T>;
using WU = ApplyType<W, U>;
Function<F, U, T> &&
requires (F f, WT wt) {
WU { map(f, wt) };
}
};
But this is not exactly what I want to conceptualize. The wrapped type T
and the function F should be universally quantified, that is, the
concept concerns only the type constructor W: Functor<W>.
I have a problem introducing the universal quantification of T and F. I
don't know how to do it without using again a template.
concept Functor<typename W> =
template <typename T, typename F> // universal quantification on T
and F
requires {
using WT = ApplyType<W, T>;
using U = ResultType<F, T>;
using WU = ApplyType<W, U>;
Function<F, U, T> &&
requires (F f, WT wt) {
WU { map(f, wt) };
}
}
};
But this is not valid code, isn't it.
Is there something wrong with this kind of concepts?
What would be the best way to conceptualize this kind of concepts with
the Tick library ?
Best,
Vicente
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk