public void checkInputs(List inputs) throws IllegalArgumentException {
        Object [] list = inputs.toArray();

        // check that we've got the right number of arguments
        if (list.length != 2)
            throw new IllegalArgumentException("map requires two inputs");

        // now check that we've got the right types for map
        Function function = null;

        if (list[0] instanceof Function) {
            function = (Function)(list[0]);
        } else if (list[0] instanceof VariableReference) {
            Expression xpr = ((VariableReference)(list[0])).
                getReferencedDefinition().getExpression();
            if (xpr instanceof Function)
                function = (Function)xpr;
        }

        if (function == null)
            throw new IllegalArgumentException("first argument to map must " +
                                               "be a Function");
        Evaluatable eval = (Evaluatable)(list[1]);
        if (! eval.returnsBag())
            throw new IllegalArgumentException("second argument to map must " +
                                               "be a bag");

        // finally, check that the type in the bag is right for the function
        List input = new ArrayList();
        input.add(list[1]);
        function.checkInputsNoBag(input);
    }