coalton icon indicating copy to clipboard operation
coalton copied to clipboard

Allow matching on other number types

Open eliaslfox opened this issue 2 years ago • 5 comments

Extend overloaded integer literals to patterns

eliaslfox avatar Mar 12 '22 06:03 eliaslfox

can someone please add more information as to what this issue is about? thanks

Jobhdez avatar Apr 12 '23 06:04 Jobhdez

Currently integer literal patterns must be of type Integer. Ideally it would be possible to pattern match on anything that implements Num.

This works:

 (coalton-toplevel
  (define (f x)
    (match x
      (5 "five")
      (_ "not five"))))

This does not:

 (coalton-toplevel
  (declare f (IFix -> String))
  (define (f x)
    (match x
      (5 "five")
      (_ "not five"))))

eliaslfox avatar Apr 13 '23 00:04 eliaslfox

Thank you.

Jobhdez avatar Apr 13 '23 00:04 Jobhdez

Ideally it would be possible to pattern match on anything that implements Num.

Num and Eq, I would think.

gefjon avatar Apr 13 '23 00:04 gefjon

Num implies Eq

eliaslfox avatar Apr 13 '23 00:04 eliaslfox