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

Ale*_*nko 6 haskell template-haskell haskell-lens

任何人都可以告诉为什么这段代码不能编译

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

type B = String
Run Code Online (Sandbox Code Playgroud)

与消息

Not in scope: type constructor or class B
Run Code Online (Sandbox Code Playgroud)

这样做:

type B = String

data A = A {
  _b  :: B
}
makeLenses ''A
Run Code Online (Sandbox Code Playgroud)

没有makeLenses一切编译好.

为什么我不能在makeLenses之后有类型的synonim声明?

tho*_*ron 8

只有模板haskell调用之前的定义才可以在作用域中访问.

请参阅上一个关于同一主题的问题:Haskell:模板Haskell和范围.