我想将Rasterific中的小图纸序列化为JSON。
我想序列化程序/绘图操作,例如:
withTexture (uniformTexture drawColor) $ do
fill $ circle (V2 0 0) 30
stroke 4 JoinRound (CapRound, CapRound) $
circle (V2 400 200) 40
如何对JSON进行此类序列化?
到目前为止我的想法:也许最好使用monoid实例。 stackoverflow还有一个答案,它建议使用“数据类型”。用于函数调用和评估代码的解释器函数(即调用函数):How to serialize function type to json in haskell?