<div dir="ltr"><div>Now I understand it.</div><div>Thanks a lot!</div><div><br></div><div>Anthony<br></div><div><br><div class="gmail_quote"><div dir="ltr">On Sat, Aug 18, 2018 at 5:34 AM <<a href="mailto:beginners-request@haskell.org">beginners-request@haskell.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Send Beginners mailing list submissions to<br>
<a href="mailto:beginners@haskell.org" target="_blank">beginners@haskell.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
or, via email, send a message with subject or body 'help' to<br>
<a href="mailto:beginners-request@haskell.org" target="_blank">beginners-request@haskell.org</a><br>
<br>
You can reach the person managing the list at<br>
<a href="mailto:beginners-owner@haskell.org" target="_blank">beginners-owner@haskell.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of Beginners digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
1. Re: Beginners Digest, Vol 122, Issue 6 (Anthony Lee)<br>
2. Re: Bound library questions (David McBride)<br>
3. Empty list and null (trent shipley)<br>
4. Re: Empty list and null (Ut Primum)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Fri, 17 Aug 2018 09:21:47 -0400<br>
From: Anthony Lee <<a href="mailto:anthonynlee@gmail.com" target="_blank">anthonynlee@gmail.com</a>><br>
To: <a href="mailto:beginners@haskell.org" target="_blank">beginners@haskell.org</a><br>
Subject: Re: [Haskell-beginners] Beginners Digest, Vol 122, Issue 6<br>
Message-ID:<br>
<CA+pBo5FSLqbgC=<a href="mailto:L9bONcCb0y%2BUPSGq6jpVgq60ouKUNk4xNv3w@mail.gmail.com" target="_blank">L9bONcCb0y+UPSGq6jpVgq60ouKUNk4xNv3w@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
The source code is here: <a href="https://github.com/ekmett/bound/" rel="noreferrer" target="_blank">https://github.com/ekmett/bound/</a><br>
<br>
On Fri, Aug 17, 2018 at 8:41 AM <<a href="mailto:beginners-request@haskell.org" target="_blank">beginners-request@haskell.org</a>> wrote:<br>
<br>
> Send Beginners mailing list submissions to<br>
> <a href="mailto:beginners@haskell.org" target="_blank">beginners@haskell.org</a><br>
><br>
> To subscribe or unsubscribe via the World Wide Web, visit<br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
> or, via email, send a message with subject or body 'help' to<br>
> <a href="mailto:beginners-request@haskell.org" target="_blank">beginners-request@haskell.org</a><br>
><br>
> You can reach the person managing the list at<br>
> <a href="mailto:beginners-owner@haskell.org" target="_blank">beginners-owner@haskell.org</a><br>
><br>
> When replying, please edit your Subject line so it is more specific<br>
> than "Re: Contents of Beginners digest..."<br>
><br>
><br>
> Today's Topics:<br>
><br>
> 1. Bound library questions (Anthony Lee)<br>
><br>
><br>
> ----------------------------------------------------------------------<br>
><br>
> Message: 1<br>
> Date: Fri, 17 Aug 2018 06:46:52 -0400<br>
> From: Anthony Lee <<a href="mailto:anthonynlee@gmail.com" target="_blank">anthonynlee@gmail.com</a>><br>
> To: <a href="mailto:beginners@haskell.org" target="_blank">beginners@haskell.org</a><br>
> Subject: [Haskell-beginners] Bound library questions<br>
> Message-ID:<br>
> <CA+pBo5HVraf_8jbs15bR6QAy1S7=z_u-3KBwT=<br>
> <a href="mailto:c3sqkAgc0m5Q@mail.gmail.com" target="_blank">c3sqkAgc0m5Q@mail.gmail.com</a>><br>
> Content-Type: text/plain; charset="utf-8"<br>
><br>
> In Scope.hs there are some functions I feel difficult to understand,<br>
> Why fmap/foldmap/traverse is applied three times?<br>
><br>
> instance Functor f => Functor (Scope b f) where<br>
> fmap f (Scope a) = Scope (fmap (fmap (fmap f)) a)<br>
> {-# INLINE fmap #-}<br>
><br>
> -- | @'toList'@ is provides a list (with duplicates) of the free variables<br>
> instance Foldable f => Foldable (Scope b f) where<br>
> foldMap f (Scope a) = foldMap (foldMap (foldMap f)) a<br>
> {-# INLINE foldMap #-}<br>
><br>
> instance Traversable f => Traversable (Scope b f) where<br>
> traverse f (Scope a) = Scope <$> traverse (traverse (traverse f)) a<br>
> {-# INLINE traverse #-}<br>
> -------------- next part --------------<br>
> An HTML attachment was scrubbed...<br>
> URL: <<br>
> <a href="http://mail.haskell.org/pipermail/beginners/attachments/20180817/429114c8/attachment-0001.html" rel="noreferrer" target="_blank">http://mail.haskell.org/pipermail/beginners/attachments/20180817/429114c8/attachment-0001.html</a><br>
> ><br>
><br>
> ------------------------------<br>
><br>
> Subject: Digest Footer<br>
><br>
> _______________________________________________<br>
> Beginners mailing list<br>
> <a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
><br>
><br>
> ------------------------------<br>
><br>
> End of Beginners Digest, Vol 122, Issue 6<br>
> *****************************************<br>
><br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://mail.haskell.org/pipermail/beginners/attachments/20180817/2112c0e7/attachment-0001.html" rel="noreferrer" target="_blank">http://mail.haskell.org/pipermail/beginners/attachments/20180817/2112c0e7/attachment-0001.html</a>><br>
<br>
------------------------------<br>
<br>
Message: 2<br>
Date: Fri, 17 Aug 2018 10:23:53 -0400<br>
From: David McBride <<a href="mailto:toad3k@gmail.com" target="_blank">toad3k@gmail.com</a>><br>
To: The Haskell-Beginners Mailing List - Discussion of primarily<br>
beginner-level topics related to Haskell <<a href="mailto:beginners@haskell.org" target="_blank">beginners@haskell.org</a>><br>
Subject: Re: [Haskell-beginners] Bound library questions<br>
Message-ID:<br>
<CAN+Tr40SXsiWUsasn7hQoryCoXD232PSB-P=<a href="mailto:JrmRR5ToPm93jw@mail.gmail.com" target="_blank">JrmRR5ToPm93jw@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
The code as it currently stands only has two nested fmaps / foldMaps /<br>
traverses.<br>
<br>
The reason he can do that is because Scope is defined as an "f (Var b a)".<br>
Since Scope is only a functor if f is also functor, that means you can fmap<br>
over f, regardless of what it is. But in addition to that Var is also a<br>
functor. So you can fmap over f, and then fmap over the Var inside the f,<br>
which ends up being two nested fmaps. That same condition exists for<br>
foldable and traversable.<br>
<br>
On Fri, Aug 17, 2018 at 6:46 AM, Anthony Lee <<a href="mailto:anthonynlee@gmail.com" target="_blank">anthonynlee@gmail.com</a>> wrote:<br>
<br>
> In Scope.hs there are some functions I feel difficult to understand,<br>
> Why fmap/foldmap/traverse is applied three times?<br>
><br>
> instance Functor f => Functor (Scope b f) where<br>
> fmap f (Scope a) = Scope (fmap (fmap (fmap f)) a)<br>
> {-# INLINE fmap #-}<br>
><br>
> -- | @'toList'@ is provides a list (with duplicates) of the free variables<br>
> instance Foldable f => Foldable (Scope b f) where<br>
> foldMap f (Scope a) = foldMap (foldMap (foldMap f)) a<br>
> {-# INLINE foldMap #-}<br>
><br>
> instance Traversable f => Traversable (Scope b f) where<br>
> traverse f (Scope a) = Scope <$> traverse (traverse (traverse f)) a<br>
> {-# INLINE traverse #-}<br>
><br>
> _______________________________________________<br>
> Beginners mailing list<br>
> <a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
><br>
><br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://mail.haskell.org/pipermail/beginners/attachments/20180817/e0fbde97/attachment-0001.html" rel="noreferrer" target="_blank">http://mail.haskell.org/pipermail/beginners/attachments/20180817/e0fbde97/attachment-0001.html</a>><br>
<br>
------------------------------<br>
<br>
Message: 3<br>
Date: Sat, 18 Aug 2018 02:13:25 -0700<br>
From: trent shipley <<a href="mailto:trent.shipley@gmail.com" target="_blank">trent.shipley@gmail.com</a>><br>
To: Haskell Beginners <<a href="mailto:beginners@haskell.org" target="_blank">beginners@haskell.org</a>><br>
Subject: [Haskell-beginners] Empty list and null<br>
Message-ID:<br>
<CAEFLyb+JS2HGitc9HTTe_suhHsesoM5r=JkT+rRmTmQ5xg=<a href="mailto:Q2A@mail.gmail.com" target="_blank">Q2A@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
Why does Haskell so often seem to treat [] as a general null.<br>
<br>
For example I know 0 : 1 : [] gives [0, 1].<br>
<br>
But shouldn't it produce a type fault in a consistent world?<br>
<br>
Int:Int:List isn't properly a list. It mixes types.<br>
<br>
I expect something like:<br>
<br>
Let GSN mean general_scalar_null.<br>
<br>
1 : 2 : GSN -- works<br>
<br>
1 : 2 : [] -- type fault, cannot mix int and empty list in the same list.<br>
<br>
And why does [] == [] : []<br>
instead of [[], []] == [] : []<br>
<br>
What sorts of nullity are there in core Haskell?<br>
<br>
Trent.<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://mail.haskell.org/pipermail/beginners/attachments/20180818/dd3bff19/attachment-0001.html" rel="noreferrer" target="_blank">http://mail.haskell.org/pipermail/beginners/attachments/20180818/dd3bff19/attachment-0001.html</a>><br>
<br>
------------------------------<br>
<br>
Message: 4<br>
Date: Sat, 18 Aug 2018 11:34:23 +0200<br>
From: Ut Primum <<a href="mailto:utprimum@gmail.com" target="_blank">utprimum@gmail.com</a>><br>
To: The Haskell-Beginners Mailing List - Discussion of primarily<br>
beginner-level topics related to Haskell <<a href="mailto:beginners@haskell.org" target="_blank">beginners@haskell.org</a>><br>
Subject: Re: [Haskell-beginners] Empty list and null<br>
Message-ID:<br>
<CANjDmKKcY_CEcOXeeAsT8=<a href="mailto:xW0WLe_MF5MJ7sn_%2B-yF6WBCGVmQ@mail.gmail.com" target="_blank">xW0WLe_MF5MJ7sn_+-yF6WBCGVmQ@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
If you consider the type of the operator *(:)* you have:<br>
<br>
Prelude> :t (:)<br>
(:) :: a -> [a] -> [a]<br>
<br>
So it takes an element of type a and a list. So if you write 1:[2,3,4] the<br>
type is correct, because you give an integer 1 and a list of integers<br>
[2,3,4]. You will obtain the list of integers [1,2,3,4]. Similarly, writing<br>
1:[] is correct and gives you [1] as result.<br>
<br>
Then, if you write<br>
0 : 1 : []<br>
(as in your example), is the same as<br>
0 : (1 : [])<br>
so it means 0 : [1], which is [0,1]. So, the operator (:) is right<br>
associative.<br>
<br>
If it was left associative, your example would give an error. Indeed<br>
(0 : 1) : []<br>
is not correct in Haskell.<br>
<br>
Furthermore, your final examples are both false:<br>
<br>
Prelude> [] == [] : []<br>
False<br>
<br>
[[], []] == [] : []<br>
False<br>
<br>
The following is True:<br>
Prelude> [[]] == [] : []<br>
True<br>
<br>
Indeed if you write [] : [] youy mean you want to build a list whose first<br>
element (head) is [] and whose "tail" (i.e. the rest of the list) is the<br>
empty list.<br>
So, if 1:[] is [1], then []:[] is [[]].<br>
<br>
Ut<br>
<br>
2018-08-18 11:13 GMT+02:00 trent shipley <<a href="mailto:trent.shipley@gmail.com" target="_blank">trent.shipley@gmail.com</a>>:<br>
<br>
> Why does Haskell so often seem to treat [] as a general null.<br>
><br>
> For example I know 0 : 1 : [] gives [0, 1].<br>
><br>
> But shouldn't it produce a type fault in a consistent world?<br>
><br>
> Int:Int:List isn't properly a list. It mixes types.<br>
><br>
> I expect something like:<br>
><br>
> Let GSN mean general_scalar_null.<br>
><br>
> 1 : 2 : GSN -- works<br>
><br>
> 1 : 2 : [] -- type fault, cannot mix int and empty list in the same list.<br>
><br>
> And why does [] == [] : []<br>
> instead of [[], []] == [] : []<br>
><br>
> What sorts of nullity are there in core Haskell?<br>
><br>
> Trent.<br>
><br>
><br>
> _______________________________________________<br>
> Beginners mailing list<br>
> <a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
><br>
><br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <<a href="http://mail.haskell.org/pipermail/beginners/attachments/20180818/0eebd5a6/attachment.html" rel="noreferrer" target="_blank">http://mail.haskell.org/pipermail/beginners/attachments/20180818/0eebd5a6/attachment.html</a>><br>
<br>
------------------------------<br>
<br>
Subject: Digest Footer<br>
<br>
_______________________________________________<br>
Beginners mailing list<br>
<a href="mailto:Beginners@haskell.org" target="_blank">Beginners@haskell.org</a><br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners</a><br>
<br>
<br>
------------------------------<br>
<br>
End of Beginners Digest, Vol 122, Issue 7<br>
*****************************************<br>
</blockquote></div></div></div>