6

Can anyone tell why this code doesn't compile

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

type B = String

with message

Not in scope: type constructor or class B

and this does:

type B = String

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

Without makeLenses everything compiles fine.

Why can't I have type synonim declaration after makeLenses?

Anupam Jain
  • 7,851
  • 2
  • 39
  • 74
Alexey Vagarenko
  • 1,206
  • 8
  • 15

1 Answers1

8

Only the definitions before the template haskell call are accessible in the scope.

See this previous question on the same topic: Haskell: Template Haskell and the scope.

Community
  • 1
  • 1
tomferon
  • 4,993
  • 1
  • 23
  • 44