disco-lang / disco

Functional teaching language for use in a discrete mathematics course
Other
164 stars 23 forks source link

Get rid of fraction arithmetic patterns #351

Open byorgey opened 2 years ago

byorgey commented 2 years ago

Currently,

Disco> f : Q -> N
Disco> f(2/4) = 6
Disco> f(1/2)
Error: value did not match any of the branches in a case expression.

In fact f is completely undefined, since the pattern 2/4 will never match anything; rational inputs are always reduced, and the numerator and denominator will be matched literally.

The above is a little strange, and maybe not worth fixing, but I think the below is more troubling:

Disco> f : F -> N
Disco> f(n/4) = n
Disco> f(1/2)
Error: value did not match any of the branches in a case expression.

I would expect to get 2 as a result.

byorgey commented 1 year ago

Should sketch out a detailed design for the semantics of matching.

byorgey commented 2 months ago

Related: #32 .

byorgey commented 2 weeks ago

Another option is to just get rid of fraction patterns entirely. After hours of thinking about them, discussing with students, etc. I still can't really make heads or tails of what they are supposed to mean. They really aren't that useful either, so getting rid of them would just simplify a lot of things.