# How to get the name of a template or data type

**URL:** <https://forum.canton.network/t/how-to-get-the-name-of-a-template-or-data-type/7314>\
**Category:** App Development\
**Tags:** daml\
**Created:** [July 15, 2024, 1:13pm UTC](https://forum.canton.network/t/how-to-get-the-name-of-a-template-or-data-type/7314 "2024-07-15T13:13:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cohen.avraham](https://avatars.discourse-cdn.com/v4/letter/c/a87d85/32.png) [@cohen.avraham](https://forum.canton.network/u/cohen.avraham)\
**Post date:** [July 15, 2024, 1:13pm UTC](https://forum.canton.network/t/how-to-get-the-name-of-a-template-or-data-type/7314/1 "2024-07-15T13:13:15Z")

</div>

Hello,  
Let’s say that I have the following template:

```haskell
template Hello
  with
    owner: Party
  where
    signatory owner

```

How can I print only the template name once I create it in a script? Is there something similar like the Haskell’s `typeOf` function?

---

<div class="post-metadata">

**Author:** ![bernhard](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/bernhard/32/356_2.png) [@bernhard](https://forum.canton.network/u/bernhard)\
**Post date:** [July 15, 2024, 2:05pm UTC](https://forum.canton.network/t/how-to-get-the-name-of-a-template-or-data-type/7314/2 "2024-07-15T14:05:05Z")

</div>

There is in the form of `TypeRep`, but the function to print those type representations is a dev-only feature, meaning it’s only available in Daml-LF `1.dev`. Might be of use in a test script, but cannot be used in a package that you deploy to the ledger:

```haskell
module Main where

import Daml.Script

template Hello
  with
    owner: Party
  where
    signatory owner

ttrFromCid : forall t . (Template t) => ContractId t -> TemplateTypeRep
ttrFromCid x = templateTypeRep @t

setup : Script ()
setup = script do
  owner <- allocatePartyWithHint "owner" (PartyIdHint "owner")

  helloCid <- submit owner do
    createCmd Hello with ..

  Some hello <- queryContractId owner helloCid

  let tr = ttrFromCid helloCid

  debug (templateTypeRepToText tr)

```

Requires in `daml.yaml`:

```haskell
build-options:
  - --target=1.dev

```

You’ll get output (in the IDE):

```haskell
Trace: 
  "-homePackageId-:Main:Hello"

```

---

<div class="post-metadata">

**Author:** ![cohen.avraham](https://avatars.discourse-cdn.com/v4/letter/c/a87d85/32.png) [@cohen.avraham](https://forum.canton.network/u/cohen.avraham)\
**Post date:** [July 15, 2024, 4:33pm UTC](https://forum.canton.network/t/how-to-get-the-name-of-a-template-or-data-type/7314/3 "2024-07-15T16:33:07Z")

</div>

Thanks @bernhard,  
Why is this limited to dev only? I would like to have this not only in dev environment.

---

<div class="post-metadata">

**Author:** ![bernhard](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/bernhard/32/356_2.png) [@bernhard](https://forum.canton.network/u/bernhard)\
**Post date:** [July 16, 2024, 12:52pm UTC](https://forum.canton.network/t/how-to-get-the-name-of-a-template-or-data-type/7314/4 "2024-07-16T12:52:06Z")

</div>

Adding stable features has ongoing cost as Daml has strong backwards compatibility guarantees. Whether this particular feature has enough value is not clear. We have opened a ticket here for discussion: [Investigate impact/need of providing template names in Daml Script · Issue #19604 · digital-asset/daml · GitHub](https://github.com/digital-asset/daml/issues/19604)
