checkFunctionArgs argMap dom resType f args
  | length (prcdArgs f) /= length args = 
    throwError $ "Arguments not same length"
  | otherwise = do
    let formalTypes = map declType (prcdArgs f)
        guardTypeM type1 type2 
           | type1 == type2 = return ()
           | otherwise  = throwError $ "Unconforming arguments: " ++ 
                           show type1 ++ " and " ++ show type2
    actualArgs <- mapM (fmap texprType . typecheckExpr argMap dom resType) args
    zipWithM_ guardTypeM formalTypes actualArgs
    return (prcdResult f)
checkFunctionArgs argMap dom resType f args
  | length (prcdArgs f) /= length args = 
    throwError $ "Arguments not same length"
  | otherwise = do
    let formalTypes = map declType (prcdArgs f)
        guardTypeM type1 type2 
           | type1 == type2 = return ()
           | otherwise  = throwError $ "Unconforming arguments: " ++ 
                           show type1 ++ " and " ++ show type2
    actualArgs <- mapM (fmap texprType . typecheckExpr argMap dom resType) args
    zipWithM_ guardTypeM formalTypes actualArgs
    return (prcdResult f)
checkFunctionArgs argMap dom resType f args
  | length (prcdArgs f) /= length args = 
    throwError $ "Arguments not same length"
  | otherwise = do
    let formalTypes = map declType (prcdArgs f)
        guardTypeM type1 type2 
           | type1 == type2 = return ()
           | otherwise  = throwError $ "Unconforming arguments: " ++ 
                           show type1 ++ " and " ++ show type2
    actualArgs <- mapM (fmap texprType . typecheckExpr argMap dom resType) args
    zipWithM_ guardTypeM formalTypes actualArgs
    return (prcdResult f)