I would like to implement term graphs in Haskell, so that I can implement a term rewriting engine that uses sharing. Something like
data TG f v = Var v | Op f [TG f v] | P (Ptr (TG f v))
And I would want something like the following to make sense:
let
t' = Op 'f' [Var 'x', Var 'y']
t = getPointer t'
in
Op 'g' [P t,P t]
Then during rewriting, I only have to rewrite t once.
However, I noticed two things: (1) the module is called Foreign.Storable, so should it only be used for FFI stuff and (2) there are no instances of Foreign.Storable for any types like lists; why is this?