[Haskell-cafe] Looking for a paper [Dijkstra-Dot]
Olaf Klinke
olf at aatal-apotheke.de
Wed Jun 10 19:37:04 UTC 2020
Now I can't tell whether you're teasing to keep this thread alive. If
it is humour, it is lost on me.
> Report section 6.4.1 Numeric Literals. "An integer literal represents
> the application of the function `fromInteger` to the appropriate
> value
> of type `Integer`."
>
> OK. How do we write in Haskell that "appropriate value"?
>
To me that part of the report is obviously about compile-time code
generation. The sentence itself is not recursive, it is "literal"
versus "value". The two concepts live in different domains. Why do you
think its meaning may be recursive?
I imagine that when the compiler sees the literal 7, it de-sugars to
(fromInteger (mkInteger ...)) where the inner expression is code from
GHC.Integer that does not invoke fromInteger again. When the entire
expression is to be of type Integer, then the fromInteger dictionary
lookup replaces that by id. So the entire expression can be optimized
to be whatever core expression generates the Integer seven, most likely
S# 7#.
Olaf
More information about the Haskell-Cafe
mailing list