[Haskell-cafe] need help with understanding expression

damodar kulkarni kdamodar2000 at gmail.com
Sun Nov 25 04:19:35 CET 2012


Hi,
Thanks for the clarification.

This is clearly depravity.


I am confused, in what sense this is depravity?

Damodar

On Sun, Nov 18, 2012 at 7:27 AM, Albert Y. C. Lai <trebla at vex.net> wrote:

> 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 at haskell.org
> http://www.haskell.org/**mailman/listinfo/haskell-cafe<http://www.haskell.org/mailman/listinfo/haskell-cafe>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20121125/0d17ad3d/attachment.htm>


More information about the Haskell-Cafe mailing list