     }
 }
 
+/**
+
+    Creates a new deferred by applying a function `f` to the result of this deferred.
+
+    :param: dx Deferred
+    :param: f Function that will be applied to result of `dx`
+    :param: ec Execution context of `f`
+
+    :returns: a new Deferred
+
+*/
 public func map<D: DeferredType, T>(dx: D, f: D.Element -> T)(_ ec: ExecutionContextType) -> Deferred<T> {
     let p = PurePromise<T>()
     dx.onComplete(ec) { p.complete(f($0)) }
     return p.deferred
 }
 
+/**
+
+    Creates a new deferred by applying a function to the result of this deferred, and returns the result of the function as the new deferred.
+
+    :param: dx Deferred
+    :param: f Funcion that will be applied to result of `dx`
+    :param: ec Execution context of `f`
+
+    :returns: a new Deferred
+
+*/
 public func flatMap<D: DeferredType, D2: DeferredType>(dx: D, f: D.Element -> D2)(_ ec: ExecutionContextType) -> Deferred<D2.Element> {
     let p = PurePromise<D2.Element>()
     dx.onComplete(ec) { p.completeWith(f($0)) }
     return p.deferred
 }
 
+/**
+
+    Converts Deferred<Deferred<T>> into Deferred<T>
+
+    :param: dx Deferred
+
+    :returns: flattened Deferred
+
+*/
 public func flatten<D: DeferredType, ID: DeferredType where D.Element == ID>(dx: D) -> Deferred<ID.Element> {
     let p = PurePromise<ID.Element>()
     

    }
}

public func traverse<S: SequenceType, D: DeferredType>(xs: S, f: S.Generator.Element -> D)(_ ec: ExecutionContextType) -> Deferred<[D.Element]> {
    return reduce(map(xs, f), []) { $0 + [$1] }(ec)
}

public func sequence<S: SequenceType where S.Generator.Element: DeferredType>(dxs: S) -> Deferred<[S.Generator.Element.Element]> {
    return traverse(dxs, id)(ExecutionContext.DefaultPureOperationContext)
}

public func toFuture<D: DeferredType, T, E where D.Element == Result<T, E>>(dx: D) -> Future<T, E> {
    let p = Promise<T, E>()
    

    }(ec)
}

/**

    Reduces the elements of sequence of deferreds using the specified reducing function `combine`

    :param: dxs Sequence of Deferred
    :param: initial Initial value that will be passed as first argument in `combine` function
    :param: combine reducing function
    :param: ec Execution context of `combine`

    :returns: Deferred which will contain result of reducing sequence of deferreds

*/
public func reduce<S: SequenceType, T where S.Generator.Element: DeferredType>(dxs: S, initial: T, combine: (T, S.Generator.Element.Element) -> T)(_ ec: ExecutionContextType) -> Deferred<T> {
    return reduce(dxs, Deferred(initial)) { acc, defValue in
        flatMap(defValue) { value in
