# Template Modification Fails on Template Role

**URL:** <https://forum.canton.network/t/template-modification-fails-on-template-role/3017>\
**Category:** App Development\
**Tags:** daml, contract, examples\
**Created:** [August 20, 2021, 2:58am UTC](https://forum.canton.network/t/template-modification-fails-on-template-role/3017 "2021-08-20T02:58:00Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![quidagis](https://avatars.discourse-cdn.com/v4/letter/q/dbc845/32.png) [@quidagis](https://forum.canton.network/u/quidagis)\
**Post date:** [August 20, 2021, 2:58am UTC](https://forum.canton.network/t/template-modification-fails-on-template-role/3017/1 "2021-08-20T02:58:00Z")

</div>

Reference: [GitHub - digital-asset/boat](https://github.com/digital-asset/boat)

Am modifying the [Boat](https://github.com/digital-asset/boat) example with the goal of initially substituting ‘making a Boat’ to ‘planting a Pine Tree’. Once that all works, I’ll modify the Custody and Transfer roles into something more germane. Currently the only sticking point seems to be in the `template ManufacturerRole`.

> **template ManufacturerRole**
>
> ```haskell
> template ManufacturerRole
> with 
> manufacturer: Party
> coastGuard: Party 
> operator: Party 
> where 
> signatory operator
> observer coastGuard 
> 
> controller manufacturer can 
> nonconsuming Manufacture: ContractId Boat
> with 
> name: Text
> do 
> 
> ```

Exchanging the terms `manufacturer`, `coastGuard`, and `operator` for `seedling_planter`, `forest_compliance`, and `forest_operator` works OK.

> **Seedling\_PlanterRole**
>
> ```haskell
> template Seedling_PlanterRole
> with 
> seedling_planter: Party
> forest_compliance: Party 
> forest_operator: Party 
> where 
> signatory forest_operator
> observer forest_compliance
> 
> controller seedling_planter can 
> nonconsuming seedling_planter: ContractId Tree 
> with 
> name: Text
> do
> 
> ```

The error from `daml start` is:

```haskell
Range: 94:19-94:35
Source: parser
Severity: DsError
Message: daml/Main.daml:94:20: error:parse error on input ‘seedling_planter’
ERROR: Creation of DAR file failed.

```

Line 94 being: `nonconsuming seedling_planter: ContractId Tree`

However with the template below, I cannot get my head around what the `seedling_planter` equivalent for the `non-consuming Manufacture` should be.

---

<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:** [August 20, 2021, 7:02am UTC](https://forum.canton.network/t/template-modification-fails-on-template-role/3017/2 "2021-08-20T07:02:32Z")

</div>

The error is due to capitalization. Choice names need to be calitalized. I’d think that `Plant_Seedling` is to `seedling_planter` what `Manufacture` is to `manufacturer` so maybe go for `nonconsuming Plant_Seedling : ContractId Tree` in line 94.

---

<div class="post-metadata">

**Author:** ![Gary\_Verhaegen](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/gary_verhaegen/32/81_2.png) [@Gary\_Verhaegen](https://forum.canton.network/u/Gary_Verhaegen)\
**Post date:** [August 20, 2021, 9:20am UTC](https://forum.canton.network/t/template-modification-fails-on-template-role/3017/3 "2021-08-20T09:20:32Z")

</div>

Choice names are types (records, under the hood) and thus must start with a capital letter. ~~You’re also missing a keyword, which is more likely the immediate issue here: `nonconsuming` must be followed by `choice`; as in~~

EDIT: As @bernhard kindly pointed out in private, I missed the use of the `controller can` syntax, which does not include the `choice` keyword.

---

<div class="post-metadata">

**Author:** ![quidagis](https://avatars.discourse-cdn.com/v4/letter/q/dbc845/32.png) [@quidagis](https://forum.canton.network/u/quidagis)\
**Post date:** [August 21, 2021, 3:08am UTC](https://forum.canton.network/t/template-modification-fails-on-template-role/3017/4 "2021-08-21T03:08:17Z")

</div>

Thank you @bernhard und @Gary_Verhaegen 👍🏻

Now have:

- seedling\_planter instead of manufacturer (Noun)
- Plant\_Seedling instead of Manufacture (Verb)
- Removed two instances on `boat` that were in the Main.daml 🤦🏻‍♂️
- Removed duplicate `-- forest_compliance = forest_owner `

> **Works now with the exception on a single error.**
>
> ```haskell
> SDK 1.15.0 has been released!
> See https://github.com/digital-asset/daml/releases/tag/v1.15.0 for details.
> 
> SDK 1.15.0 has been released!
> See https://github.com/digital-asset/daml/releases/tag/v1.15.0 for details.
> 
> Compiling tree to a DAR.
> File: daml/Main.daml
> Hidden: no
> Range: 50:14-50:27
> Source: typecheck
> Severity: DsError
> Message: daml/Main.daml:50:15: error: Not in scope: ‘newCompliance’
> ERROR: Creation of DAR file failed.
> daml-helper: Received ExitFailure 1 when running
> Shell command: /home/quid/.daml/bin/daml build
> 
> ```

Line 50 `newCompliance = owner`

However I am not using the term `Compliance` but forest\_compliance`

I think that using `hyphenated_words` presents syntax-related issues, and that perhaps `hyphenatedwords` might be a better idea.

---

<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:** [August 22, 2021, 7:21pm UTC](https://forum.canton.network/t/template-modification-fails-on-template-role/3017/5 "2021-08-22T19:21:09Z")

</div>

Can you share the code you’re using now that produces this error?

As for snake\_case vs camelCase both are perfectly fine from a syntax pov. In Haskell, the convention is to use camelCase and we borrowed that for Daml so the standard library uses that consistently and I’d generally recommend to not deviate from that but it’s only a convention. Everything will work perfectly fine if you use snake\_case for your own identifiers.

---

<div class="post-metadata">

**Author:** ![Gary\_Verhaegen](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/gary_verhaegen/32/81_2.png) [@Gary\_Verhaegen](https://forum.canton.network/u/Gary_Verhaegen)\
**Post date:** [August 23, 2021, 8:49am UTC](https://forum.canton.network/t/template-modification-fails-on-template-role/3017/6 "2021-08-23T08:49:44Z")

</div>

I personally prefer snake\_case and use it liberally in both Daml and Haskell (at least when I don’t need to share it; if I’m writing a library, I follow community conventions); not only do I find snake\_case easier to read, I also quite like the fact that my identifiers are distinguishable at a glance from library identifiers.

Either way, the part the compiler cares about is that value identifiers start with a lowercase and type (and module) identifiers start with an uppercase. After that you can mix and match underscores, letters and numbers in any combination you see fit.

Your error message seems fairly consistent with your explanations, actually. What it seems to say is that, on line 50, you have

```haskell
  newCompliance = owner

```

and that is invalid because `newCompliance` does not exist in the current scope. You tell us you’re using `forest_compliance` as an identifier, so it’s not very surprising that `newCompliance` does not exist.

If that line is expected to introduce a new identifier, the syntax is incorrect. Depending on context, it must be either (in a `do` block, if right-hand-side is an action)

```haskell
newCompliance <- someActionOf owner

```

or (in a `do` block, if right-hand-side is a pure value)

```haskell
let newCompliance = owner

```

or (outside of a `do` block`)

```haskell
let newCompliance = owner
 in ...

```

The line `newCompliance = owner` _could_ be valid syntax for introducing a new binding, but only in the context of a `where` clause, and if that were the context you’re in, it wouldn’t be reporting an error.

The other possibilities I can see are:

- You want to do a comparison rather than introduce a new binding; in that case, you want `==` instead of `=`.
- You are trying to assign a value to the field of a record, in which case you need to change `newCompliance` to instead be the name of the field in that record (perhaps that is `forest_compliance`?).

As @cocreature mentioned, it would be a lot easier to help you if you provided a bit more context than the single failing line.
