def singleton_of(conversion):

    """Generate conversion function to convert a single-entry list of
    strings to a single value of given type.

    Caution: For integers representing boolean values, use conversion function
    mfdnres.tools.bool_from_str, rather than simply bool.

    >>> a = ["1"]
    >>> singleton_of(int)(a)
        1

    Arguments:
        conversion (function): type converstion function for single entry

    Returns:
        (function): function extract such entry

    """

    def f(data):
        if (len(data)!=1):
            raise ValueError("expecting list of length 1 but found {}".format(data))
        return conversion(data[0])

    return f