racket - Bad syntax error on define-type using #lang plai -
i'm getting bad syntax error on piece of code
deleted
and more specifically, error:
xxx:22.0: define-type: bad syntax in: xxx #(739 316)
i'm new language kind enough tell me what's wrong code , how rid of error?
the following problematic lines causing syntax-error:
i --> [give (expr1 oe?) name (id-ref1 symbol?) in (expr2 oe?)] ii --> [(string-literal string?)] iii --> [(id-ref2 symbol?)]
as noted in docs, define-type
has structure
(define-type type-id variant ...)
where
variant = (variant-id (field-id contract-expr) ...)
so, every variant must have variant-id, , each field-id must have associated contract. violation of cause of syntax-error.
in case of (i)
, both name , in lack contracts, possible fix adding contracts fields, such (using string?
example contract):
[give (expr1 oe?) (name string?) (id-ref1 symbol?) (in string?) (expr2 oe?)]
both (ii)
, (iii)
lack variant-ids, adding them fix problem:
[some-variant-id (string-literal string?)] [some-other-variant-id (id-ref2 symbol?)]
here possible rewrite of type, suggested changes:
(define-type oe (group (expr1 oe?) (expr2 oe?)) (sequentially (expr1 oe?) (expr2 oe?)) (together (expr1 oe?) (expr2 oe?)) (join (expr1 oe?) (expr2 oe?)) (arrive (expr oe?)) (give (expr1 oe?) (name string?) (id-ref1 symbol?) (in string?) (expr2 oe?)) (some-variant-id (string-literal string?)) (some-other-variant-id (id-ref2 symbol?)))
Comments
Post a Comment