import LlamaKit

func >>-<A, B>(a: Result<A>, f: A -> Result<B>) -> Result<B> {
    return a.flatMap(f)
}

func <^><A, B>(f: A -> B, a: Result<A>) -> Result<B> {
    return a.map(f)
}

func <*><A, B>(f: Result<A -> B>, a: Result<A>) -> Result<B> {
    switch (f, a) {
    case let (.Success(fBox), .Success(aBox)): return success(fBox.unbox(aBox.unbox))
    case let (.Failure(err), _): return failure(err)
    case let (_, .Failure(err)): return failure(err)
    default: return failure(NSError())
    }
}

import LlamaKit

func >>-<A, B>(a: Result<A>, f: A -> Result<B>) -> Result<B> {
    switch a {
    case let .Success(box): return f(box.unbox)
    case let .Failure(err): return failure(err)
    }
}

func <*><A, B>(f: Result<A -> B>, a: Result<A>) -> Result<B> {
    switch (f, a) {
    case let (.Success(fBox), .Success(aBox)): return success(fBox.unbox(aBox.unbox))
    case let (.Failure(err), _): return failure(err)
    case let (_, .Failure(err)): return failure(err)
    default: return failure(NSError())
    }
}

func <^><A, B>(f: A -> B, a: Result<A>) -> Result<B> {
    switch a {
    case let .Success(box): return success(f(box.unbox))
    case let .Failure(err): return failure(err)
    }
}

--- 
+++ 
@@ -1,10 +1,11 @@
 import LlamaKit
 
 func >>-<A, B>(a: Result<A>, f: A -> Result<B>) -> Result<B> {
-    switch a {
-    case let .Success(box): return f(box.unbox)
-    case let .Failure(err): return failure(err)
-    }
+    return a.flatMap(f)
+}
+
+func <^><A, B>(f: A -> B, a: Result<A>) -> Result<B> {
+    return a.map(f)
 }
 
 func <*><A, B>(f: Result<A -> B>, a: Result<A>) -> Result<B> {
@@ -15,10 +16,3 @@
     default: return failure(NSError())
     }
 }
-
-func <^><A, B>(f: A -> B, a: Result<A>) -> Result<B> {
-    switch a {
-    case let .Success(box): return success(f(box.unbox))
-    case let .Failure(err): return failure(err)
-    }
-}
Use LlamaKit's map and flatMap for fmap and bind

We don't need to duplicate these implementations, since they are already
supplied by LlamaKit. Instead, we should just use them for the
implementation of our operators.
