Factor out repeated code in typed_ast.ml Arr/ArrMusic
Closed this issue · 0 comments
There are 4 cases to handle:
1: Normal array, type known
2: Normal array, type inferred
3: Music array, type known
4: Music array, type inferred
(2) can be handled by assuming the first type / most popular type is correct. Then it becomes (1).
(3) can be handled by promoting all the contents to the given type. Then this case becomes (1).
(4) can be handled by taking the first type / most popular type and promoting it (int -> pitch, float -> float, pitch -> pitch, everything else is rejected). Assume that this promoted type is correct. Then this case becomes (3).
Also, convert_music_list
and don't need to have module scope. After not repeating code, we may be able to pull in chord_of
verify_list
, verify_list_empty
, return_list_type
, check_list_type
as well.