Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is this expected behavior of Template Haskell?

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?

like image 869
Alexey Vagarenko Avatar asked May 16 '15 09:05

Alexey Vagarenko


1 Answers

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.

like image 110
tomferon Avatar answered Sep 23 '22 15:09

tomferon