[Haskell-beginners] Question on Real World Haskell ch.13 SymbolicManip
djp at arqux.com
Wed Jun 1 03:26:37 CEST 2011
Thanks. See below.
On 2011-05-31, at 9:14 PM, Brandon Allbery wrote:
> On Tue, May 31, 2011 at 20:48, Jake Penton <djp at arqux.com> wrote:
>> Ok, so far so good. But the following example seems quite astounding to me:
>> ghci> (5 * 10 + 2)::SymbolicManip Int
>> Arith Plus (Arith Mul (Number 5) (Number 10)) (Number 2)
>> The book says to notice that haskell "converted" 5 * 10 + 2 into a
>> SymbolicManip. Indeed!
>> My understanding breaks down at this point. I suspect that it may be my weak
>> grasp of the implications of lazy evaluation, and typeclasses generally. My
> It's not lazy evaluation; it's the combination of types and the
> automatic translation of literal values to calls to fromLiteral per
> the Haskell language definition. Since in this case, the type
I don't see fromLiteral in the language definition. Is it fromInteger that I should look at, maybe?
> produced by fromLiteral must be a SymbolicManip Int for the entire
> expression to work out to a SymbolicManip Int, each literal becomes
> (Number whatever) and then the operators are taken from SymbolicManip
> to preserve the type.
More information about the Beginners