 private let floatFormatter = numberFormatter(with: 7)
 
 // TODO: Support `Float80`
-//extension Float80: NodeRepresentable {}
+//extension Float80: ScalarRepresentable {}
 
 #if swift(>=4.0)
 extension BinaryInteger {

        }
    }
}

extension Array: NodeRepresentable {
    public func represented() throws -> Node {
        let nodes = try map(represent)
        return Node(nodes, Tag(.seq))
    }
}

extension Dictionary: NodeRepresentable {
    public func represented() throws -> Node {
        let pairs = try map { (key: try represent($0.0), value: try represent($0.1)) }
        return Node(pairs.sorted { $0.key < $1.key }, Tag(.map))
    }
}

    }
}

extension Array: NodeRepresentable {
    public func represented() throws -> Node {
        let nodes = try map(represent)
        return Node(nodes, Tag(.seq))
    }
}

extension Dictionary: NodeRepresentable {
    public func represented() throws -> Node {
        let pairs = try map { (key: try represent($0.0), value: try represent($0.1)) }
        return Node(pairs.sorted { $0.key < $1.key }, Tag(.map))
    }
}

private func represent(_ value: Any) throws -> Node {
    if let string = value as? String {
        return Node(string)
    } else if let representable = value as? NodeRepresentable {
        return try representable.represented()
    }
    throw YamlError.representer(problem: "Fail to represent \(value)")
}

// MARK: - ScalarRepresentable
/// Type is representabe as `Node.scalar`
public protocol ScalarRepresentable: NodeRepresentable {}

extension Bool: ScalarRepresentable {
    public func represented() throws -> Node {
        return Node(self ? "true" : "false", Tag(.bool))
    }
}

extension Data: ScalarRepresentable {
    public func represented() throws -> Node {
        return Node(base64EncodedString(), Tag(.binary))
    }
}

extension Date: ScalarRepresentable {
    public func represented() throws -> Node {
        return Node(iso8601string, Tag(.timestamp))
    }
