how do you create an observer for a map?

observer accepts arbitrary expressions with the template arguments in scope. So you can write an expression that extracts the keys from your map. To do so, first convert to a list of (key, value) pairs and then use map fst to throw away the values. Here’s a full example:

module Main where

import DA.Next.Map (Map)
import qualified DA.Next.Map as Map

data CustomObj = CustomObj
  deriving (Eq, Show)

template T
    sig : Party
    m : Map Party CustomObj
    signatory sig
    observer map fst (Map.toList m)

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top