[Haskell-cafe] Re: Hit a wall with the type system
Chris Smith
cdsmith at twu.net
Thu Nov 29 00:20:09 EST 2007
Luke Palmer wrote:
> I don't see why this should be true. Int -> Int is an instance of this type,
> but derivatives require limits, which integers don't have. Do you intend to
> output the difference sequence of the function in this case?
>
> But then Double -> Double is also an instance of this type. Do you intend
> to approximate the real derivative when it's specialized to this?
>
> Instead of worrying about the types, first tell us what semantics you want.
I intend to naively treat each function as being from the reals to the
reals, and then take advantage of the fact (which is proven by the type
system in the code I posted) that when the derivative is evaluated at
integer inputs for functions defined using only ring operations, the
result is an integer (and similarly for rationals and field operations).
Note that the functions here are defined over real numbers rather than
*merely* intervals, because the type given for diffNum, for example,
requires that the first parameter be no more specific than
Num a => a -> a... so one may not actually pass in a function of type
Int -> Int and expect the code to compile.
--
Chris Smith
More information about the Haskell-Cafe
mailing list