Everyone knows to open a TR reply and do:

> (:print-type expt)

right? It's fun :)

Robby

On Tue, Sep 27, 2016 at 3:40 PM, Vincent St-Amour
<stamo...@eecs.northwestern.edu> wrote:
> You are correct, the implementation of `expt` is not aware of that fact.
>
> However, TR assigns `expt` a type after the fact, and so is able to
> encode more precise properties.
>
> The particular one under discussion happens to not hold, as Pierpaolo
> explained.
>
> Vincent
>
>
>
> On Tue, 27 Sep 2016 08:36:43 -0500,
> Matthew Eric Bassett wrote:
>>
>> I do not believe this is an oversight.  The function expt has type
>> signature (-> Number Number Number).  Mathematically, yes, a^b is a real
>> when a and b are reals.  But the implementation of expt is not aware of
>> it (it is, in principle, possible to do case-by-case types for a
>> function, but expt does not appear to take advantage of this).
>>
>> Because of this, (expt a b) is a Number, but your function definition
>> requires it to be the more restrictive Real.  Since you know that a and
>> b are reals, you could probably get away with a cast to Real.
>>
>> On 09/27/2016 02:23 PM, Tim Brown wrote:
>> > The following snippet:
>> >
>> > --------------------------
>> > #lang typed/racket
>> > (: ** [Real Real -> Real])
>> > (define (** a b)
>> >   (expt a b))
>> > --------------------------
>> >
>> > Throws:
>> > unsaved editor:5:2: Type Checker: type mismatch expected: Real given: 
>> > Number in: (expt a b)
>> >   #(67 10)
>> >
>> >
>> > I believe (because I can’t think of a counterexample) that
>> > (expt Real Real) is never Complex; and therefore expt can be of type
>> > (Real Real -> Real).
>> >
>> > First off, is the statement above true?
>> >
>> > Is there a technical reason why my example HAS TO fall back to
>> > (Number Number -> Number)? Or is this simply an oversight?
>> >
>> > Regards,
>> >
>> > Tim
>> >
>> > Version: 6.6.0.4--2016-09-08(-/f) [3m].
>> >
>>
>> --
>> Matthew Eric Bassett | http://mebassett.info
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to racket-users+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to