1

I am trying to insert a string into a record type, which is a list of strings. However, the semicolon after the record keeps throwing an error. Also a couple of lines down there's a type error that I think is related because as I've been playing around with debugging the first error sometimes it goes away. Deleting the semicolon, adding or deleting "...", "_", or the entire record hasn't worked and often only causes more errors.

if (lecture.time == workweek.time) {
 switch (lecture.priority, workweek.priority) {
 | (3, 1) => failwith("No time available for class")
 | (3, 2) => 
 switch (lecture.day) {
 | "monday" => {monday: [lecture.lecture], ...};
 | "tuesday" => {..., tuesday: [lecture.lecture], ...};
 | "wednesday" => {..., wednesday: [lecture.lecture], ...};
 | "thursday" => {..., thursday: [lecture.lecture], ...};
 | "friday" => {..., friday: [lecture.lecture]};
 | _ => failwith ("not a valid day")

The errors:

Error: Syntax error
Error: This pattern matches values of type string
 but a pattern was expected which matches values of type (int, int)
Chris
38.3k6 gold badges33 silver badges59 bronze badges
asked Jan 13, 2022 at 2:05

1 Answer 1

0

Record update syntax is {...rec, field: value}: https://reasonml.github.io/docs/en/record#updating-records-amp-spreading

In your case it should probably be:

{...lecture, monday: [lecture.lecture]}

But it's difficult to be sure without knowing the definition of the record type. You should also list the errors next to the specific code that throws each error, not lump them together. It's difficult to tell which code is causing which error.

answered Jan 13, 2022 at 4:19
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.