Skip to content
CCPEDIAby Unity Nodes
App Development

I have just discovered that you can use guards in the `case` pattern

2 posts299 views7 likesLast activity Mar 2021

  1. gyorgybalazsiOP 5

    Might be useful for other Daml-ers as well.

    Source: dablchat/V3.daml at e648049b6d74805ed85154518ab7a89194326d2a · digital-asset/dablchat · GitHub

  2. anthony 2

    Great tip, here’s the text version for easier reading / searching

    case optAliasCid of
        Some cid | alias /= "" -> do
            newCid <- exercise cid SelfAlias_Rename with newAlias = alias
            return $ Some newCid
        Some cid | alias == "" -> do
            archive cid
            return None
        None | alias /= "" -> do
            cid <- create SelfAlias with ..
            return $ Some cid
        _ -> return None