<commit_before>//
//  Structures.swift
//  BricBrac
//
//  Created by <NAME> on 11/4/15.
//  Copyright © 2015 io.glimpse. All rights reserved.
//

// General data structes need for `Brac` and `Curio` schema support

/// A WrapperType is able to map itself through a wrapped optional
public protocol WrapperType {
    associatedtype Wrapped
    init(_ some: Wrapped)
    func flatMap<U>(_ f: (Wrapped) throws -> U?) rethrows -> U?
}

public extension WrapperType where Self : ExpressibleByNilLiteral {
    /// The underlying type that is contained in this wrapper.
    @inlinable var flatValue: Wrapped? {
        get { self.flatMap({ $0 }) }
        set { self = newValue.flatMap(Self.init) ?? nil }
    }
}

extension Optional : WrapperType { }

public typealias Indirect = IndirectEnum

public extension Optional {
    /// Wrap this optional in an indirection
    func indirect() -> Optional<Indirect<Wrapped>> {
        return self.flatMap(Indirect.init(rawValue:))
    }
}

/// An Indirect is a simple wrapper for an underlying value stored via an indirect enum in order to permit recursive value types
public struct IndirectStruct<Wrapped> : WrapperType {
    /// The underlying holder of the value; must be a type that can handle recursive types, which is why it is an `Array` and not a `CollectionOfOne`
    private var wrapper: [Wrapped]

    public var value: Wrapped {
        get { return self.wrapper[0] }
        set { self.wrapper[0] = newValue }
    }

    /// Construct a non-`nil` instance that stores `value`.
    public init(_ value: Wrapped) {
        self.wrapper = [value]
    }

    public func flatMap<U>(_ f: (Wrapped) throws -> U?) rethrows -> U? {
        return try f(value)
    }
}

/// An Indirect is a simple wrapper for an underlying value stored via an indirect enum in order to permit recursive value types
public indirect enum IndirectEnum<Wrapped> : WrapperType {
    case some(Wrapped)

    /// Construct a non-`nil` instance that stores `some`.
    @inlinable public init(_ some: Wrapped) {
        self = .some(some)
    }

    /// Cover for `indirectValue`
    @available(*, deprecated, renamed: "indirectValue")
    @inlinable public var value: Wrapped {
        get { indirectValue }
        set { indirectValue = newValue }
    }

    /// The underlying value of this `IndirectEnum`.
    @inlinable public var indirectValue: Wrapped {
        get {
            switch self {
            case .some(let v): return v
            }
        }

//        set {
//            self = .some(newValue)
//        }
<commit_msg>Inspectors<commit_after>//
//  Structures.swift
//  BricBrac
//
//  Created by <NAME> on 11/4/15.
//  Copyright © 2015 io.glimpse. All rights reserved.
//

// General data structes need for `Brac` and `Curio` schema support

/// A WrapperType is able to map itself through a wrapped optional
public protocol WrapperType {
    associatedtype Wrapped
    init(_ some: Wrapped)
    func flatMap<U>(_ f: (Wrapped) throws -> U?) rethrows -> U?
}

public extension WrapperType where Self : ExpressibleByNilLiteral {
    /// The underlying type that is contained in this wrapper.
    @inlinable var flatValue: Wrapped? {
        get { self.flatMap({ $0 }) }
        _modify {
            var val = self.flatMap({ $0 })
            yield &val
            if let val = val {
                self = Self(val)
            } else {
                self = nil
            }
        }
    }
}

extension Optional : WrapperType { }

public typealias Indirect = IndirectEnum

public extension Optional {
    /// Wrap this optional in an indirection
    func indirect() -> Optional<Indirect<Wrapped>> {
        return self.flatMap(Indirect.init(rawValue:))
    }
}

/// An Indirect is a simple wrapper for an underlying value stored via an indirect enum in order to permit recursive value types
public struct IndirectStruct<Wrapped> : WrapperType {
    /// The underlying holder of the value; must be a type that can handle recursive types, which is why it is an `Array` and not a `CollectionOfOne`
    private var wrapper: [Wrapped]

    public var value: Wrapped {
        get { return self.wrapper[0] }
        set { self.wrapper[0] = newValue }
    }

    /// Construct a non-`nil` instance that stores `value`.
    public init(_ value: Wrapped) {
        self.wrapper = [value]
    }

    public func flatMap<U>(_ f: (Wrapped) throws -> U?) rethrows -> U? {
        return try f(value)
    }
}

/// An Indirect is a simple wrapper for an underlying value stored via an indirect enum in order to permit recursive value types
public indirect enum IndirectEnum<Wrapped> : WrapperType {
    case some(Wrapped)

    /// Construct a non-`nil` instance that stores `some`.
    @inlinable public init(_ some: Wrapped) {
        self = .some(some)
    }

    /// The underlying value of this `IndirectEnum`.
    @inlinable public var indirectValue: Wrapped {
        get {
            switch self {
            case .some(let v): return v
            }
        }

{'fraction_non_alphanumeric': 0.09816073570571772, 'fraction_numerical': 0.004998000799680128, 'mean_word_length': 2.4220246238030096, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 27, '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': '5648681', 'n_tokens_mistral': 1449, 'n_tokens_neox': 1416, 'n_words': 536}