| > > It takes an input range
> Which should have a type. It does. That'd the `Range` here: https://dlang.org/phobos/std_algorithm_iteration.html#.map.m... > > and returns a type that iterates through that range
> Which should have a type. It does. But the name of that type depends on the type of the range and on the callable. > Functor f => (a -> b) -> f a -> f b This doesn't work because the return type isn't `f b`, it's `g b` where g depends on what f is. It also depends on the callable, because the first parameter isn't necessary a function. The closest is Callable c, Range r0 => c a b -> r0 a -> r1 b Where `r1` isn't even a concrete type but a type that depends on both `c` and `r0` and is made up on-the-fly (per instantiation). > Documentation is good. I agree. How would you suggest improving the signature of map given that D doesn't have typeclasses? Or with types that depend on other types in the template? |
is how you would define that class of types in Haskell. It says "If g is a range, then a pair of types f and g satisfy the FunctorTo interface[1] when knowing f determines g, and there's an implementation of fmapto with this type".
Maybe D needs typeclasses. This thread has certainly put me off of D, because being able to write down types is really quite important to me.
[1] The Haskell class keyword is defines something closer to an interface than an OO class.