Closed dmelcer9 closed 4 years ago
Nice. I just asked the same thing in this hidden thread
To get around it, you could just flip the order of the last two arguments right?
I would consider that invalid, since match ought to only get inductive types. Instead, the same thing should be written as something like:
(define/rec/match fold : (X : Type) (Y : Type) (f : (-> X Y Y)) (List X) (b : Y) -> Y
[(nil X) => b]
[(cons X h t) => (f h (fold X Y f t b))])
def/rec/match doesn't allow non-inductive arguments to be both before and after inductive ones, I flipped the arguments for now.
Ideally, def/rec/match
wouldn't be sensitive to position in this way, and could match on named arguments, but that's an improvement for later. Might be able to mimic that by returning a function in the branches if that's the interface you really want.
Say we have the following function:
Even though we aren't destructing b, cur gives the error: