Hi,<div><br></div><div>you can always check the types using GHCi prompt:</div><div><br></div><div><div>*Prelude&gt; :i (,)</div><div>data (,) a b = (,) a b <span class="Apple-tab-span" style="white-space:pre">        </span>-- Defined in GHC.Tuple</div>
<div>instance (Bounded a, Bounded b) =&gt; Bounded (a, b)</div><div>  -- Defined in GHC.Enum</div><div>instance (Eq a, Eq b) =&gt; Eq (a, b) -- Defined in Data.Tuple</div><div>instance Functor ((,) a) -- Defined in Control.Monad.Instances</div>
<div>instance (Ord a, Ord b) =&gt; Ord (a, b) -- Defined in Data.Tuple</div><div>instance (Read a, Read b) =&gt; Read (a, b) -- Defined in GHC.Read</div><div>instance (Show a, Show b) =&gt; Show (a, b) -- Defined in GHC.Show</div>
<div><br></div><div>that&#39;s for a tuple. You can see that tuple has an instance for the Ord class.</div><div><br></div><div>*Prelude&gt; :i ()</div><div>data () = () <span class="Apple-tab-span" style="white-space:pre">        </span>-- Defined in GHC.Unit</div>
<div>instance Bounded () -- Defined in GHC.Enum</div><div>instance Enum () -- Defined in GHC.Enum</div><div>instance Eq () -- Defined in Data.Tuple</div><div>instance Ord () -- Defined in Data.Tuple</div><div>instance Read () -- Defined in GHC.Read</div>
<div>instance Show () -- Defined in GHC.Show</div><div><br></div><div>and that&#39;s for a unit type.</div><br><div class="gmail_quote">On 3 March 2011 08:09, Karthick Gururaj <span dir="ltr">&lt;<a href="mailto:karthick.gururaj@gmail.com">karthick.gururaj@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hello,<br>
<br>
I&#39;m learning Haskell from the extremely well written (and well<br>
illustrated as well!) tutorial - <a href="http://learnyouahaskell.com/chapters" target="_blank">http://learnyouahaskell.com/chapters</a>.<br>
I have couple of questions from my readings so far.<br>
<br>
In &quot;typeclasses - 101&quot;<br>
(<a href="http://learnyouahaskell.com/types-and-typeclasses#typeclasses-101" target="_blank">http://learnyouahaskell.com/types-and-typeclasses#typeclasses-101</a>),<br>
there is a paragraph that reads:<br>
Enum members are sequentially ordered types - they can be enumerated.<br>
The main advantage of the Enum typeclass is that we can use its types<br>
in list ranges. They also have defined successors and predecesors,<br>
which you can get with the succ and pred functions. Types in this<br>
class: (), Bool, Char, Ordering, Int, Integer, Float and Double.<br>
<br>
What is the &quot;()&quot; type? Does it refer to a tuple? How can tuple be<br>
ordered, let alone be enum&#39;d? I tried:<br>
Prelude&gt; take 10 [(1,1) ..]<br>
&lt;interactive&gt;:1:8:<br>
    No instance for (Enum (t, t1))<br>
      arising from the arithmetic sequence `(1, 1) .. &#39;<br>
                   at &lt;interactive&gt;:1:8-17<br>
    Possible fix: add an instance declaration for (Enum (t, t1))<br>
    In the second argument of `take&#39;, namely `[(1, 1) .. ]&#39;<br>
    In the expression: take 10 [(1, 1) .. ]<br>
    In the definition of `it&#39;: it = take 10 [(1, 1) .. ]<br>
<br>
This is expected and is logical.<br>
<br>
But, surprise:<br>
Prelude&gt; (1,1) &gt; (1,2)<br>
False<br>
Prelude&gt; (2,2) &gt; (1,1)<br>
True<br>
Prelude&gt; (1,2) &gt; (2,1)<br>
False<br>
Prelude&gt; (1,2) &lt; (2,1)<br>
True<br>
<br>
So tuples are in &quot;Ord&quot; type class atleast. What is the ordering logic?<br>
<br>
Another question, on the curried functions - specifically for infix<br>
functions. Suppose I need a function that takes an argument and adds<br>
five to it. I can do:<br>
Prelude&gt; let addFive = (+) 5<br>
Prelude&gt; addFive 4<br>
9<br>
<br>
The paragraph: &quot;Infix functions can also be partially applied by using<br>
sections. To section an infix function, simply surround it with<br>
parentheses and only supply a parameter on one side. That creates a<br>
function that takes one parameter and then applies it to the side<br>
that&#39;s missing an operand&quot;: describes a different syntax. I tried that<br>
as well:<br>
<br>
Prelude&gt; let addFive&#39; = (+5)<br>
Prelude&gt; addFive&#39; 3<br>
8<br>
<br>
Ok. Works. But on a non-commutative operation like division, we get:<br>
Prelude&gt; let x = (/) 20.0<br>
Prelude&gt; x 10<br>
2.0<br>
Prelude&gt; let y = (/20.0)<br>
Prelude&gt; y 10<br>
0.5<br>
<br>
So a curried infix operator fixes the first argument and a &quot;sectioned<br>
infix&quot; operator fixes the second argument?<br>
<br>
Regards,<br>
Karthick<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>Regards, Paul Sujkov<br>
</div>