def mapping_constructor(mapping_type, loader, mapping):
    """
    Construct an AttributeDict from the representation

    :param mapping_type: the class of the mapping to construct, must accept a dictionary as a
        sole constructor argument to be compatible
    :param loader: the yaml loader
    :type loader: :class:`yaml.loader.Loader`
    :param mapping: the attribute dict representation
    :return: the mapping type
    """
    yaml_node = loader.construct_mapping(mapping)
    return mapping_type(yaml_node)