 	}
 }
 
+public protocol EventType {
+	typealias T
+	typealias E: ReactiveCocoa.ErrorType
+	var event: Event<T, E> { get }
+}
+
+extension Event : EventType {
+	public var event: Event<T, E> {
+		return self
+	}
+}
+
+extension SignalType where T: EventType, E == NoError {
+	public func dematerialize() -> Signal<T.T, T.E> {
+		return Signal { _ in nil }
+		// TODO Commenting out the segfault causes a sigtrap in the compiler.
+//		return Signal { (observer: Event<T.T, T.E>.Sink) in
+//			return self.signal.observe { event in
+//				switch event {
+//				case let .Next(innerEvent):
+//					// TODO This segfaults the compiler as does switching all inner cases explicitly
+//					//observer(innerEvent.event)
+//					break
+//
+//				case .Error:
+//					fatalError()
+//
+//				case .Completed:
+//					sendCompleted(observer)
+//
+//				case .Interrupted:
+//					sendInterrupted(observer)
+//				}
+//			}
+//		}
+	}
+}
+
 private struct SampleState<T> {
 	var latestValue: T? = nil
 	var signalCompleted: Bool = false

/// from `replacement` instead, regardless of whether `signal` has sent events
/// already.
public func takeUntilReplacement<T, E>(replacement: Signal<T, E>) -> Signal<T, E> -> Signal<T, E> {
	return { signal in
		return Signal { observer in
			let signalDisposable = signal.observe { event in
				switch event {
				case .Completed:
					break


/// Returns a signal that will yield an array of values when `signal` completes.
public func collect<T, E>(signal: Signal<T, E>) -> Signal<[T], E> {
	return signal.collect()
}

extension SignalType {
	public func collect() -> Signal<[T], E> {
		return signal
			.reduce(CollectState()) { $0.append($1) }
			.map { $0.values }
	}
}

/// Forwards all events onto the given scheduler, instead of whichever
/// scheduler they originally arrived upon.
public func observeOn<T, E>(scheduler: SchedulerType) -> Signal<T, E> -> Signal<T, E> {
	return { $0.observeOn(scheduler) }
}

extension SignalType {
	public func observeOn(scheduler: SchedulerType) -> Signal<T, E> {
		return Signal { observer in
			return self.signal.observe { event in
				scheduler.schedule {
					observer(event)
				}
