# Daml Finance interfaces

**URL:** <https://forum.canton.network/t/daml-finance-interfaces/5787>\
**Category:** App Development\
**Tags:** daml\
**Created:** [December 8, 2022, 4:15pm UTC](https://forum.canton.network/t/daml-finance-interfaces/5787 "2022-12-08T16:15:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![eriktim](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/eriktim/32/4395_2.png) [@eriktim](https://forum.canton.network/u/eriktim)\
**Post date:** [December 8, 2022, 4:15pm UTC](https://forum.canton.network/t/daml-finance-interfaces/5787/1 "2022-12-08T16:15:41Z")

</div>

Trying to grasp the concepts of Daml interfaces and its usage in Daml Finance.  
One of the things I noticed that for some interfaces, the `View` type exposes data that is only used by the implementation, not the interface. I understand anyone fetching that interface contract would get access to the data as well, but in some cases I am confused on whether that is desired.

To give a concrete example, please look at the interface [NumericObservable](https://github.com/digital-asset/daml-finance/blob/0e26d54d0a187f799243c317bc16c0b1dcd2d068/src/main/daml/Daml/Finance/Interface/Data/NumericObservable.daml) and an implementation [`Observation`](https://github.com/digital-asset/daml-finance/blob/0e26d54d0a187f799243c317bc16c0b1dcd2d068/src/main/daml/Daml/Finance/Data/Numeric/Observation.daml). `View` contains `observations`, being a `Map Time Decimal`, but it also defines a non-consuming choice `Observe`, which seems to contain the logic of observing those `observations` at some time `t`. Now what would be the rationale to expose the `observations` in the view in this case?

---

<div class="post-metadata">

**Author:** ![Matteo\_Limberto](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/matteo_limberto/32/2823_2.png) [@Matteo\_Limberto](https://forum.canton.network/u/Matteo_Limberto)\
**Post date:** [December 8, 2022, 5:33pm UTC](https://forum.canton.network/t/daml-finance-interfaces/5787/2 "2022-12-08T17:33:42Z")

</div>

Hi @eriktim,

Thanks for your question.

A rationale for exposing data in the `view` is for e.g. displaying purposes in a template-agnostic UI. Your UI would work only against the interface type rather than the concrete template type.

In the specific case of `NumericObservable`, however, it is indeed undesirable to expose the `observations` in the `view`, as that would prevent us from defining additional observation templates such as the below. We will rectify this in an upcoming Daml Finance version.

Thanks,  
Matteo

```haskell
-- | Observe 1.0 if a credit event has happened, 0.0 otherwise
template CreditEventObservation
  with
    provider : Party
      -- ^ The reference data provider.
    id : Id
      -- ^ A textual identifier.
    creditEventTime : Optional Time
      -- ^ Identifies when a credit event has happened.
    observers : PartiesMap
      -- ^ Observers.
  where
    signatory provider
    observer Disclosure.flattenObservers observers

    interface instance NumericObservable.I for CreditEventObservation where
      observe t =
        case creditEventTime of
          Some s | t >= s -> pure 1.0
          _ -> pure 0.0

```

---

<div class="post-metadata">

**Author:** ![eriktim](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/eriktim/32/4395_2.png) [@eriktim](https://forum.canton.network/u/eriktim)\
**Post date:** [December 9, 2022, 8:00am UTC](https://forum.canton.network/t/daml-finance-interfaces/5787/3 "2022-12-09T08:00:11Z")

</div>

Ah in that sense the name `View` fits nicely as well 🙂  
Thanks for the clear explanation, @Matteo_Limberto!
