def weld_compare(array, scalar, operation, weld_type):
    """Applies comparison operation between each element in the array with scalar.

    Parameters
    ----------
    array : numpy.ndarray or WeldObject
        Input data.
    scalar : {int, float, str, bool, bytes_}
        Value to compare with; must be same type as the values in the array. If not a str,
        it is casted to weld_type (allowing one to write e.g. native Python int).
    operation : str
        Operation to do out of: {<, <=, ==, !=, >=, >}.
    weld_type : WeldType
        Type of the elements in the input array.

    Returns
    -------
    WeldObject
        Representation of this computation.

    """
    obj_id, weld_obj = create_weld_object(array)

    if not isinstance(scalar, str):
        scalar = to_weld_literal(scalar, weld_type)

    cast = '{type}({scalar})'.format(type=weld_type, scalar=scalar)
    # actually checking WeldVec(WeldChar)
    if isinstance(weld_type, WeldVec):
        cast = get_weld_obj_id(weld_obj, scalar)

    # TODO: there should be no casting! requires Weld fix
    weld_template = """map(
    {array},
    |a: {type}| 
        a {operation} {cast}
)"""

    weld_obj.weld_code = weld_template.format(array=obj_id,
                                              operation=operation,
                                              type=weld_type,
                                              cast=cast)

    return weld_obj