Skip to content
CCPEDIAby Unity Nodes
App Development

Parse error in pattern: exercise Possibly caused by a missing 'do'?

2 posts700 views3 likesLast activity Sep 2020

  1. Muhammad_MoizOP 1

    Hi, EveryOne I want to save the current date and time. I do following but get this error I search on the network but can’t able to solve it

        template Attandance 
            with
                systemUser : Party
                associate : Optional Party
                punchInTime : Optional Time
                punchOutTime :Optional Time
            where 
                signatory systemUser
                nonconsuming choice PunchIn 
                    : ContractId Attandance
                    with
                        currentTime : Time
                    controller associate 
                       do 
                        create this with punchInTime = Some currentTime 
                nonconsuming choice PunchOut 
                    : ContractId Attandance
                    with
                        currentTime : Time
                    controller associate 
                       do 
                        create this with punchOutTime = Some currentTime
    

    Here is my scenario of update punchIn but it show me error when i exercised PunchIn exercise
    Parse error in pattern: exercise
    Possibly caused by a missing ‘do’?

    atid <- submit systemUser do
            create Attandance
                with
                    systemUser
                    associate  = None   
                    punchInTime = None
                    punchOutTime = None   
     submit associate do
            exercise asid PunchIn with
                currentTime <- getTime
        return()
  2. SamirTalwar 2

    You’ll need to run getTime on a separate line. Something like:

    submit associate do
      currentTime <- getTime
      exercise asid PunchIn with currentTime
    

    I don’t think you can use <- syntax in a with block like that. I do think we need a better error message, but unfortunately I expect this is part of GHC and therefore we have limited ability to change it.