-
-
Notifications
You must be signed in to change notification settings - Fork 38
Open
Description
#lang racket
(require redex)
(define-language A (N ::= 0 1 2))
(define-metafunction A
flip : N -> N
[(flip 1) ()]
[(flip ()) 1])
(term (flip 1))
; flip: codomain test failed for (), call was (flip 1) [,bt for context]
(term (flip ()))
; flip: (flip ()) is not in my domain [,bt for context]
Ideally, the clauses in the definition of flip
would be rejected because ()
does not match the grammar N
, so they can never be used correctly. Checking #:pre
and #:post
conditions would also be great, but I'm not sure this is possible. (Also I wouldn't be too surprised if it is possible to write expressions that can't be typechecked at function declaration time, but there are lots of examples like this one where the pattern definitely has empty intersection with the grammar, so an error message seems warranted.)
Metadata
Metadata
Assignees
Labels
No labels