
On Thu, Dec 27, 2012 at 11:48 PM, Rustom Mody
On Thu, Dec 27, 2012 at 8:26 PM, Kim-Ee Yeoh
wrote: What he really wants methinks is a way to suppress type classes altogether! That or a NoOverloadedNumerals extension.
I'm not really sure about that... Look!
Prelude> :t [[1,2],3] [[1,2],3] :: (Num [t], Num t) => [[t]]
As Satvik explained, well-typed does not imply instantiable. And with constraints, not instantiable /does/ imply not evaluable!
:set -XRebindableSyntax let fromInteger = id Prelude> :t [[1,2],3]
Couldn't match expected type `[Integer]' with actual type `Integer' Expected type: Integer -> [Integer] Actual type: Integer -> Integer In the expression: 3 In the expression: [[1, 2], 3]
You can see overloaded numerals at work again via the hidden hand of
fromInteger.
Presumably some imaginary NoOverloadedNumerals extension would thoroughly
purge its presence.
-- Kim-Ee
On Thu, Dec 27, 2012 at 11:48 PM, Rustom Mody
On Thu, Dec 27, 2012 at 8:26 PM, Kim-Ee Yeoh
wrote: Hi David, it looks like Rustom's aware that haskell's not lisp. What he
-- Kim-Ee
I'm not really sure about that... Look!
ghci with default startup --------------------
$ ghci GHCi, version 7.4.1: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. Prelude> :t [[1,2],3] [[1,2],3] :: (Num [t], Num t) => [[t]]
So it would appear that ghci is giving a well-typing for [[1,2], 3]. But is it?
Prelude> [[1,2],3]
<interactive>:3:8:
No instance for (Num [t0]) arising from the literal `3'
Possible fix: add an instance declaration for (Num [t0]) In the expression: 3 In the expression: [[1, 2], 3] In an equation for `it': it = [[1, 2], 3] ------------------- So is it well-typed in ghci or not??
And now we add Roman's suggestions... $ cat .ghci
:set -XRebindableSyntax let fromInteger = id
And run ghci again
$ ghci GHCi, version 7.4.1: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. Prelude> :t [[1,2],3]
<interactive>:1:8: Couldn't match expected type `[Integer]' with actual type `Integer' Expected type: Integer -> [Integer] Actual type: Integer -> Integer In the expression: 3 In the expression: [[1, 2], 3] Prelude> [[1,2],3]
<interactive>:3:8:
Couldn't match expected type `[Integer]' with actual type `Integer' Expected type: Integer -> [Integer] Actual type: Integer -> Integer In the expression: 3 In the expression: [[1, 2], 3] Prelude>
So far so good -- when an expression is type-wrong, its 'wrongness' is
really wants methinks is a way to suppress type classes altogether! That or a NoOverloadedNumerals extension. the same irrespective of whether I ask for its type or evaluate it.
But now we are in for new surprises: Try out f x y = x / y Prelude> :l f [1 of 1] Compiling Main ( f.hs, interpreted )
f.hs:1:11: Not in scope: `/' Failed, modules loaded: none. Prelude> (/)
Oh is it that now integer literals are just plain Integers and cant be
divided using '/' ??
So lets replace '/' with '+' f.hs:1:11: Not in scope: `+'
And now I am at my wits end!