type rec student = {taughtBy: teacher}
and teacher = {students: array<student>}
let rec vicky = { taughtBy: teacher }
and teacher = {students: [vicky]}
I’m getting error: This kind of expression is not allowed as right-hand side of `let rec’
type rec student = {taughtBy: teacher}
and teacher = {students: array<student>}
let rec vicky = { taughtBy: teacher }
and teacher = {students: [vicky]}
I’m getting error: This kind of expression is not allowed as right-hand side of `let rec’
rec
can be used with other expressions besides functions. The problem here is that it apparently cannot be used with arrays. I’m not sure why.
Using a list instead works:
type rec student = {taughtBy: teacher}
and teacher = {students: list<student>}
let rec vicky = {taughtBy: teacher}
and teacher = {students: list{vicky}}
Interesting, it worked only with function expressions when I tried in the past. Probably because of something similar to arrays here.