On 12-11-17 02:19 AM, damodar kulkarni wrote:
Let's see tthis:
Prelude> :t 3 "a"
3 "a" :: (Num ([Char] -> t)) => t

No complaint from GHC; but now see this:

Prelude> :t  "a" 3

<interactive>:1:0:
     Couldn't match expected type `t1 -> t'
            against inferred type `[Char]'
     In the expression: "a" 3

Why does it not fail for  (:t 3 "a") but does fail for (:t  "a" 3)?

3 is polymorphic, "a" is monomorphic (exactly [Char]).

To make "a" polymorphic, turn on OverloadedStrings:

:set -XOverloadedStrings
:type "a"

"a" :: Data.String.IsString a => a

:type "a" 3

"a" 3 :: (Num a, Data.String.IsString (a -> t)) => t

Success!

This is clearly depravity.

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to