是否可以显示应用 Haskell 类型族函数的结果?

Is it possible to display the results of applying a Haskell type family function?

例如,如果我有这些奇怪的类型:

{-# LANGUAGE TypeFamilies #-}
type family WeirdFamily a
type instance WeirdFamily () = Int
type instance WeirdFamily (a, b) = (a, WeirdFamily b)

我可以通过键入类似以下内容来显示(例如在 GHCi 中)WeirdFamily (Bool, (Char, ())) 的结果:

:t WeirdFamily (Bool, (Char, ()))

加入 GHCi?

所以我找到了答案。在 GHCi 中输入:

f :: WeirdFamily (Bool, (Char, ())); f = undefined
:t f

给出f :: (Bool, (Char, Int))

但感觉应该有一种“更干净”的方式。有吗?

使用kind!.

:kind! WeirdFamily (Bool, (Char, ()))
WeirdFamily (Bool, (Char, ())) :: *
= (Bool, (Char, Int))