I would like to serialize small drawings in Rasterific to JSON.
I want to serialize programs/drawing actions such as:
withTexture (uniformTexture drawColor) $ do
fill $ circle (V2 0 0) 30
stroke 4 JoinRound (CapRound, CapRound) $
circle (V2 400 200) 40
How can I do such an serialization to JSON?
My ideas so far: Perhaps it is better to use the monoid instance. There is also an answer on stackoverflow that advises to use a 'data type' for function calls and an interpreter function that evaluated the code (ie. calls the function): How to serialize function type to json in haskell?