On May 21, 2010, at 3:51 AM, Brent Yorgey wrote:

On Thu, May 20, 2010 at 11:53:09AM +1200, Richard O'Keefe wrote:

On May 20, 2010, at 3:18 AM, Brent Yorgey wrote:

On Wed, May 19, 2010 at 04:27:14AM +0000, R J wrote:

What are some simple functions that would naturally have the following
type signatures:
f :: (Integer -> Integer) -> Integer

The key point is the 'that would NATURALLY have', which I take
to mean "as a result of type inference without any forcibly
imposed type signatures".

Given that this is an exercise in Chapter 1, I kind of doubt this is
really what it is supposed to mean.  Are people reading chapter 1
really expected to understand the intricacies of type inference and
the Num class?  And to know about 'toInteger' and the fact that
numeric constants are polymorphic?  I really doubt it.  I read the
question much more simply, with "naturally" having a much more
informal meaning than you suggest.  I interpret the question as simply
getting the reader some practice with basic higher-order types.

The other possibility, of course, is a setup where Integer is the
default type, so the function should just be f g = g 0 + 0.
But "naturally" has to mean *something*, and the questions are
clearly about type inference.


_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to