<commit_before>//
//  ViewController.swift
//  Demo
//
//  Created by xxxAIRINxxx on 2016/01/27.
//  Copyright © 2016 xxxAIRINxxx. All rights reserved.
//

import UIKit
import Chain

final class ViewController: UIViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // Basics
        
        Chain.main {
            // called first
            // called at main thread queue
            print("start")
            return "1"
            }.background { result in
                // called second
                // called at background thread queue
                print(result)  // Optional(1)
                return "2"
            }.userInteractive { result in
                // called third
                // called at userInteractive thread queue
                print(result)  // Optional(2)
                return "3"
            }.userInitiated { result in
                // called fourth
                // called at userInitiated thread queue
                print(result)  // Optional(3)
                return "4"
            }.on { result in
                // called fifth
                // called in the same thread queue as before
                print(result)  // Optional(4)
                return "5"
            }.run(.Main) { result in
                // called last
                // called at main thread queue
                print(result)  // Optional(5)
                print("completion")
        }
        
        // Custom Queue
        
        let customQueue = dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0)
        
        Chain.custom(customQueue) {
            // called first
            // called at customQueue
            return nil
            }.on { result in
                // called second
                // called at customQueue
                return result
            }.main { result in
                // called third
                // called at main thread queue
                return result
            }.custom(customQueue) { result in
                // called fourth
                // called at customQueue
                return result
            }.run()
    }
}
<commit_msg>Fix Demo code<commit_after>//
//  ViewController.swift
//  Demo
//
//  Created by xxxAIRINxxx on 2016/01/27.
//  Copyright © 2016 xxxAIRINxxx. All rights reserved.
//

import UIKit
import Chain

final class ViewController: UIViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // Basics
        
        Chain.main {
            // called first
            // called at main thread queue
            print("start")
            return "1"
            }.background { result in
                // called second
                // called at background thread queue
                print(result)  // Optional(1)
                return "2"
            }.userInteractive { result in
                // called third
                // called at userInteractive thread queue
                print(result)  // Optional(2)
                return "3"
            }.userInitiated { result in
                // called fourth
                // called at userInitiated thread queue
                print(result)  // Optional(3)
                return "4"
            }.onDefault { result in
                // called fifth
                // called at default thread queue
                print(result)  // Optional(4)
                return "5"
            }.run(.Main) { result in
                // called last
                // called at main thread queue
                print(result)  // Optional(5)
                print("completion")
        }
        
        // Custom Queue
        
        let customQueue = dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0)
        
        Chain.custom(customQueue) {
            // called first
            // called at customQueue
            return nil
            }.onDefault { result in
                // called second
                // called default thread queue
                return result
            }.main { result in
                // called third
                // called at main thread queue
                return result
            }.custom(customQueue) { result in
                // called fourth
                // called at customQueue
                return result
            }.run()
    }
}

{'fraction_non_alphanumeric': 0.07729029324846556, 'fraction_numerical': 0.010456922027733576, 'mean_word_length': 1.0455602045560204, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4202603', 'n_tokens_mistral': 1093, 'n_tokens_neox': 976, 'n_words': 316}