google-research / dex-lang

Research language for array processing in the Haskell/ML family
BSD 3-Clause "New" or "Revised" License
1.58k stars 107 forks source link

Can't compose other effects with `with_stack` #1205

Closed duvenaud closed 1 year ago

duvenaud commented 1 year ago

Now that stacks have landed, I'm reviving quicksort. However, I can't seem to manipulate a reference inside of a with_stack. Here's a MWE:

def func {h} (xs: Ref h Nat) : {State h} Unit =
  with_stack Unit \stack.
    xs := 0

gives

Type error:
Expected: {State h.1}
  Actual: {State h|a}
(Solving for: [a])

    xs := 0
       ^^^
dougalm commented 1 year ago

Thanks for catching that. Fix is in #1206. Do you need pop too?

duvenaud commented 1 year ago

Thanks! D'oh, I should have been able to fix that myself. I already wrote pop myself though, thanks for the offer.