I am trying to create a Haskell program which draws some simple 2d shapes to screen, but when you hover over each shape, it prints the line of source code where the shape was created.
In order to do this I would like to be able to create shapes with parameters for their dimensions and a final parameter which indicates the line number. Something like this:
rect1 = Shape(Rectangle 2 2 lineNumber)
This would create a rectangle of width 2 pixels, height 2 pixels, and use a function lineNumber to store the line this piece of code was written on. Does such a function exist in Haskell? Is it simple to create one?
I have searched stack overflow and found this question where the answerer suggests that the __LINE__ pragma from C++ can be used to achieve a similar effect. Is this the best way to go about it or is there a way to do it in pure Haskell?