I could be wrong, as I am also new to Haskell. I suppose<br>the compiler simply cannot decide which type the lists you want to compare are<br>(their constituent elements  must be instances of class Eq, but more is not known).<br>
Adding type signatures will help the compiler (it should say so as well, check the<br>error messages):<br><br>testNull = ([]::[Int]) == ([]::[Int])<br><br>although I don&#39;t know why you would want to do such a thing (sorry I did not follow the<br>
whole thread).<br><br>Cheers<br>Christian<br><br><br><div class="gmail_quote">2010/10/2  <span dir="ltr">&lt;<a href="mailto:beginners-request@haskell.org">beginners-request@haskell.org</a>&gt;</span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Send Beginners mailing list submissions to<br>
        <a href="mailto:beginners@haskell.org">beginners@haskell.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
        <a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
or, via email, send a message with subject or body &#39;help&#39; to<br>
        <a href="mailto:beginners-request@haskell.org">beginners-request@haskell.org</a><br>
<br>
You can reach the person managing the list at<br>
        <a href="mailto:beginners-owner@haskell.org">beginners-owner@haskell.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than &quot;Re: Contents of Beginners digest...&quot;<br>
<br>
<br>
Today&#39;s Topics:<br>
<br>
   1. Re:  fromIntegral (Russ Abbott)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Fri, 1 Oct 2010 22:52:34 -0700<br>
From: Russ Abbott &lt;<a href="mailto:russ.abbott@gmail.com">russ.abbott@gmail.com</a>&gt;<br>
Subject: Re: [Haskell-beginners] fromIntegral<br>
To: Daniel Fischer &lt;<a href="mailto:daniel.is.fischer@web.de">daniel.is.fischer@web.de</a>&gt;<br>
Cc: <a href="mailto:beginners@haskell.org">beginners@haskell.org</a><br>
Message-ID:<br>
        &lt;AANLkTikKF9g3MnGew5YkAK=<a href="mailto:xxszdiLHCd8a81Skqd6Kf@mail.gmail.com">xxszdiLHCd8a81Skqd6Kf@mail.gmail.com</a>&gt;<br>
Content-Type: text/plain; charset=&quot;iso-8859-1&quot;<br>
<br>
It turns out that<br>
<br>
   test1 = 1 == 1<br>
<br>
will load (and return True), but<br>
<br>
  testNull = [ ] == [ ]<br>
