On 30/06/11 23:53, Arlen Cuss wrote:
[snip]

and modify the assignment in main to this:

    keyboardMouseCallback $= Just (myKeyMouse gameState)
I think that part of my confusion was, on reflection, caused by the fact that coming from a procedural background, the syntax of "Just (myKeyMouse gameState) still reads as "function call arguments", so if I may be permitted to expand on that to see if I now understand Haskell a little more ...

The form: "Just (myKeyMouse gameState)" looks like its calling the Just function with two parameters as the () is also used to define a tuple. So is (myKeyMouse gameState) a tuple of one, the result of calling that function with that parameter or is just a way of ensuring that the function is performed before it is passed to Just as the one and only parameter?

I know the correct  answer but I did sometimes get confused over when is a tuple "()" not a tuple, especially in things like this:

foo (x:xs) = ...

I *know* it is pattern matching using ':' and that ':' takes a thing and a list of things and returns a list of same things but old habits.. DOH!

Back to the chase.

If I had rewritten the Just called like this I think it would have been clearer about what was happening:

  Just $ myKeyMouse gameState

as that quite clearly says, call myKeyMouseFirst and then hand the result to Just. From that point, Arlens great description of how it trundles through the type system, resulting in a partially evaluated function that has the *same* type as the expected one for the keyboardMouseCallback is really making it clearer for me now. That was a loud Eureka moment in my kitchen over breakfast this morning I can tell you!

It just needs to settle in and join the rest of the facts jostling for top position on the "Don't forget..." list.

Once again "list", I thank thee muchly for helping this troubador of trouble travel the road to Haskell...

:)