# Did you create Daml using Template Haskell?

**URL:** <https://forum.canton.network/t/did-you-create-daml-using-template-haskell/3364>\
**Category:** App Development\
**Created:** [October 24, 2021, 8:05am UTC](https://forum.canton.network/t/did-you-create-daml-using-template-haskell/3364 "2021-10-24T08:05:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gyorgybalazsi](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/gyorgybalazsi/32/684_2.png) [@gyorgybalazsi](https://forum.canton.network/u/gyorgybalazsi)\
**Post date:** [October 24, 2021, 8:05am UTC](https://forum.canton.network/t/did-you-create-daml-using-template-haskell/3364/1 "2021-10-24T08:05:57Z")

</div>

In the [Creating you own bindings](https://docs.daml.com/app-dev/bindings-x-lang/index.html) section of the docs you mention Template Haskell as an alternative to codegen.

I don’t know anything about Template Haskell (yet) but I became interested.

Since we know that Daml is based on Haskell, this connection raises the question for me: did you create Daml using Template Haskell in the first place?

---

<div class="post-metadata">

**Author:** ![cocreature](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/cocreature/32/36_2.png) [@cocreature](https://forum.canton.network/u/cocreature)\
**Post date:** [October 24, 2021, 8:31am UTC](https://forum.canton.network/t/did-you-create-daml-using-template-haskell/3364/2 "2021-10-24T08:31:09Z")

</div>

We do use TemplateHaskell in our code base if that’s what you’re asking. However, we use it very sparingly. From a quick look at our codebase and my own memory, we only use it for generating lenses in a few places (and we use lenses sparingly as well) which is only a handful of places across the whole codebase.

Personally, I’m not a huge fan of TemplateHaskell. It leads to slow compilation times, it breaks cross-compilation, it leads to a nightmare of linker errors in any reasonably complicated setup & it is often quite hard to understand.

If you are looking to build Haskell bindings for Daml, I’d recommend to go the codegen route using something like [gRPC-haskell](https://github.com/awakesecurity/gRPC-haskell).

---

<div class="post-metadata">

**Author:** ![gyorgybalazsi](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/gyorgybalazsi/32/684_2.png) [@gyorgybalazsi](https://forum.canton.network/u/gyorgybalazsi)\
**Post date:** [October 24, 2021, 8:37am UTC](https://forum.canton.network/t/did-you-create-daml-using-template-haskell/3364/3 "2021-10-24T08:37:56Z")

</div>

Thanks, will check it out

---

<div class="post-metadata">

**Author:** ![Stephen](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/stephen/32/102_2.png) [@Stephen](https://forum.canton.network/u/Stephen)\
**Post date:** [October 25, 2021, 7:20pm UTC](https://forum.canton.network/t/did-you-create-daml-using-template-haskell/3364/4 "2021-10-25T19:20:13Z")

</div>

The [original discussion that produced the linked docs](https://github.com/digital-asset/daml/pull/1569#discussion_r292534661) should be illuminating.

To expand on that, I would give a different recommendation from @cocreature: if you’re building a codegen _for some language_, figure out what parts the language’s metaprogramming features are good at, and what parts code-generation is better at, and build accordingly.

For example, the Scala codegen is such a hybrid: generating code for some tasks, using simple features to avoid generating code for other tasks (e.g. avoiding generating static methods with `TemplateCompanion`), and using language-specific metaprogramming to avoid generating code for yet other tasks (e.g. API value encoding and create/exercise typeclasses).

---

<div class="post-metadata">

**Author:** ![gyorgybalazsi](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/gyorgybalazsi/32/684_2.png) [@gyorgybalazsi](https://forum.canton.network/u/gyorgybalazsi)\
**Post date:** [October 26, 2021, 6:10am UTC](https://forum.canton.network/t/did-you-create-daml-using-template-haskell/3364/5 "2021-10-26T06:10:18Z")

</div>

That’s really interesting, I will check out the discussions connected to other parts of the docs too.
