Re: [Chicken-users] Correct type declarations for (call-with-... thunk) procedures

2015-01-11 Thread Evan Hanson
Hi Alaric,

I agree it would be nice if one could capture the multiple values case
with a `forall` type, e.g.

(: call-with-foo (forall (a) (foo (- . a) - . a)))

However, AFAIK there is currently no way to express this.

You can of course specify that `call-with-context-support` may return an
arbitrary number of values as follows:

(: call-with-context-support (foo (- . *) - . *))

This will silence the warnings from `csc(1)`, but obviously isn't ideal.

I've created a ticket[1] to track this feature request. Thanks for
bringing it up!

Evan

[1]: https://bugs.call-cc.org/ticket/1176

___
Chicken-users mailing list
Chicken-users@nongnu.org
https://lists.nongnu.org/mailman/listinfo/chicken-users


[Chicken-users] Correct type declarations for (call-with-... thunk) procedures

2014-11-15 Thread Alaric Snell-Pym
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 tmpsome 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