3 ms·
I love TH (though not as much as metalua and metaocaml), but I've never had the occasion to use it. I've used a library that uses TH to parse out my prop_foo i
by jrockway 15y ago
I love TH (though not as much as metalua and metaocaml), but I've never had the occasion to use it. I've used a library that uses TH to parse out my prop_foo into a main method that will run all the quickcheck tests, but that's about it.
Is there any particularly well-done TH being used somewhere in the real world? (You don't have to show me the code, just what problem you had that TH solved.)
- thedigitalengel 15y agoThere is a list here: http://www.haskell.org/haskellwiki/Template_Haskell#Projects http://www.haskell.org/haskellwiki/Template_Haskell#Projects I'm a Haskell newbie, and have not done much with TH yet. But I can imagine a bunch of TH code generating a lexer or a parser out of some meta-description. Like Happy, but with everything directly embedded in the source itself.
- pjscott 15y agoMy favorite is the MessagePack serialization protocol. The Haskell implementation (officially supported, yay) uses Template Haskell to derive serialization and deserialization code, with full type-checking, for arbitrary data structures. Check it out: https://github.com/msgpack/msgpack/blob/master/haskell/test/UserData.hs https://github.com/msgpack/msgpack/blob/master/haskell/test/...