
On 2/5/20 12:53 PM, Levent Erkok wrote:
The SBV library (https://hackage.haskell.org/package/sbv) uses the ideas in Andy Gill’s Observable sharing paper (http://www.ittc.ku.edu/~andygill/papers/reifyGraph.pdf) to safely observe sharing. Expressions remain pure, so long as “observation” of the sharing is done in the IO monad.
In my experience, this works really well and closely captures the application model: You want your users to program as if in a pure language, but the various backends (For SBV, this means C-compilation, SMTLib translation, Test-case generation etc.) already happens in a monadic framework, so it all works out rather nicely.
This would probably fit my case also.
SBV doesn’t use Andy’s data-reify package (https://hackage.haskell.org/package/data-reify), but that’s mostly historic. I’d definitely give that package a try. But if it doesn’t work for you for whatever reason (maybe the API doesn’t quite fit), Andy’s paper is extremely well written and you can easily use his ideas to roll your own.
Thanks for the pointers!