[<<][meta_siso][>>][..]
Tue Aug 18 11:04:19 EDT 2015

Struct

This is actually not working because there is no terminator for leaf
nodes.

-- Data structures can be converted between target language
-- representation and embedding in Haskell (i.e. meta-level).
class MRepr m r => Struct m r a b where
  unpack :: r a -> b
  pack   :: b   -> r a
instance MRepr m r => Struct m r () () where
  unpack _ = ()
  pack   _ = nil
instance (Struct m r a (r a), Struct m r b (r b)) => Struct m r (a, b) (r a, r b) where
  pack (a, b) = cons (pack a) (pack b)
  unpack ab = (unpack a, unpack b) where (a, b) = uncons ab


In the end it would probably be a good idea to add a cleaner
representation...  For now it seems the notational overhead is too
high.




[Reply][About]
[<<][meta_siso][>>][..]