这是模板 Haskell 的预期行为吗?

Is this expected behavior of Template Haskell?

谁能告诉我为什么这段代码不能编译

data A = A {
  _b  :: B
}
makeLenses ''A

type B = String

有消息

Not in scope: type constructor or class B

这样做:

type B = String

data A = A {
  _b  :: B
}
makeLenses ''A

没有 makeLenses 一切都可以正常编译。

为什么我不能在 makeLenses 之后声明类型同义词?

在范围内只能访问模板 haskell 调用之前的定义。

请参阅上一个关于同一主题的问题:Haskell: Template Haskell and the scope