///|
/// Why a resolver cannot find a type.
pub(all) suberror PathResolveError {
  /// The prefix is not declared.
  UnknownPrefix
  /// There is no such type.
  UnknownType
}

///|
/// Finds the types that a path names. Both functions get the prefix, when there is one, and the name.
pub struct PathResolver {
  priv owner : (String?, String) -> @dependency.OwnerType raise PathResolveError
  priv argument_type : (String?, String) -> ArgumentType? raise PathResolveError
}

///|
/// `owner` finds owner types, as in `(local:Grid.Row)`, and `argument_type` the types of arguments, as in `[(sys:Int32)42]`.
///
/// An argument whose type is `None` is the text as it was written, as in WPF. Without `argument_type`, all arguments are text.
pub fn PathResolver::new(
  owner~ : (String?, String) -> @dependency.OwnerType raise PathResolveError = (
    _,
    _,
  ) => raise UnknownType,
  argument_type~ : (String?, String) -> ArgumentType? raise PathResolveError = (
    _,
    _,
  ) => None,
) -> PathResolver {
  { owner, argument_type, }
}

///|
/// A type that an argument of an indexer can have.
pub struct ArgumentType {
  priv name : String
  priv parse : (String) -> @dependency.AnyValue raise
}

///|
/// `name` is the identity of the type: arguments are equal when their types have the same name and their texts are equal. `parse`
/// makes the value of a text.
pub fn ArgumentType::new(
  name : String,
  parse : (String) -> @dependency.AnyValue raise,
) -> ArgumentType {
  { name, parse, }
}