Send Beginners mailing list submissions to
[email protected]
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
[email protected]
You can reach the person managing the list at
[email protected]
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? ([email protected])
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: [email protected]
To: Alexander Chen <[email protected]>, The Haskell-Beginners
Mailing List - Discussion of primarily beginner-level topics related
to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] '/' instead use 'DIV'. why?
Message-ID: <[email protected]>
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 <[email protected]> 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
> [email protected]
> 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 <[email protected]>
To: [email protected]
Subject: [Haskell-beginners] Why the compiler does not commit to a
type class?
Message-ID: <[email protected]>
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 <[email protected]>
To: Alexander Chen <[email protected]>, The Haskell-Beginners
Mailing List - Discussion of primarily beginner-level topics related
to Haskell <[email protected]>
Subject: Re: [Haskell-beginners] Why the compiler does not commit to a
type class?
Message-ID: <[email protected]>
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 <[email protected]> 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
> [email protected]
> 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
[email protected]
http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners
------------------------------
End of Beginners Digest, Vol 142, Issue 2
*****************************************