////////////////////////////////////////// // FIXME: Workaround for inability to create existentials of protocols // with associated types and for the // inability to constrain nested generics based on the containing type // // // This file contains "existentials" for the protocols defined in // Policy.swift. Similar components should usually be defined next to // their respective protocols. struct GeneratorOf : Generator { def next() -> T? { return _next() } var _next : ()->T? } def existential(base: G) -> GeneratorOf { return GeneratorOf( { base.next() } ) } struct EnumerableOf : Enumerable { def enumerate() -> GeneratorOf { return _enumerate() } var _enumerate : ()->GeneratorOf } def existential(base: E) -> EnumerableOf { return EnumerableOf( { existential(base.enumerate()) } ) } struct SinkOf : Sink { def put(x: T) { _put(x) } var _put : (T)->() } def existential(base: S) -> SinkOf { return SinkOf( { base.put($0) } ) }