[Yhc] coreFunc has extra argument
shackell at cs.york.ac.uk
Tue Mar 4 07:09:27 EST 2008
> I believe
> 'tackling the awkward squad' explains the World parameter.
Indeed this is the 'World' parameter. It's quite easy to see why it's
needed. Image the getChar function ...
getChar :: IO Char
if we imagine that the World parameter wasn't present, this would make
the type of getChar.
getChar :: _E Char
Since _E is just a box this is basically the same as.
getChar :: Char
Since this doesn't take any arguments it's a CAF, i.e. a constant value.
Since it's constant, every call to getChar would always return the same
When we add the World parameter we turn getChar into.
getChar :: World -> Char
Now getChar takes an argument, so its value is no longer constant (its
value can vary depending on the argument). Haskell neither knows, nor
cares, that getChar doesn't even look at the World argument. As far as
Haskell is concerned getChar has an argument so Haskell can't treat it
like a constant.
In other words, it's all some nasty trickery to make impure functions
work correctly in Haskell ;)
Hope that explains it :)
More information about the Yhc