Files
mercury/tests/invalid/errors2.err_exp2
Simon Taylor 46a8da81cb Implement builtin tuple types, similar to those in Haskell.
Estimated hours taken: 30

Implement builtin tuple types, similar to those in Haskell.

Tuples are constructed and deconstructed using
the syntax X = {Arg1, Arg2, ...}.
Tuples have type `{Arg1, Arg2, ...}'.

Unary tuples (X = {Arg}) do work, unlike in Haskell. The rationale
for this is that it is useful to be able to construct unary tuples
to be passed to a polymorphic predicate which uses std_util__deconstruct
to deal with a tuple of any arity. Since this is probably the only
use for unary tuples, it's not really worth the effort of treating
them as no_tag types, so we don't.

The type-infos for tuples have the same structure as for higher-order
types. There is a single type_ctor_info for tuples, and the arity
is placed before the argument type_infos.

library/parser.m:
	Change the way '{}/N' terms are parsed, so that the parsed
	representation is consistent with the way other functors
	are represented (previously the arguments were left as
	unparsed ','/2 terms). This avoids special case code
	in prog_io__parse_qualified_term, term__term_to_type
	and term__type_to_term.

compiler/prog_io_dcg.m:
compiler/prog_io_util.m:
	Handle the new structure of '{}/N' terms when parsing DCG escapes
	by converting the argument list back into a single ','/2 term.

compiler/module_qual.m:
	Treat tuples as a builtin type.

compiler/typecheck.m:
	Typecheck tuple constructors.

compiler/mode_util.m:
	Propagate types into tuple bound insts.

compiler/type_util.m:
	Add type_is_tuple/2 and type_id_is_tuple/1 to identify tuple types.
	Add tuples to the list of types which are not atomic types.

	Handle tuple types in `type_constructors' and
	`get_cons_id_arg_types' and `switch_type_num_functors'.

compiler/tabling.m:
	Handle tabling of tuples.

compiler/term_util.m:
	Handle tuples in the code to compute functor norms.

compiler/magic_util.m:
compiler/rl.m:
compiler/rl_key.m:
	Handle tuple types in the Aditi back end.

compiler/mercury_to_mercury.m:
library/io.m:
library/term_io.m:
	Handle output of '{}/N' terms.

compiler/higher_order.m:
compiler/simplify.m:
	Don't specialize complicated unifications of tuple
	types into calls to a specific unification procedure --
	even if the procedure were implemented, it probably
	wouldn't be that much more efficient.

compiler/unify_proc.m:
	Generate unification procedures for complicated unifications
	of tuples (other than in-in unifications). These are generated
	lazily as required.

compiler/make_hlds.m:
	Export add_special_pred for use by unify_proc.m.

compiler/polymorphism.m:
	Export polymorphism__process_pred for use by unify_proc.m.

compiler/bytecode_gen.m:
compiler/code_util.m:
compiler/ml_code_util.m:
	Handle unify procedure names and tags for tuple types.

compiler/mlds_to_c.m:
	Output tuple types as MR_Tuple.

compiler/ml_unify_gen.m:
	Compute the field types for tuples.

compiler/polymorphism.m:
compiler/pseudo_type_info.m:
	Treat tuple type_infos in a similar way to higher-order type_infos.

compiler/hlds_data.m:
	Document how cons_ids for tuple types are represented.

compiler/switch_gen.m:
compiler/table_gen.m:
	Add tuple types to switches on type_util__builtin_type.

compiler/llds_out.m:
util/mdemangle.c:
profiler/demangle.m:
	Transform items named "{}" to "f_tuple" when mangling symbols.

library/builtin.m:
	Define the type_ctor_info used for tuples.

library/private_builtin.m:
	Add `builtin_unify_tuple/2' and `builtin_compare_tuple/3',
	both of which abort. All comparisons and in-in unifications
	of tuples are performed by the generic unification functions
	in runtime/mercury_ho_call.c and runtime/mercury.c.

library/std_util.m:
	Implement the various RTTI functions for tuples.

	Encode tuple `TypeCtorDesc's in a similar way to that
	used for higher-order types. This has the consequence that the limit
	on the arity of higher-order types is now MAX_VIRTUAL_REG,
	rather than 2*MAX_VIRTUAL_REG.

	Avoid calling MR_GC_free for the type-info vector returned
	from ML_expand() for tuples because unlike the vectors
	for du types, it is not copied.

runtime/mercury_type_info.h:
	Add macros for extracting fields from tuple type-infos.
	These just call the macros for extracting fields from higher-order
	type-infos.

	Add a macro MR_type_ctor_rep_is_variable_arity(), which
	returns TRUE for tuples and higher-order types.

	The distinction between higher-order and first-order types
	is now misnamed -- the distinction is really between fixed arity
	types and builtin variable arity types. I'm not sure whether
	it's worth renaming everything.

runtime/mercury.h:
runtime/mercury.c:
	Define unification and comparison of tuples in
	high-level code grades.

runtime/mercury_deep_copy_body.h:
runtime/mercury_make_type_info_body.h:
runtime/mercury_tabling.c:
runtime/mercury_unify_compare_body.h:
	Handle tuple types in code which traverses data using RTTI.

tests/hard_coded/construct.{m,exp}:
tests/hard_coded/expand.{m,exp}:
	Test RTTI functions from std_util.m applied to tuples.

tests/hard_coded/tuple_test.{m,exp}:
	Test unification, comparison, term_to_type etc. applied to tuples.

tests/hard_coded/deep_copy.{m,exp}:
	Test deep copy of tuples.

tests/hard_coded/typeclasses/tuple_instance.{m,exp}:
	Test instance declarations for tuples.

tests/tabling/expand_tuple.{m,exp}:
	Test tabling of tuples.

tests/hard_coded/write.m:
	Add some module qualifications for code which uses
	`{}/1' constructors which are not tuples.

