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: Network PortNumber deprecation warning (Theodore Lief Gannon) 2. Re: Network PortNumber deprecation warning (Jeff C. Britton) ---------------------------------------------------------------------- Message: 1 Date: Fri, 16 Aug 2019 10:22:57 -0700 From: Theodore Lief Gannon <tan...@gmail.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Network PortNumber deprecation warning Message-ID: <cajopsudeb5sojwqk1bs81c+gm3v0isycmfbdvzx_u-5mkmf...@mail.gmail.com> Content-Type: text/plain; charset="utf-8" You may have figured this out by now, but according to the docs, the error is correct: PortNumber exposes no constructor at all. Instead, it has a Num instance; you should be able to just use the literal 7200 there. This strikes me as a highly questionable decision on the part of the module authors, but it is at least convenient. On Wed, Aug 14, 2019, 10:59 AM Jeff C. Britton <j...@iteris.com> wrote: > I have just installed Haskell using Stack on Windows. > > I wanted to try and write some code to do network programming with TCP/IP. > > I found a simple example on Stack Overflow to start me off. > > I’m having some problems with PortNumber and deprecated warnings. > > I don't know how to modify the code to be deprecation free. > > > > stack install network – installed version 2.8.0.1 > > > > ------------------------- > > package.yaml > > network >= 2.8.0.1 > > --------------------------- > > > > The following code gives a deprecation warning, but ultimately my sample > compiles and runs. > > > > import qualified Network > > import qualified Network.Socket > > > > main = Network.withSocketsDo $ do > > handle <- Network.connectTo "192.168.1.2" (Network.PortNumber 7200) > > talk handle `finally` hClose handle > > > > D:\work\hsSocket\app\Main.hs:14:46: warning: [-Wdeprecations] > > In the use of data constructor `PortNumber' > > (imported from Network): > > Deprecated: "The high level Network interface is no longer supported. > Please use Network.Socket." > > > > > > ----------------------------------------- > > So, now I try and use Network.Socket as the warning indicates. > > > > main = Network.withSocketsDo $ do > > handle <- Network.connectTo "192.168.1.2" (Network.Socket.PortNumber > 7200) > > talk handle `finally` hClose handle > > > > D:\work\hsSocket\app\Main.hs:15:46: error: > > Not in scope: data constructor `Network.Socket.PortNumber' > > Module `Network.Socket' does not export `PortNumber'. > > | > > 15 | handle <- Network.connectTo "192.168.1.2" > (Network.Socket.PortNumber 7200) > > > _______________________________________________ > 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/20190816/537f4d2b/attachment-0001.html> ------------------------------ Message: 2 Date: Fri, 16 Aug 2019 22:13:38 +0000 From: "Jeff C. Britton" <j...@iteris.com> To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Network PortNumber deprecation warning Message-ID: <mwhpr17mb103925a2a81c88ad2aaf370fce...@mwhpr17mb1039.namprd17.prod.outlook.com> Content-Type: text/plain; charset="utf-8" The Network module is deprecated. I didn’t really get that from the warning, I thought it was just about PortNumber. From Hackage: “”” Milestones 2.7 See https://github.com/haskell/network/issues/296 • [x] Making Network deprecated • [x] Making Network.BSD deprecated • [x] Making MkSocket deprecated “”” ---- From: Beginners [mailto:beginners-boun...@haskell.org] On Behalf Of Theodore Lief Gannon Sent: Friday, August 16, 2019 10:23 AM To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell <beginners@haskell.org> Subject: Re: [Haskell-beginners] Network PortNumber deprecation warning You may have figured this out by now, but according to the docs, the error is correct: PortNumber exposes no constructor at all. Instead, it has a Num instance; you should be able to just use the literal 7200 there. This strikes me as a highly questionable decision on the part of the module authors, but it is at least convenient. On Wed, Aug 14, 2019, 10:59 AM Jeff C. Britton <mailto:j...@iteris.com> wrote: I have just installed Haskell using Stack on Windows. I wanted to try and write some code to do network programming with TCP/IP. I found a simple example on Stack Overflow to start me off. I’m having some problems with PortNumber and deprecated warnings. I don't know how to modify the code to be deprecation free. stack install network – installed version 2.8.0.1 ------------------------- package.yaml network >= 2.8.0.1 --------------------------- The following code gives a deprecation warning, but ultimately my sample compiles and runs. import qualified Network import qualified Network.Socket main = Network.withSocketsDo $ do handle <- Network.connectTo "192.168.1.2" (Network.PortNumber 7200) talk handle `finally` hClose handle D:\work\hsSocket\app\Main.hs:14:46: warning: [-Wdeprecations] In the use of data constructor `PortNumber' (imported from Network): Deprecated: "The high level Network interface is no longer supported. Please use Network.Socket." ----------------------------------------- So, now I try and use Network.Socket as the warning indicates. main = Network.withSocketsDo $ do handle <- Network.connectTo "192.168.1.2" (Network.Socket.PortNumber 7200) talk handle `finally` hClose handle D:\work\hsSocket\app\Main.hs:15:46: error: Not in scope: data constructor `Network.Socket.PortNumber' Module `Network.Socket' does not export `PortNumber'. | 15 | handle <- Network.connectTo "192.168.1.2" (Network.Socket.PortNumber 7200) _______________________________________________ Beginners mailing list mailto:Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners ATTENTION: This email is from an external source. Always use caution when opening attachments or clicking links from unknown senders or when receiving unexpected emails. ------------------------------ Subject: Digest Footer _______________________________________________ Beginners mailing list Beginners@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners ------------------------------ End of Beginners Digest, Vol 134, Issue 3 *****************************************