Skip to content

Instantly share code, notes, and snippets.

@entzik
Created November 4, 2020 23:27
Show Gist options
  • Save entzik/b8d4134251253f0b4d8180329ae0e7b3 to your computer and use it in GitHub Desktop.
Save entzik/b8d4134251253f0b4d8180329ae0e7b3 to your computer and use it in GitHub Desktop.
do
invite <- fetch inviteId
...
let
crtVotes = fromOptional (VotingSlot with count = 0, voted = []) (DA.TextMap.lookup option this.votes)
updatedVotes = DA.TextMap.insert option (VotingSlot with count = crtVotes.count + 1, voted = voter :: crtVotes.voted) this.votes
assertMsg "each voter is only allowed to cast one vote per option" (notElem voter crtVotes.voted)
create this with votes = updatedVotes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment