GHC Generics is a fairly detailed way to execute basically any request or workaround. For example, consider the AST language with the types Stmt and Expr , which output Typeable , Generic and Data :
data Stmt = ... lots of constrs ... data Expr = Const Int | ... lots of other constrs ...
How do you use SYB to get all constants starting with Expr or Stmt ? Something like:
getConst (Const i) = [i] getConst _ = [] getAllConst = everything (++) (mkQ getConst)
Compare this to the typical use of Generics, which requires two classes, bypassing the sum of the product representations and instantiating the class N times for the N types that need to be passed. Where SYB and, indeed, most common systems will fall exactly in performance .
Thomas M. DuBuisson
source share