# Specifying symbol type for \`HasField x r a\`

**URL:** <https://forum.canton.network/t/specifying-symbol-type-for-hasfield-x-r-a/701>\
**Category:** App Development\
**Tags:** 1\_2\_0, daml-sdk\
**Created:** [June 22, 2020, 9:00am UTC](https://forum.canton.network/t/specifying-symbol-type-for-hasfield-x-r-a/701 "2020-06-22T09:00:38Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Martin\_Huschenbett](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/martin_huschenbett/32/372_2.png) [@Martin\_Huschenbett](https://forum.canton.network/u/Martin_Huschenbett)\
**Post date:** [June 22, 2020, 12:25pm UTC](https://forum.canton.network/t/specifying-symbol-type-for-hasfield-x-r-a/701/2 "2020-06-22T12:25:26Z")

</div>

Hi Luciano,

that’s a very interesting problem. The solution mostly involves sprinkling a few more types across your code. Despite that, you will still need to enable the `AllowAmbiguousTypes` language extension because the type parameter `f` only appears within the type class constraints.

First of all, you need to tell the compiler that you want to access the `x` field in `updateInner`'s `setField` and `getField`:

```haskell
updateInner : forall x f. (Functor f, HasField x Outer (f Inner)) => (Inner -> Inner) -> Outer -> Outer
updateInner fi o = setField @x (fmap fi (getField @x o)) o

```

Notice how we added `@x` type applications to `setField` and `getField`. For `x` to be in scope at these places, we need to _explicitly_ introduce it (and also `f`) using the `forall x f.` abstraction in the type signature of `updateInner`. Having the `x` as the first type parameter makes call sites more convenient since you only have to provide the field name, as in `updateInner @"a"`, and don’t need to provide the functor, for field `a` it would be `Optional` here. Thus, if we assume `type Inner = Int`, we can use `updateInner` like

```haskell
incrementA : Outer -> Outer
incrementA outer = updateInner @"a" (\i -> i + 1) outer

```

I hope that solves your problem,

Martin.

---

_[View the full topic](https://forum.canton.network/t/specifying-symbol-type-for-hasfield-x-r-a/701)._
