3 ms·
Haskell implements type classes via dictionary passing that don’t always get optimized away by the compiler so it does have a slight runtime cost: https://okmi
by nequo 2y ago
Haskell implements type classes via dictionary passing that don’t always get optimized away by the compiler so it does have a slight runtime cost:
https://okmij.org/ftp/Computation/typeclass.html#dict https://okmij.org/ftp/Computation/typeclass.html#dict
In Rust, using trait objects also generates a vtable for dynamic dispatch so in that case traits are not fully erased:
https://web.mit.edu/rust-lang_v1.25/arch/amd64_ubuntu1404/share/doc/rust/html/book/first-edition/trait-objects.html https://web.mit.edu/rust-lang_v1.25/arch/amd64_ubuntu1404/sh...
- deredede 2y agoMy quotation was not good - I intended to reply to the argument that "nominal type do [exist at runtime] to some level". The newtype pattern in either Haskell or Rust is fully transparent at runtime.