[plt-scheme] match for Promise
Oh-- I've no idea how to make it work with Typed Scheme, though. Sorry,
Dave
On Feb 28, 2010, at 2:08 PM, David Herman wrote:
> A quick implementation:
>
> ;; --
> #lang scheme/base
>
> (require scheme/match
> scheme/promise
> web-server/dispatch/extend)
>
> (define-coercion-match-expander promise promise? force)
> ;; --
>
> Example:
>
>> (define foo
> (delay (begin (printf "forced!\n") 42)))
>> foo
> #<promise:foo>
>> (match foo
> [(promise x) x])
> forced!
> 42
>
> [It seems to me define-coercion-match-expander is useful enough to belong in scheme/match.]
>
> Dave
>
> On Feb 27, 2010, at 1:02 AM, krhari at ccs.neu.edu wrote:
>
>> Hi,
>> In Typed Scheme, I have a structure which has a field of type
>>
>> (Promise (Pair A B)).
>>
>> Is it possible to use match for this(for Promise)?
>>
>> Thanks
>> Hari
>> _________________________________________________
>> For list-related administrative tasks:
>> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>