[racket] Typed Racket: Command-line parsing problems

From: Tim K. (tk at crono.co.uk)
Date: Mon Jun 24 09:50:13 EDT 2013

Thank you both Matthias and Roman for explaining those things so thoroughly :)


Matthias Felleisen <matthias at ...> writes:

> Second, here is why your code is potentially buggy. Suppose you used the
type of your mystringlistlist as an
> argument type to f. You could then apply f to '( () ), which is a list of
list of strings. If this argument flows
> to assoc, you violate the primitives basic constraint, namely, that each
item on the list consists of at
> least one cons cell. By saying (cons String (Listof String)) you are
saying list of non-empty list of
> strings, which fits the assoc type signature fine. 
>
> Third, the reason your code doesn't have a run-time error -- i.e. the type
error is conservative and the
> 'potential' is needed -- is because your specific list consists of
non-empty lists of strings. Even
> though TR can infer this type, your type assignment to this identifier
overrides TR's capabilities. 


Oh, I really didn't think that far here... I guess TR is a bit more strict
than I imagined.
Which is a good thing, of course. I'd rather have some headaches declaring
my functions and types correctly
than having to debug through layers of old code just because some symbol
went into some list where it
shouldn't have been.
But I see that I have to be more careful to prevent runtime errors in the
future.


Best Regards,
Tim



Posted on the users mailing list.