Using Template Haskell to generate boilerplate code
anyone fancy reading this draft Template Haskell blog post? I'd like feedback on its clarity before I hit Publish. TIA!
Google memories (4/x)
but if you're working-class, something in the atmosphere nagged at you. my (then) wife felt it, too. the way everybody acted so high and showy, the expensive barbecue outings, the invisibility of the cleaning ladies, the second-class status of "contractors, temps, and part-timers". nobody gave a second thought to the fact that our weekly TGIF parties meant shorter Fridays for us but longer Fridays to the women doing our dishes.
Completed some Template Haskell meta programming and thoroughly proud of it https://github.com/jmtd/liquorice/commit/d115222ffe5a7058fe5e674272de00c0bebbee6d
Someone on Reddit pointed out there’s always unsafePerformIO
I’m now fairly sure this is impossible. I must bow down and accept Q into my heart
λ> 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
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'
A sleep and a shower and I think I have figured this out.
I might have to thank Mira showers in my thesis
If I wanted to generate code, easy: $(...). But pretty printing expressions to strings and escaping Q? More difficult
The first part is easy: [| foo |] gets me Q Exp. and within Q I can do whether I want with Exp. but getting out of Q is tough
I want to permit the user to write Haskell but then do stuff with the parsed expression tree and write it out to files
New blog post: Template Haskell
Blog post: Introducing Red Hat UBI OpenJDK runtime images
new blog post: Amiga floppy recovery project: what next?
Kernel.org after-party social