4 ms·
Haskell has full type erasure.
by hither_shores 5y ago
Haskell has full type erasure.
- munificent 5y agoIt still has to carry around enough information to detect non-exhaustive matches and throw at runtime, no?
- dllthomas 5y agoOnly in the same way that "if ... else if ... else" needs to know about types, which is to say mostly not. AFAIK - and this might be either dated or just wrong - the two places GHC doesn't fully erase are 1) polymorphic recursion (where if we squint it's probably not unreasonable to treat the dictionaries as type tags), and 2) when the programmer explicitly asks for run-time type information with Typeable.
- whimsicalism 5y agoBut what are you performing the "if else" on? Type level information stored at runtime, no?
- dllthomas 5y agoValue level information. The compiler statically knows the type that's being matched on. It's true that the generated code depends on the type, but that's not any more true than when a C compiler generates an integer comparison vs a float comparison in the conditional of that "if". All that's looked at at runtime is the data.
- tome 5y agoYes, but those aren't types, they're values.