Follow

Could this #haskell be improved using template haskell quasi-quotes/splices/etc without changing the type?

predFuse :: Exp -> Exp -> Exp

predFuse p' q' = let

x = mkName "x"

p = mkName "p"

q = mkName "q"

l = LamE [VarP p,VarP q,VarP x] (InfixE (Just (AppE (VarE p) (VarE x))) (VarE '(&&)) (Just (AppE (VarE q) (VarE x))))

in AppE (AppE l p') q'

@jmtd How about rewrite rules?

@dpwiz Do you mean GHC's rewrite rules?

Coincidentally, this is an excerpt of a (not GHC) rewrite rule from a code generator I'm writing

@jmtd I see... Perhaps a less dense code layout would be sufficient.

Jonathan Dowland@jmtd@kernel.socialHints:

λ> runQ [| \p q x -> p x && q x |]

LamE [VarP p_0,VarP q_1,VarP x_2] (InfixE (Just (AppE (VarE p_0) (VarE x_2))) (VarE GHC.Classes.&&) (Just (AppE (VarE q_1) (VarE x_2))))

λ> :t runQ [| \p q x -> p x && q x |]

runQ [| \p q x -> p x && q x |]

:: Language.Haskell.TH.Syntax.Quasi m => m Exp