disco-lang / disco

Functional teaching language for use in a discrete mathematics course
Other
161 stars 22 forks source link

Division arithmetic patterns should be more liberal wrt equality? #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 1 month ago

Related: #32 .