Cω - Reference

Apply-to-All

Since it is common to apply operations to every element of a stream, in general, Cω allows explicit lifting of arbitrary method bodies over streams (and other structural types) by writing .{ … block using implicit argument it …}. For example to print all the elements of the stream of integers xs above we can write:

  xs.{ Console.WriteLine(it); };

Manual lifting is also convenient when explicit control over lifting is required such as lifting method access over choices and when both the element type and the stream itself have the same member:

  string  s1 = xs.ToString();                 // convert stream itself
  string* s2 = xs. { return it.ToString(); }; // convert each element

The results of Apply-to-all blocks are flattened using the same rules as lifted member access.