logoalt Hacker News

mono442yesterday at 7:05 PM2 repliesview on HN

I've looked at Gleam before but it didn't seem to have any mechanism for dynamic dispatch like interfaces or type classes. Did it change in the meantime?


Replies

stuartaxelowenyesterday at 7:18 PM

The answer I’ve seen is “just pass structs of functions around”, which is just one step more explicit than the implicit version we’re all use to, but honestly I kinda like it to free ourselves of all the ceremony around generics.

show 1 reply
lpilyesterday at 7:18 PM

Gleam has first class functions, so it has dynamic dispatch.

Both of type classes and interfaces desugar to high order functions, so anything you write with them can be written with first class functions, though with a less concise API.

show 1 reply