 		dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER)
 		return result!
 	}
-
+}
+
+/// Conversions from ColdSignal to HotSignal.
+extension ColdSignal {
 	/// Immediately subscribes to the receiver, then forwards all values on the
 	/// returned signal.
 	///

	public func subscribe(next: T -> () = doNothing, error: NSError -> () = doNothing, completed: () -> () = doNothing) -> Disposable {
		return subscribe(Subscriber(next: next, error: error, completed: completed))
	}

	/// Maps over the elements of the signal, accumulating a state along the
	/// way.
	///

		}
	}

	/// Concatenates `signal` after the receiver.
	public func concat(signal: ColdSignal) -> ColdSignal {
		return ColdSignal { subscriber in
			let serialDisposable = SerialDisposable()
			subscriber.disposable.addDisposable(serialDisposable)

			serialDisposable.innerDisposable = self.subscribe(Subscriber { event in
				switch event {
				case let .Completed:
					serialDisposable.innerDisposable = signal.subscribe(subscriber)

				default:
					subscriber.put(event)
				}
			})
		}
	}

	/// Ignores all values from the receiver, then subscribes to and forwards
	/// events from the given signal once the receiver has completed.
	public func then<U>(signal: ColdSignal<U>) -> ColdSignal<U> {
		return ColdSignal<U> { subscriber in
			let disposable = SerialDisposable()
			subscriber.disposable.addDisposable(disposable)

			disposable.innerDisposable = self.subscribe(error: { error in
				subscriber.put(.Error(error))
			}, completed: {
				disposable.innerDisposable = signal.subscribe(subscriber)
			})
		}
	}

	/// Merges a signal of signals down into a single signal, biased toward the
	/// signals added earlier.
	///
	/// evidence - Used to prove to the typechecker that the receiver is
	///            a signal of signals. Simply pass in the `identity` function.
	///
	/// Returns a signal that will forward events from the original signals
	/// as they arrive.
	public func merge<U>(evidence: ColdSignal<T> -> ColdSignal<ColdSignal<U>>) -> ColdSignal<U> {
		return ColdSignal<U> { subscriber in
			let disposable = CompositeDisposable()
			let inFlight = Atomic(1)

			let decrementInFlight: () -> () = {
				let orig = inFlight.modify { $0 - 1 }
				if orig == 1 {
					subscriber.put(.Completed)
				}
			}

			let selfDisposable = evidence(self).subscribe(next: { stream in
				inFlight.modify { $0 + 1 }

				let streamDisposable = SerialDisposable()
				disposable.addDisposable(streamDisposable)

				streamDisposable.innerDisposable = stream.subscribe(Subscriber { event in
					if event.isTerminating {
						streamDisposable.dispose()
						disposable.pruneDisposed()
					}

					switch event {
					case let .Completed:
						decrementInFlight()

					default:
						subscriber.put(event)
					}
				})
			}, error: { error in
				subscriber.put(.Error(error))
			}, completed: {
				decrementInFlight()
			})

			subscriber.disposable.addDisposable(selfDisposable)
		}
	}

	/// Switches on a signal of signal, forwarding events from the
	/// latest inner signal.
	///
	/// evidence - Used to prove to the typechecker that the receiver is
	///            a signal of signals. Simply pass in the `identity` function.
	///
	/// Returns a signal that will forward events only from the latest
	/// signal sent upon the receiver.
	public func switchToLatest<U>(evidence: ColdSignal<T> -> ColdSignal<ColdSignal<U>>) -> ColdSignal<U> {
		return ColdSignal<U> { subscriber in
			let selfCompleted = Atomic(false)
			let latestCompleted = Atomic(false)

			let completeIfNecessary: () -> () = {
				if selfCompleted.value && latestCompleted.value {
					subscriber.put(.Completed)
				}
			}

			let latestDisposable = SerialDisposable()
			subscriber.disposable.addDisposable(latestDisposable)

			let selfDisposable = evidence(self).subscribe(next: { stream in
				latestDisposable.innerDisposable = nil
				latestDisposable.innerDisposable = stream.subscribe(Subscriber { innerEvent in
					switch innerEvent {
					case let .Completed:
						latestCompleted.value = true
						completeIfNecessary()

					default:
						subscriber.put(innerEvent)
					}
				})
			}, error: { error in
				subscriber.put(.Error(error))
			}, completed: {
				selfCompleted.value = true
				completeIfNecessary()
			})

			subscriber.disposable.addDisposable(selfDisposable)
		}
	}
}

/// Blocking methods for receiving values.
extension ColdSignal {
	/// Subscribes to the receiver, then returns the first value received.
	public func first() -> Result<T> {
		let semaphore = dispatch_semaphore_create(0)
