The bellow code reports the last_visited_at a field as missing, even if it is defined in all record variants:
pub type User {
User(username: String, last_visited_at: String)
Visitor(last_visited_at: String)
}
pub fn main() {
let users = [
User(username: "Robert", last_visited_at: "2019-11-16T16:00:33.52Z"),
Visitor(last_visited_at: "2019-11-16T10:11:02.66Z")
]
list.each(users, fn(user: User) {
io.println("user.last_visited_at:" <> user.last_visited_at)
})
}
Question 1 : Am I wrong trying to use record variants to make my code behaving differently based on the record variant?
Question 2: Is this something that would be supported later by gleam?
Question 3: What would be a better way of achieving this in gleam?
Thank you in advance!