[Issue 9591] New: std.typetuple.staticApplyMap
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Feb 25 18:14:32 PST 2013
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 at puremagic.com
ReportedBy: bearophile_hugs at eml.cc
--- Comment #0 from bearophile_hugs at 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: -------
More information about the Digitalmars-d-bugs
mailing list