[Haskell-beginners] Question about List Type Constraint and Null

aditya siram aditya.siram at gmail.com
Sat Jan 22 18:06:19 CET 2011


Ok I've figured out why I can't compile it. But now I'm more confused
than ever. The problem was that I have a -XNoMonomorphismRestriction
flag on Ghci. Removing this allowed me to compile.

But why?

-deech

On Sat, Jan 22, 2011 at 2:07 AM, Magnus Therning <magnus at therning.org> wrote:
> On 22/01/11 06:03, aditya siram wrote:
>> Hi all,
>> The following function gives me an "Ambiguous type variable `a' in the
>> constraint: `Read a' arising from a use of `res'" error:
>>   test :: Read a => String -> Maybe [(a,String)]
>>   test s = if null res then
>>              Nothing
>>            else
>>              Just $ fst $ head res
>>            where
>>              res = reads s
>
> This code doesn't give me that error, in fact it gives me no error at all.
>
> /M
>
> --
> Magnus Therning                      OpenPGP: 0xAB4DFBA4
> email: magnus at therning.org   jabber: magnus at therning.org
> twitter: magthe               http://therning.org/magnus
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at haskell.org
> http://www.haskell.org/mailman/listinfo/beginners
>
>



More information about the Beginners mailing list