Re: TR issue with the type of expt

Matthew Eric Bassett <[email protected]>
Newsgroups gmane.comp.lang.racket.user,gmane.lisp.scheme.plt
Message-ID <[email protected]>
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+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected]
For more options, visit https://groups.google.com/d/optout.
signature.asc (application/pgp-signature, 819 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQIcBAEBCAAGBQJX6nXsAAoJEODaoE34V1BJMloQAJ09+/a52QnBmIiNql+4s8R/
nxeE7T5o1i3IfYQvwDs+aBY/NC2iDT0zhuoTYb8eLCe6zpbOPLrDdhcqv+sk8CQG
iC6zV59UdtAqtEQhRc4XJH0ebDGCYf7K4KZt2jItIq8f+iR+jCAWh2eAACrqAlQt
qPsft6gPBAiRrDlZnvclDdl/PPNcz9Lfcn5BjADkILzIWhr4ZZKu4JcRBwOurXba
8OjRyB+cLEIzMMX4m2nGZ0Kzf9zU5pb3w1NNLWHdJC0XzlXTZx8lnlnK1GgNuMiq
I4Hyi2a48UKniXz6397VY0ce8FHe0PKxDIoZ1rxZUqw+OevGMGTZDK6U9CEn4RQB
XqtBoeci0mhQCe7nBV/qe8EQl/tt62oC08AH4N7Tx/il4vwGIDSELB9UEvEu6VTS
s2p1ktRjbW9J0aAwEpHGSWiFOKCTBGSkxKwCAPP9i3qM3UA1IXl78OVllrHnnuKq
Aoey2Z0Okll3cJxDXKxIVx+it386g6VSeBSMXRbaVB7yNkMyoFgvsuUN55q8Muyp
eN+PHDgq4i0hMoZ6ps7puoSQF5V2ddp9oL2uS2VyphSWKyviABfS+MXdB0cOsyBb
6y9zdd7grmYK8K9O/j7wv7y7LX0MTMzIW6O1PYYE7TNxxXm5CnsTBNET2t9SztE8
GkCaYV9QJrdZY5Y3YiRq
=yJlT
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.