Ever confusing implementations in DAML.

How to best understand base interface below? Why can’t we do the same with Templates?

  asBaseInstrument : BaseInstrument.I
    -- ^ Conversion to `Base Instrument` interface.
.......
.......
.......

-- | Type constraint for requiring templates to implement `Distribution`.
type Implementation t = (HasToInterface t Event, Base.Implementation t)
class (Implementation t) => HasImplementation t
instance HasImplementation Event
instance HasToInterface I Base.I where _toInterface = asEvent

Please open a separate thread per question. Otherwise, the discussions get messy and hard to follow. You have at least three topics here.

@code_monkey @Gary_Verhaegen I’ve trimmed the question to what I think is a single one. Here’s what’s left:

What are the design patterns implemented in [daml-finance] (GitHub - digital-asset/daml-finance)? Why is DAML built on Haskell, rational plzzz? Is DAML still the same, write once and deploy anywhere? soooo many whyyyyy

These are separate topics, feel free to create a thread for each :slight_smile:

FYI @code_monkey You can use triple backticks to open and close a code block.

Hi @code_monkey,

To summarise, the reasons for this code pattern for interfaces in Daml-Finance are two fold:

  1. to enforce a hierarchy of interfaces (akin to extends in Java);
  2. at compile time to provide developer feedback that implementations adhere to the specified interface hierarchy.

At the time of writing, we don’t have the language feature in Daml Interfaces akin to extends in Java that provides the desired feature set above.

1 Like