The Strange Loop conference

Nick Sabalausky a at a.a
Thu Sep 22 03:53:01 PDT 2011


"Peter Alexander" <peter.alexander.au at gmail.com> wrote in message 
news:j5dhe0$2ln6$1 at digitalmars.com...
>
> For example, in Haskell, map (correctly) has the signature:
>
> map :: (a -> b) -> [a] -> [b]
>
> but in D, std.map has the signature (expressed in some Haskell/D 
> pseudocode)
>
> map :: (a -> b) -> [a] -> Map!((a -> b), [a])
>

That actually brings up something I've found kind of interesting about D's 
map and other similar functions. They return a type that's specially-tasked 
as "the return type for function {whatever}". So, in a way, it seems almost 
like saying:

ReturnTypeOf!(foo) foo()
{...}

Ie, "The return type of this function is defined to be the type this 
function returns."

Of course, I realize that's not actually what's going on.




More information about the Digitalmars-d mailing list