Send Beginners mailing list submissions to
        beginners@haskell.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        beginners-requ...@haskell.org

You can reach the person managing the list at
        beginners-ow...@haskell.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  '/' instead use  'DIV'. why? (amin...@gmail.com)
   2.  Why the compiler does not commit to a type       class?
      (Alexander Chen)
   3. Re:  Why the compiler does not commit to a type   class?
      (Jason Chau)


----------------------------------------------------------------------

Message: 1
Date: Fri, 17 Apr 2020 15:42:46 -0400
From: amin...@gmail.com
To: Alexander Chen <alexan...@chenjia.nl>, The Haskell-Beginners
        Mailing List - Discussion of primarily beginner-level topics related
        to Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] '/' instead use  'DIV'. why?
Message-ID: <8a974ead-b22e-44e3-9974-ff16b19f7...@gmail.com>
Content-Type: text/plain; charset="utf-8"

It might help to imagine if you flip your arguments:

length [23, 34, 45] / 6 :: Int

How do you represent 3/6 as an Int?

> El 17 abr 2020, a las 03:19, Alexander Chen <alexan...@chenjia.nl> escribió:
> 
> Hi, 
> 
> 
> Prelude> :t (/)
> (/) :: Fractional a => a -> a -> a
> 
> Prelude> :t div
> div :: Integral a => a -> a -> a
> 
> 
> Prelude> 6 / length [23,34,45]
> error 
> 
> Prelude> 6 / 3
> 2.0
> 
> Could somebody explain to me why this is?
> 
> thanks,
> 
> Alexander Chen
> 
> 
> 
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20200417/d0c6cc1f/attachment-0001.html>

------------------------------

Message: 2
Date: Fri, 17 Apr 2020 21:56:16 +0200 (CEST)
From: Alexander Chen <alexan...@chenjia.nl>
To: beginners@haskell.org
Subject: [Haskell-beginners] Why the compiler does not commit to a
        type    class?
Message-ID: <1426914449.1477761.1587153376...@ichabod.co-bxl>
Content-Type: text/plain; charset="utf-8"

hi,

Prelude> u = undefined
Prelude> k :: (Ord a, Num b) => a -> b -> a; k = u

Prelude> :t k 1 2 
k 1 2 :: (Ord a, Num a) => a

Prelude> :t k (1 :: Integer) 2
k (1 :: Integer) 2 :: Integer

In the first version the compiler is not really pushed so it simply gives back 
the type class constriction it has to adhere to. While in the second it is 
pushed to give an more specific answer and thus the :: Integer.

Question:
Is this train of thought correct? 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20200417/0b0ea624/attachment-0001.html>

------------------------------

Message: 3
Date: Fri, 17 Apr 2020 13:00:28 -0700
From: Jason Chau <jasonsyc...@gmail.com>
To: Alexander Chen <alexan...@chenjia.nl>, The Haskell-Beginners
        Mailing List - Discussion of primarily beginner-level topics related
        to Haskell <beginners@haskell.org>
Subject: Re: [Haskell-beginners] Why the compiler does not commit to a
        type    class?
Message-ID: <bac9641d-4eec-43db-8f22-734283bce...@gmail.com>
Content-Type: text/plain; charset="utf-8"

Yes - if you look at the number types, you will find different number types and 
not integer types are providing support that’s not in Integer, so compiler is 
giving safest assumption.

Sent from my iPhone

> On Apr 17, 2020, at 12:56 PM, Alexander Chen <alexan...@chenjia.nl> wrote:
> 
> 
> hi,
> 
> Prelude> u = undefined
> Prelude> k :: (Ord a, Num b) => a -> b -> a; k = u
> 
> Prelude> :t k 1 2 
> k 1 2 :: (Ord a, Num a) => a
> 
> Prelude> :t k (1 :: Integer) 2
> k (1 :: Integer) 2 :: Integer
> 
> In the first version the compiler is not really pushed so it simply gives 
> back the type class constriction it has to adhere to. While in the second it 
> is pushed to give an more specific answer and thus the :: Integer.
> 
> Question:
> Is this train of thought correct? 
> 
> 
> 
> _______________________________________________
> Beginners mailing list
> Beginners@haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://mail.haskell.org/pipermail/beginners/attachments/20200417/0da90ce0/attachment-0001.html>

------------------------------

Subject: Digest Footer

_______________________________________________
Beginners mailing list
Beginners@haskell.org
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners


------------------------------

End of Beginners Digest, Vol 142, Issue 2
*****************************************

Reply via email to