<br>
won&#39;t load. Both 1 and [ ] seem to have similar sorts of type parameters in<br>
their types. Why are they treated differently?<br>
<br>
<br>
-- Russ<br>
<br>
<br>
<br>
On Fri, Oct 1, 2010 at 10:40 PM, Russ Abbott &lt;<a href="mailto:russ.abbott@gmail.com">russ.abbott@gmail.com</a>&gt; wrote:<br>
<br>
&gt; I can even write<br>
&gt;<br>
&gt; test =<br>
&gt;    let x = []<br>
&gt;        y = 1 : x<br>
&gt;        z = &#39;a&#39; : x<br>
&gt;    in ...<br>
&gt;<br>
&gt; But clearly I can&#39;t write tail y == tail z.  Does that imply that type<br>
&gt; inferencing prevents one from writing a True expression?<br>
&gt;<br>
&gt;<br>
&gt; -- Russ<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; On Fri, Oct 1, 2010 at 10:24 PM, Russ Abbott &lt;<a href="mailto:russ.abbott@gmail.com">russ.abbott@gmail.com</a>&gt;wrote:<br>
&gt;<br>
&gt;&gt; Thanks. I&#39;m still wondering what [ ] refers to. I can load the following<br>
&gt;&gt; file without error.<br>
&gt;&gt;<br>
&gt;&gt; null&#39; xs = xs == [ ]<br>
&gt;&gt;<br>
&gt;&gt; test =<br>
&gt;&gt;    let x = [ ]<br>
&gt;&gt;    in tail [1]  == x &amp;&amp; tail [&#39;a&#39;]  == x<br>
&gt;&gt;<br>
&gt;&gt; (I know I can define null&#39; differently. I&#39;m defining it this way so that I<br>
&gt;&gt; can ask this question.)<br>
&gt;&gt;<br>
&gt;&gt; When I execute test I get True.<br>
&gt;&gt;  &gt; test<br>
&gt;&gt;  True<br>
&gt;&gt;<br>
&gt;&gt; So my question is: what is x after compilation? Is it really a thing of<br>
&gt;&gt; type<br>
&gt;&gt;      (Eq a) =&gt; [a] ?<br>
&gt;&gt; If so, how should I think of such a thing being stored so that it can be<br>
&gt;&gt; found equal to both tail [1] and tail [&#39;a&#39;]?  Furthermore, this seems to<br>
&gt;&gt; show that (==) is not transitive since one can&#39;t even compile<br>
&gt;&gt;   tail [1] == tail [&#39;a&#39;]<br>
&gt;&gt; much less find them to be equal. Yet they are each == to x.<br>
&gt;&gt;<br>
&gt;&gt; -- Russ<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; On Fri, Oct 1, 2010 at 9:08 AM, Daniel Fischer &lt;<a href="mailto:daniel.is.fischer@web.de">daniel.is.fischer@web.de</a>&gt;wrote:<br>
&gt;&gt;<br>
&gt;&gt;&gt; On Friday 01 October 2010 17:08:08, Russ Abbott wrote:<br>
&gt;&gt;&gt; &gt; Thanks, Filipe<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; I clearly over-stated my case.  I&#39;d like to break it into a number of<br>
&gt;&gt;&gt; &gt; different question.  Please see below.<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; On Thu, Sep 30, 2010 at 10:25 PM, Felipe Lessa<br>
&gt;&gt;&gt; &lt;<a href="mailto:felipe.lessa@gmail.com">felipe.lessa@gmail.com</a>&gt;wrote:<br>
&gt;&gt;&gt; &gt; &gt; I&#39;ll try to clarify some concepts.  Please correct me if I am<br>
&gt;&gt;&gt; &gt; &gt; wrong, and please forgive me if I misunderstood you.<br>
&gt;&gt;&gt; &gt; &gt;<br>
&gt;&gt;&gt; &gt; &gt; On Fri, Oct 1, 2010 at 12:54 AM, Russ Abbott &lt;<a href="mailto:russ.abbott@gmail.com">russ.abbott@gmail.com</a>&gt;<br>
&gt;&gt;&gt; &gt; &gt;<br>
&gt;&gt;&gt; &gt; &gt; wrote:<br>
&gt;&gt;&gt; &gt; &gt; &gt; In explaining fromIntegral, I want to say that it is really a<br>
&gt;&gt;&gt; &gt; &gt; &gt; collection<br>
&gt;&gt;&gt; &gt; &gt;<br>
&gt;&gt;&gt; &gt; &gt; of<br>
&gt;&gt;&gt; &gt; &gt;<br>
&gt;&gt;&gt; &gt; &gt; &gt; overloaded functions:<br>
&gt;&gt;&gt; &gt; &gt; &gt;<br>
&gt;&gt;&gt; &gt; &gt; &gt; Integer -&gt; Double<br>
&gt;&gt;&gt; &gt; &gt; &gt; Int -&gt; Float<br>
&gt;&gt;&gt; &gt; &gt; &gt; ...<br>
&gt;&gt;&gt; &gt; &gt; &gt;<br>
&gt;&gt;&gt; &gt; &gt; &gt; When GHC compiles a line of code with fromIntegral it in, it must<br>
&gt;&gt;&gt; &gt; &gt; &gt; decide<br>
&gt;&gt;&gt; &gt; &gt;<br>
&gt;&gt;&gt; &gt; &gt; at<br>
&gt;&gt;&gt; &gt; &gt;<br>
&gt;&gt;&gt; &gt; &gt; &gt; compile time which of these overloaded functions to compile to.<br>
&gt;&gt;&gt; &gt; &gt; &gt; This is<br>
&gt;&gt;&gt; &gt; &gt;<br>
&gt;&gt;&gt; &gt; &gt; in<br>
&gt;&gt;&gt; &gt; &gt;<br>
&gt;&gt;&gt; &gt; &gt; &gt; contrast to saying that fromIngetral is a function of the type<br>
&gt;&gt;&gt; &gt; &gt; &gt; (Integral<br>
&gt;&gt;&gt; &gt; &gt;<br>
&gt;&gt;&gt; &gt; &gt; a,<br>
&gt;&gt;&gt; &gt; &gt;<br>
&gt;&gt;&gt; &gt; &gt; &gt; Num b) =&gt; a -&gt; b.  In reality there is no (single) function of the<br>
&gt;&gt;&gt; &gt; &gt; &gt; type (Integral a, Num b) =&gt; a -&gt; b because (among other things)<br>
&gt;&gt;&gt; &gt; &gt; &gt; every function must map between actual types, but (Integral a, Num<br>
&gt;&gt;&gt; &gt; &gt; &gt; b) =&gt; a -&gt; b does not say which actual types are mapped between.<br>
&gt;&gt;&gt; &gt; &gt; &gt;<br>
&gt;&gt;&gt; &gt; &gt; &gt; Is the preceding a reasonable thing to say?<br>
&gt;&gt;&gt; &gt; &gt;<br>
&gt;&gt;&gt; &gt; &gt; First of all, I do think that polymorphic functions are plain ol&#39;<br>
&gt;&gt;&gt; &gt; &gt; functions.  For example<br>
&gt;&gt;&gt; &gt; &gt;<br>
&gt;&gt;&gt; &gt; &gt;  id :: a -&gt; a<br>
&gt;&gt;&gt; &gt; &gt;  id x = x<br>
&gt;&gt;&gt; &gt; &gt;<br>
&gt;&gt;&gt; &gt; &gt; is a function.  Moreover, in GHC &#39;id&#39; has only one<br>
&gt;&gt;&gt; &gt; &gt; representation, taking a thunk and returning a thunk, so even at<br>
&gt;&gt;&gt; &gt; &gt; the machine code level this is only one function.<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; Agree.  I over stated my case.  The same can be said for<br>
&gt;&gt;&gt; &gt;   length  :: [a] -&gt; Int<br>
&gt;&gt;&gt; &gt; It doesn&#39;t matter what the type of element in the list is. length runs<br>
&gt;&gt;&gt; &gt; the same way no matter what. So this is pure polymorphism.<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; &gt; Now, maybe &#39;fromIntegral&#39; has something more than polymorphism?<br>
&gt;&gt;&gt; &gt; &gt; Well, it has typeclasses.  But we can represent those as<br>
&gt;&gt;&gt; &gt; &gt; data types, so we could write<br>
&gt;&gt;&gt; &gt; &gt;<br>
&gt;&gt;&gt; &gt; &gt;  fromIntegralD :: Integral a -&gt; Num b -&gt; a -&gt; b<br>
&gt;&gt;&gt; &gt; &gt;  fromIntegralD intrDictA numDictB =<br>
&gt;&gt;&gt; &gt; &gt;    fromIntegral numDictB . toInteger intrDictA<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; I&#39;m afraid I don&#39;t understand this. Moreover, I couldn&#39;t get the<br>
&gt;&gt;&gt; &gt; preceding to load without error.<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; No wonder, Integral and Num are type classes and not datatypes (unless<br>
&gt;&gt;&gt; you<br>
&gt;&gt;&gt; have defined such datatypes in scope).<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; The point is, you can represent type classes as dictionaries, e.g.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; data Num a = NumDict<br>
&gt;&gt;&gt;    { plus :: a -&gt; a -&gt; a<br>
&gt;&gt;&gt;    , minus :: a -&gt; a -&gt; a<br>
&gt;&gt;&gt;    , ...<br>
&gt;&gt;&gt;    , fromIntegerD :: Integer -&gt; a<br>
&gt;&gt;&gt;    }<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; data Integral a = IntegralDict<br>
&gt;&gt;&gt;    { quotD :: a -&gt; a -&gt; a<br>
&gt;&gt;&gt;    , ...<br>
&gt;&gt;&gt;    , toIntegerD a<br>
&gt;&gt;&gt;    }<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Then a type-class polymorphic function like fromIntegral becomes a<br>
&gt;&gt;&gt; function<br>
&gt;&gt;&gt; with some dictionaries as additional arguments.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; foo :: (Class1 a, Class2 b) =&gt; a -&gt; b<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; becomes<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; fooDict :: Class1Dict a -&gt; Class2Dict b -&gt; a -&gt; b<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; To do that explicitly is of course somewhat cumbersome as one has to<br>
&gt;&gt;&gt; always<br>
&gt;&gt;&gt; carry the dictionaries around and one can have more than one dictionary<br>
&gt;&gt;&gt; per<br>
&gt;&gt;&gt; type (e.g.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; intNum1 :: Num Int<br>
&gt;&gt;&gt; intNum1 = NumDict<br>
&gt;&gt;&gt;    { plus = (+)<br>
&gt;&gt;&gt;    , ...<br>
&gt;&gt;&gt;    , fromIntegerD = fromInteger<br>
&gt;&gt;&gt;    }<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; intNum2 :: Num Int<br>
&gt;&gt;&gt; intNum2 = NumDict<br>
&gt;&gt;&gt;    { plus = quot<br>
&gt;&gt;&gt;    , -- more nonsense<br>
&gt;&gt;&gt;    , fromInteger = const 1<br>
&gt;&gt;&gt;    }<br>
&gt;&gt;&gt; ).<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Internally, GHC implements type classes via dictionaries and passes them<br>
&gt;&gt;&gt; as<br>
&gt;&gt;&gt; extra arguments to overloaded functions, as you can see by inspecting the<br>
&gt;&gt;&gt; Core output (-ddump-simpl).<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; &gt; &gt; Better yet, the compiler could write this code for us internally.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; And GHC does.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; &gt; &gt; Now, using thunks we can get a single machine code for<br>
&gt;&gt;&gt; &gt; &gt; &#39;fromIntegralD&#39; as well.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; But that&#39;s not terribly efficient, so with -O, GHC tries to eliminate<br>
&gt;&gt;&gt; dictionaries and use the specialised functions (like<br>
&gt;&gt;&gt; plusInteger :: Integer -&gt; Integer -&gt; Integer).<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; &gt; &gt;<br>
&gt;&gt;&gt; &gt; &gt; In sum, I think all functions are really just that, functions.<br>
&gt;&gt;&gt; &gt; &gt;<br>
&gt;&gt;&gt; &gt; &gt; --<br>
&gt;&gt;&gt; &gt; &gt;<br>
&gt;&gt;&gt; &gt; &gt; You may call functions that have typeclass constraints<br>
&gt;&gt;&gt; &gt; &gt; &quot;overloaded functions&quot;, but they still are functions.<br>
&gt;&gt;&gt; &gt; &gt;<br>
&gt;&gt;&gt; &gt; &gt; Functions that are polymorphic but do not have constraints are<br>
&gt;&gt;&gt; &gt; &gt; not really overloaded because of parametricity, which means that<br>
&gt;&gt;&gt; &gt; &gt; they can&#39;t change the way they work based on the specific choices<br>
&gt;&gt;&gt; &gt; &gt; of types you make.<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; I don&#39;t understand the preceding paragraph. Would you mind elaborating.<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; For a function like<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; length :: [a] -&gt; Int<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; , because it doesn&#39;t know anything about the type a at which it will be<br>
&gt;&gt;&gt; called, it cannot do anything with the contents of the list (well, it<br>
&gt;&gt;&gt; could<br>
&gt;&gt;&gt; call seq on them, but it would do that for every type), it can only<br>
&gt;&gt;&gt; inspect<br>
&gt;&gt;&gt; the spine of the list.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; The code is completely independent of what type of data the pointers to<br>
&gt;&gt;&gt; the<br>
&gt;&gt;&gt; contents point to, so `length [True,False]&#39; and `length [()]&#39; can and do<br>
&gt;&gt;&gt; call the exact same machine code.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; &gt; &gt; &gt; If so, can I say the same sort of thing about constants like 1 and<br>
&gt;&gt;&gt; &gt; &gt; &gt; []? In particular there is no single value []. Instead [] is a<br>
&gt;&gt;&gt; &gt; &gt; &gt; symbol which at compile time must be compiled to the empty list of<br>
&gt;&gt;&gt; &gt; &gt; &gt; some particular type, e.g., [Int].  There is no such Haskell value<br>
&gt;&gt;&gt; &gt; &gt; &gt; as [] :: [a] since [a] (as type) is not an actual type. I want to<br>
&gt;&gt;&gt; &gt; &gt; &gt; say the same thing about 1, i.e., that there is no such Haskell<br>
&gt;&gt;&gt; &gt; &gt; &gt; value as 1 :: (Num t) =&gt; t. When the symbol<br>
&gt;&gt;&gt; &gt; &gt;<br>
&gt;&gt;&gt; &gt; &gt; 1<br>
&gt;&gt;&gt; &gt; &gt;<br>
&gt;&gt;&gt; &gt; &gt; &gt; appears in a program, the compiler must decide during compilation<br>
&gt;&gt;&gt; &gt; &gt; &gt; whether<br>
&gt;&gt;&gt; &gt; &gt;<br>
&gt;&gt;&gt; &gt; &gt; it<br>
&gt;&gt;&gt; &gt; &gt;<br>
&gt;&gt;&gt; &gt; &gt; &gt; is intended to be 1::Int or 1::Integer or 1::Double, etc.<br>
&gt;&gt;&gt; &gt; &gt;<br>
&gt;&gt;&gt; &gt; &gt; Well, [a] *is* an actual type, a polymorphic one.<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; Here is the example that raised that issue for me. Let&#39;s say I define<br>
&gt;&gt;&gt; &gt; null&#39; as follows.<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;    null&#39; xs = xs == [ ]<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; If I don&#39;t include a declaration in the file, Haskell (reasonably)<br>
&gt;&gt;&gt; &gt; concludes the following.<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;   &gt; :t null&#39;<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;   null&#39; :: (Eq a) =&gt; [a] -&gt; Bool<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; If I write the following at the top level,<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; You seem to mean the ghci prompt here, not the top level of a module.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; &gt; everything is fine.<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;   &gt; null&#39; [ ]<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;   True<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; But if I include the following in the file that defines null&#39;, I get an<br>
&gt;&gt;&gt; &gt; error message.<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;   test = null&#39; [ ]<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;       Ambiguous type variable `a&#39; in the constraint:<br>
&gt;&gt;&gt; &gt;            `Eq a&#39; arising from a use of `null&#39;&#39; at null.hs:6:17-24<br>
&gt;&gt;&gt; &gt;          Probable fix: add a type signature that fixes these type<br>
&gt;&gt;&gt; &gt; variable(s)<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; Why is that?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; null&#39; has an Eq constraint, so to evaluate test, an Eq dictionary is<br>
&gt;&gt;&gt; needed, but there&#39;s no way to determine which one should be used.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; At a lower level, the type of null&#39; is<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; null&#39; :: EqDict a -&gt; [a] -&gt; Bool<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; The (hidden) first argument is missing and GHC doesn&#39;t know which one to<br>
&gt;&gt;&gt; pass.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; At the ghci-prompt, ghci&#39;s extended default rules let it selet the Eq<br>
&gt;&gt;&gt; dictionary of () and all&#39;s fine.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; In a source file, GHC restricts itself to the default rules specified in<br>
&gt;&gt;&gt; the language report, which state that for defaulting to take place, at<br>
&gt;&gt;&gt; least one of the constraints must be a numeric class. There&#39;s none here,<br>
&gt;&gt;&gt; so<br>
&gt;&gt;&gt; no defaulting and the type variable of the constraint remains ambiguous.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; &gt; And how can it be fixed?  I know I can fix it as follows.<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;   test = null&#39; ([ ] :: [Integer])<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;   &gt; :reload<br>
&gt;&gt;&gt; &gt;   &gt;<br>
&gt;&gt;&gt; &gt;   &gt; test<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;   True<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; In that situation, I think giving a type signature is the only way¹.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; test = null&#39; ([] :: Num a =&gt; [a])<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; also works.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; ¹ -XExtendedDefaultRules might work too.<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; That&#39;s what suggested to me that [ ] had to be compiled into a concrete<br>
&gt;&gt;&gt; &gt; value.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Try<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; null&#39;&#39; [] = True<br>
&gt;&gt;&gt; null&#39;&#39; _ = False<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; test&#39;&#39; = null&#39;&#39; []<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; No type class constraints, no problems.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; It seemed to me that similar reasoning applied to things like 1.  How<br>
&gt;&gt;&gt; is<br>
&gt;&gt;&gt; &gt; the following explained?<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;    Prelude&gt; 111111111111111111111111111111111111111111<br>
&gt;&gt;&gt; &gt;    111111111111111111111111111111111111111111<br>
&gt;&gt;&gt; &gt;    it :: (Num t) =&gt; t<br>
&gt;&gt;&gt; &gt;    Prelude&gt; maxBound :: Int<br>
&gt;&gt;&gt; &gt;    2147483647<br>
&gt;&gt;&gt; &gt;    it :: Int<br>
&gt;&gt;&gt; &gt;    Prelude&gt; 111111111111111111111111111111111111111111 - (1::Int)<br>
&gt;&gt;&gt; &gt;    -954437178<br>
&gt;&gt;&gt; &gt;    it :: Int<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; Does it make sense to say that the long string of 1&#39;s is really of type<br>
&gt;&gt;&gt; &gt; (Num t) =&gt; t?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Integer literals stand for (fromInteger Integer-value-of-literal), so the<br>
&gt;&gt;&gt; literal itself can have any type belonging to Num. If you force it to<br>
&gt;&gt;&gt; have<br>
&gt;&gt;&gt; a particular type, the corresponding fromInteger function is determined<br>
&gt;&gt;&gt; and<br>
&gt;&gt;&gt; can be applied if the value is needed.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; If so, what does the compiler think it&#39;s doing when it processes(?) it<br>
&gt;&gt;&gt; &gt; as an Int so that it can subtract 1 :: Int from it?  It didn&#39;t treat it<br>
&gt;&gt;&gt; &gt; as maxBound :: Int.  And yet it didn&#39;t generate an error message.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; For efficiency, fromInteger wraps, for a b-bit Integral type, the result<br>
&gt;&gt;&gt; of<br>
&gt;&gt;&gt; fromInteger n is n `mod` 2^b.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; Thanks<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; -- Russ<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;<br>
&gt;<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <a href="http://www.haskell.org/pipermail/beginners/attachments/20101002/23bab169/attachment.html" target="_blank">http://www.haskell.org/pipermail/beginners/attachments/20101002/23bab169/attachment.html</a><br>
<br>
------------------------------<br>
<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org">Beginners@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/beginners" target="_blank">http://www.haskell.org/mailman/listinfo/beginners</a><br>
<br>
<br>
End of Beginners Digest, Vol 28, Issue 5<br>
****************************************<br>
</blockquote></div><br>