3 ms·
I don't know Gleam at all but doesn't this beg the question here... |> iterator.from_list() |> iterator.map(Friend) |> iterator.map(friend.to_displ
by jayd16 4y ago
I don't know Gleam at all but doesn't this beg the question here...
|> iterator.from_list()
|> iterator.map(Friend)
|> iterator.map(friend.to_display)
|> print_things_from_an_iterator()
This only prints Friend types. How would you loop through a collection of several types and display them? In other languages they could all implement the interface. Perhaps you could have several to_display functions that handle each type but I'm not sure that's valid in Gleam. It would need runtime type checking. In this example to_display is a member function.
- lpil 4y agoGleam is a strongly typed language like Haskell or Rust, so you cannot have a collection of multiple different types without using another type to wrap them into one.