Skip to content
CCPEDIAby Unity Nodes
App Development

Create an optional datatype from a normal one

2 posts156 viewsLast activity Jan 2024

  1. Divyansh_Gupta_ATR10OP

    I want to convert a data type into an optional Data type. I tried the following format:

    let newOptionalAdminId = Optional newAdminId
    

    However, I am getting the following error with this

        Data constructor not in scope:
          Optional : TalentId -> Optional TalentId
    

    TalentId is the contract ID for the Template Talent. How can I convert this into an optional datatype?

  2. cocreature

    The constructor for this is called Some, so

    let newOptionalAdminId = Some newAdminId
    

    Optional is just the name of the type.
    You might also be interested in the tutorial on Daml data types Data Types — Daml SDK 2.8.0 documentation and the docs for Optional Prelude — Daml SDK 2.8.0 documentation