Safe coercions (Haskell Unfolder #48)

Will be streamed today, 2025-10-01, at 1830 UTC.

Abstract:

When GHC knows that two types have the same run-time representation, it allows you to use coerce to go from a value of one to a value of the other in a safe and cost-free way. Primarily, the opportunity to coerce arises from the use of newtype, where the new type is guaranteed to have the same representation as the wrapped type. However, the implications of this are surprisingly complex, primarily due to interactions with other features such as type classes, type families and GADTs, and have led to the introduction of roles as an aspect of the type system intended to reason about run-time representations more precisely. In this episode, we will explain why coerce is useful and how roles can help you understand what works and what does not.

13 Likes

I’m curious about the thumbnail prompt. Was the 6/9 joke in the prompt? Or did the AI decide to make it?

Sorry for the late reply. It was part of the prompt.

@kosmikus Just a request, could you do an episode on profiling an application.
Different types of applications like clis and webapps.
webapps are long running, how to profile them etc.

Thank you

4 Likes

I’ve added this to our long backlog of topics we might like to cover at some point. Thanks for the suggestion!

8 Likes