New method for reporting TypeErrors on stuck type families

The blog post
Report stuck type families gives a method for giving type errors when a type family is stuck, however it seems hacky and ad-hoc.

type Any :: k
type family Any where

type Assert :: Constraint -> Type -> k -> k
type family Assert err break a :: k where
  Assert _ () _ = Any
  Assert _ _ k = k

Is there a better way, like ErrorIfStuck or something, or do open type families make this impossible?

I’m not aware of any better way given current GHC, but this ghc-proposal aims at adding one:

2 Likes