emilaxelsson / syntactic

Generic representation and manipulation of abstract syntax
BSD 3-Clause "New" or "Revised" License
25 stars 13 forks source link

Typeable Instances for Datas #11

Closed crockeea closed 10 years ago

crockeea commented 10 years ago

When writing a domain-agnostic share, I needed to derive Typeable instances for several syntactic data types: https://gist.github.com/crockeea/07ea03c24aaea3efec81

I had to derive instances for Construct, BindingT, AST, and (:+:), but there are probably more that should be made Typeable. Perhaps using -XAutoDeriveTypeable would be a good solution.

emilaxelsson commented 10 years ago

I think you want Typeable (Internal a) instead of Typeable a in the type of share. Then you don't need Typeable for the various Syntactic types (but of course it doesn't hurt to add the instances).

A better type for share is:

share :: (Let :<: dom,
          BindingT :<: dom,
          Typeable (Internal a),
          dom ~ Domain b, dom ~ Domain a,
          Syntactic a, Syntactic b)
           => a -> (a -> b) -> b
share = sugarSym Let
crockeea commented 10 years ago

Thanks, I should have asked the expert first!