<commit_before>//: # Welcome to FutureKit!
//: Make sure you opened this inside the FutureKit workspace.  Opening the playground file directly, usually means it can't import FutureKit module correctly.
import Foundation
import FutureKit
#if os(iOS)
    import UIKit
    typealias NSImage = UIImage
#else
    import Cocoa
#endif
import XCPlayground
//: Seting XCPSetExecutionShouldContinueIndefinitely so we can run multi-threaded things.
XCPSetExecutionShouldContinueIndefinitely(continueIndefinitely: true)
//: # Let's get started!

//: This is a Future:
let future5Int : Future<Int>
//: It's not a regular Int.  It's a "Future" Int.
//: At some point in the future, this object will "generate" an Int. Or maybe it will fail.
//: I called the variable "future5Int" because it will eventualy at some point in the future it will return a Int value of 5.  Very useful if you need a 5 at somepoint in the future.
future5Int = Future(success: 5)
//: Ok.  I told a small lie. Cause now the value 5 is already there.  This was a Future that was created in a "completed" state.  It has a result.  The Future was successful, and it has a result of 5.  Very good.
let resultOfFuture5 = future5Int.result!
//: println_and_line_no will output things to the console output. So you can see how things are running. Make sure to turn on the Assistant Editor (View..Assistant Editor...Show Assistant Editor) if you don't see console output.
//: Sometimes a Future will fail. Maybe the database is all out if 5's.  So instead of 5, we are gonna return a failure.  No number 5 for you.
let futureFail = Future<Int>(failWithErrorMessage:"I have no 5's for you today.")
let failed5result = futureFail.result
let e = futureFail.error!.localizedDescription

//: Sometimes your request is cancelled. It's not usually because of a failure, and usually means we just wanted to halt an async process before it was done.  Optionally you can send a reason, but it's not required.  In FutureKit a Fail means that something went wrong, and you should cope with that.  a Cancel is usually considered "legal", like canceling active API requests when a window is closed.
let cancelledFuture = Future<Int>(cancelled: "Don't need this anymore")
let cancelledResult = cancelledFuture.result
let cancelationToken = cancelledFuture.cancelToken

//: These aren't very interesting Futures. Let's make something a bit more interesting:<commit_msg>Update Contents.swift<commit_after>//: # Welcome to FutureKit!
//: Make sure you opened this inside the FutureKit workspace.  Opening the playground file directly, usually means it can't import FutureKit module correctly.
import Foundation
import FutureKit
#if os(iOS)
    import UIKit
    typealias NSImage = UIImage
#else
    import Cocoa
#endif
import XCPlayground
//: Seting XCPSetExecutionShouldContinueIndefinitely so we can run multi-threaded things.
XCPSetExecutionShouldContinueIndefinitely(continueIndefinitely: true)
//: # Let's get started!

//: This is a Future:
let future5Int : Future<Int>
//: It's not a regular Int.  It's a "Future" Int.
//: At some point in the future, this object will "generate" an Int. Or maybe it will fail.
//: I called the variable "future5Int" because it will eventualy at some point in the future it will return a Int value of 5.  Very useful if you need a 5 at somepoint in the future.
future5Int = Future(success: 5)
//: Ok.  I told a small lie. Cause now the value 5 is already there.  This was a Future that was created in a "completed" state.  It has a result.  The Future was successful, and it has a result of 5.  Very good.
let resultOfFuture5 = future5Int.result!
//: Sometimes a Future will fail. Maybe the database is all out if 5's.  So instead of 5, we are gonna return a failure.  No number 5 for you.
let futureFail = Future<Int>(failWithErrorMessage:"I have no 5's for you today.")
let failed5result = futureFail.result
let e = futureFail.error!.localizedDescription

//: Sometimes your request is cancelled. It's not usually because of a failure, and usually means we just wanted to halt an async process before it was done.  Optionally you can send a reason, but it's not required.  In FutureKit a Fail means that something went wrong, and you should cope with that.  a Cancel is usually considered "legal", like canceling active API requests when a window is closed.
let cancelledFuture = Future<Int>(cancelled: "Don't need this anymore")
let cancelledResult = cancelledFuture.result
let cancelationToken = cancelledFuture.cancelToken

//: These aren't very interesting Futures. Let's make something a bit more interesting:
{'fraction_non_alphanumeric': 0.0673055979089523, 'fraction_numerical': 0.00653452406883032, 'mean_word_length': 4.218181818181818, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3736350', 'n_tokens_mistral': 1268, 'n_tokens_neox': 1214, 'n_words': 652}