Is there a simple existing library that provides views of data types in
terms of unit, product and sum?
Here's what I threw together for my own use. I used associated types,
though functional dependencies would work as well.
class HasView t where
type View t
view :: t -> View t
Hello Conal,
What you've done looks very much like the Regular datatype [1] in the
rewriting library [2]. The rewriting library, as its name indicates, is very
much targeted at rewriting. For a more complete library using a sum of
products view (and without type synonyms), try the new release of E