Hello folks! I've been trying to get into the habit of putting type declarations on everything I write in Chicken, to get the benefits of the lovely scrutinizer: type checks, specialisations, etc!
I've also found that it's nice as documentation - I went around switching various bits of Ugarit to use typed records, and kept finding that some fields of structures were actually (or boolean ...), because I'd forgotten some things were optional. But now that's clear in the record definitions. I can certainly recommend using typed records and (: ...)-ing all your global definitions! It's being a worthwhile experience. Anyway, I have a question, as I can't figure out how to type one of my procedures. It's a (call-with-... <thunk>) wrapper. Indeed, it's this: (define (call-with-context-support global-rules thunk) (let ((top-level-context (parse-top-level-context global-rules))) (parameterize ((*context* top-level-context)) (thunk)))) So I typed it: (: call-with-context-support (list (-> *) -> *)) However, I ran into trouble when I used it like so: (define-values (dir-key dir-reused? files bytes) (call-with-context-support (vault-global-directory-rules vault) (lambda () (store-directory! vault fspath)))) (store-directory! ...) returns four values, and as call-with-context-support tail-calls the thunk, that works in practice. But the type checker doesn't like it, and complains that an anonymous lambda called tmp<some number> expects four arguments but is called with one! So: What type should I give call-with-context-support to make it clear that it returns whatever the thunk passed to it returns, multiple values and all? I could figure out how to do it with forall if I knew how many values to expect, but I want it to work for any number of arguments! Ta, ABS -- Alaric Snell-Pym http://www.snell-pym.org.uk/alaric/
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongnu.org/mailman/listinfo/chicken-users