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. Network PortNumber deprecation warning (Jeff C. Britton)
----------------------------------------------------------------------
Message: 1
Date: Wed, 14 Aug 2019 17:59:14 +0000
From: "Jeff C. Britton" <[email protected]>
To: "[email protected]" <[email protected]>
Subject: [Haskell-beginners] Network PortNumber deprecation warning
Message-ID:
<mwhpr17mb10399289a9453f33119e565ece...@mwhpr17mb1039.namprd17.prod.outlook.com>
Content-Type: text/plain; charset="utf-8"
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)
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://mail.haskell.org/pipermail/beginners/attachments/20190814/dccc0b89/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 134, Issue 2
*****************************************