[plt-scheme] match for Promise
On Sun, Feb 28, 2010 at 3:08 PM, David Herman <dherman at ccs.neu.edu> 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.]
I'm cool with that if others and Sam are. I'm also not super attached
to the name, but it is what I thought of at the time.
Jay
>
> 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
>
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
--
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://teammccarthy.org/jay
"The glory of God is Intelligence" - D&C 93