www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9591] New: std.typetuple.staticApplyMap

http://d.puremagic.com/issues/show_bug.cgi?id=9591

           Summary: std.typetuple.staticApplyMap
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc


--- Comment #0 from bearophile_hugs eml.cc 2013-02-25 18:14:31 PST ---
This is an usage example of std.typetuple.staticMap from the online docs:

alias T = staticMap!(Unqual, int, const int, immutable int);
static assert(is(T == TypeTuple!(int, int, int)));

staticMap is similar to map, it maps a given template on a sequence of items.
Using Haskell syntax (http://www.haskell.org/haskellwiki/Kind ) it has kind:

staticMap :: (* -> *) -> [*] -> [*]


In some cases it's also useful a related higher order TypeTuple template like
this, kind of the opposite of staticMap:

import std.string: leftJustify, center, rightJustify;
alias U = staticApplyMap!(string, leftJustify, center, rightJustify);
static assert(is(U == TypeTuple!(leftJustify!string, center!string,
rightJustify!string)));

With kind:

staticApplyMap :: * -> [* -> *] -> [*]

So the first argument of staticApplyMap is seen as an item, and the following
ones as templates that accept an argument. It returns a TypeTuple of all the
templates applied on the first given item.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 25 2013