   fileprivate let parse: (Route) -> (rest: Route, match: A)?
 }
 
-extension Parser { // : Functor
+// MARK: - Functor
+
+extension Parser {
   public func map<B>(_ a2b: @escaping (A) -> B) -> Parser<B> {
     return Parser<B> { route in
       guard let (rest, a) = self.parse(route) else { return nil }

  }
}

extension Parser { // : Plus
  public static var empty: Parser {
    return Parser { _ in nil }
  }
}

public func pure<A>(_ a: A) -> Parser<A> { // : Applicative
  return Parser<A> { route in
    (route, a)
  }
}

public let end = Parser<()> { route in
  guard route.path.isEmpty else { return nil }

  guard let components = request.url.flatMap({ URLComponents(url: $0, resolvingAgainstBaseURL: false) })
  else { return (method, [], [:]) }

  let path = components.path.components(separatedBy: "/")
    |> mapOptional { $0.isEmpty ? nil : $0 }

  var query: [String: String] = [:]
  components.queryItems?.forEach { query[$0.name] = $0.value ?? "" }
