I am writing a raytracer in Haskell, and currently I define my scene in code like this:
(Scene [(Sphere (Vec3 1 0 0) 4 (PhongMaterial (color 1 0 0) (color 1 1 1) 4))] [(PhongLight (Vec3 0 0 0) (color 1 1 1) (color 1 1 1))])
This works very well in terms of expressiveness, and it's great because I donβt need to write any parser, but that means I have to recompile every time I want to display a different scene. I came to Haskell through Lisp, where it would be simple (upload a file, eval contents, and then visualize the result), but I admit that Haskell has traits that make this, if not impossible, then very complicated.
Do any of you more experienced Haskellers have any suggestions on the best way to solve this? In an ideal world, I would have a file external to my code that would define a scene in Haskell syntax that I could load; in the least ideal world, I could write a parser in Parsek. Thanks!
source share