def dumps(name, namelist):
    """
    Writes a namelist to a string.

    Parameters
    ----------
    name : str
        The name of the namelist
    namelist : dict
        Members of the namelist

    Returns
    -------
    str
        String representation of the namelist
    """
    # start with the opening marker
    result = " ${0}\n".format(name)
    # write each key-value pair on a new line
    for key, value in namelist.items():
        # string values need to be exported in quotes
        if isinstance(value, str):
            value = "'{0}'".format(value)
        # boolean values need to be replace by T or F
        elif isinstance(value, bool):
            value = "T" if value else 'F'
        result += " {0} = {1},\n".format(key, value)
    # finish with the closing marker
    result += " $END\n"
    return result