rusp icon indicating copy to clipboard operation
rusp copied to clipboard

Pattern matching on types

Open Aatch opened this issue 12 years ago • 1 comments

Since we seem to be going for dynamic, strong typing, it would be nice to have a way to pattern match on types. This should just be another pattern, so it can be used anywhere patterns can be used.

I'm not sure of the exact syntax here, since just doing (match val ((a int) (do_stuff))) would conflict with structure matching. I am leaning towards having: (match val (a:int (do_stuff))), which would match that arm if val is an integer type.

I haven't thought too hard about any potential issues involved with this.

Aatch avatar Jun 05 '13 02:06 Aatch

I'm not sure about not using s-exprs for this. Maybe (: a int), like typed racket would be more consistent, although this probably also interacts poorly with pattern matching. That said, the current pattern matching syntax is extremely ad-hoc and could/should be improved.

huonw avatar Jun 05 '13 04:06 huonw