tests/invalid/errors2.{m,err_exp,err_exp2}:
	Test handling of tuples in type errors messages.

NEWS:
doc/reference_manual.texi:
w3/news/newsdb.inc:
	Document tuples.

doc/transition_guide.texi:
	Document the change to the parsing of '{}/N' terms.
2000-09-18 11:53:19 +00:00

64 lines
3.7 KiB
Plaintext

errors2.m: 1: Warning: interface for module `errors2' does not export anything.
errors2.m:009: Error: clause for predicate `errors2:bind_type_param/1'
errors2.m:009: without preceding `pred' declaration.
errors2.m:052: In clause for predicate `errors2:type_error_4/0':
errors2.m:052: warning: variable `X' occurs only once in this scope.
errors2.m:059: In clause for predicate `errors2:type_error_5/0':
errors2.m:059: warning: variable `X' occurs only once in this scope.
errors2.m:065: In clause for predicate `errors2:type_error_6/0':
errors2.m:065: warning: variable `X' occurs only once in this scope.
errors2.m:070: In clause for predicate `errors2:type_error_7/0':
errors2.m:070: warning: variable `Y' occurs only once in this scope.
errors2.m:071: In clause for predicate `errors2:type_error_7/0':
errors2.m:071: warning: variables `Z, A, B' occur only once in this scope.
errors2.m:007: Error: no clauses for predicate `errors2:bind_type_param/2'.
errors2.m:023: Error: no clauses for predicate `errors2:produce_string/1'.
errors2.m:025: Error: no clauses for predicate `errors2:expect_int/1'.
errors2.m:031: In clause for predicate `errors2:type_error/0':
errors2.m:031: in argument 1 of call to predicate `expect_int/1':
errors2.m:031: type error: variable `X' has type `string',
errors2.m:031: expected type was `int'.
errors2.m:037: In clause for predicate `errors2:type_error_2/0':
errors2.m:037: type error in unification of variable `X'
errors2.m:037: and variable `Y'.
errors2.m:037: `X' has type `string',
errors2.m:037: `Y' has type `int'.
errors2.m:043: In clause for predicate `errors2:type_error_3/0':
errors2.m:043: in argument 1 of call to predicate `expect_int/1':
errors2.m:043: type error: variable `Y' has type `string',
errors2.m:043: expected type was `int'.
errors2.m:052: In clause for predicate `errors2:type_error_4/0':
errors2.m:052: in argument 3 of functor `foo_functor/3':
errors2.m:052: type error in unification of argument
errors2.m:052: and constant `1.00000000000000'.
errors2.m:052: argument has type `string',
errors2.m:052: constant `1.00000000000000' has type `float'.
errors2.m:059: In clause for predicate `errors2:type_error_5/0':
errors2.m:059: in argument 3 of functor `foo_functor/3':
errors2.m:059: type error in unification of argument
errors2.m:059: and constant `1.00000000000000'.
errors2.m:059: argument has type `string',
errors2.m:059: constant `1.00000000000000' has type `float'.
errors2.m:065: In clause for predicate `errors2:type_error_6/0':
errors2.m:065: in argument 3 of functor `bar_functor/3':
errors2.m:065: type error in unification of argument
errors2.m:065: and constant `1.00000000000000'.
errors2.m:065: argument has type `string',
errors2.m:065: constant `1.00000000000000' has type `float'.
errors2.m:072: In clause for predicate `errors2:type_error_7/0':
errors2.m:072: in argument 1 of call to predicate `expect_int/1':
errors2.m:072: type error: variable `C' has type `string',
errors2.m:072: expected type was `int'.
errors2.m:078: In clause for predicate `errors2:type_error_8/0':
errors2.m:078: in argument 1 of call to predicate `from_char_list/2':
errors2.m:078: error: undefined symbol `[]/0'.
errors2.m:078: In clause for predicate `errors2:type_error_8/0':
errors2.m:078: error: undefined predicate `from_char_list/2'.
errors2.m:085: In clause for predicate `errors2:type_error_9/0':
errors2.m:085: type error in unification of variable `X'
errors2.m:085: and variable `Y'.
errors2.m:085: `X' has type `{int, string, character}',
errors2.m:085: `Y' has type `{string, character, int}'.
errors2.m:009: Inferred :- pred bind_type_param(int).
For more information, try recompiling with `-E'.