<commit_before>import Beaver

struct AppReducer: Beaver.Reducing {
    typealias StateType = AppState

    let module: ModuleReducer

    func handle(envelop: ActionEnvelop,
                state: AppState,
                completion: @escaping (AppState) -> ()) -> AppState {
        var newState = state

        switch envelop.action {
        case AppAction.start(let startAction):
            return handle(envelop: envelop.update(action: startAction), state: AppState(), completion: completion)

        case AppAction.stop(module: ModuleRoutingAction.stop):
            
            newState.moduleState = nil

        case is ModuleRoutingAction:
            newState.moduleState = module.handle(envelop: envelop, state: state.moduleState ?? ModuleState()) { moduleState in
                newState.moduleState = moduleState
                completion(newState)
            }
            
        default: break
        }

        return newState
    }
}<commit_msg>Update AppReducer.swift<commit_after>import Beaver

struct AppReducer: Beaver.Reducing {
    typealias StateType = AppState

    let module: ModuleReducer

    func handle(envelop: ActionEnvelop,
                state: AppState,
                completion: @escaping (AppState) -> ()) -> AppState {
        var newState = state

        switch envelop.action {
        case AppAction.start(let startAction):
            return handle(envelop: envelop.update(action: startAction), state: AppState(), completion: completion)

        case AppAction.stop(module: ModuleRoutingAction.stop):
            
            newState.moduleState = nil

        case is ModuleAction:
            newState.moduleState = module.handle(envelop: envelop, state: state.moduleState ?? ModuleState()) { moduleState in
                newState.moduleState = moduleState
                completion(newState)
            }
            
        default: break
        }

        return newState
    }
}
{'fraction_non_alphanumeric': 0.07944643772424398, 'fraction_numerical': 0.0, 'mean_word_length': 2.1033386327503973, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '931093', 'n_tokens_mistral': 513, 'n_tokens_neox': 478, 'n_words': 119}