aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/lux/world/net
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--stdlib/source/lux/world/net.lux2
-rw-r--r--stdlib/source/lux/world/net/tcp.jvm.lux76
-rw-r--r--stdlib/source/lux/world/net/udp.jvm.lux54
3 files changed, 66 insertions, 66 deletions
diff --git a/stdlib/source/lux/world/net.lux b/stdlib/source/lux/world/net.lux
index c9e2829e5..c7e597a66 100644
--- a/stdlib/source/lux/world/net.lux
+++ b/stdlib/source/lux/world/net.lux
@@ -1,4 +1,4 @@
-(;module:
+(.module:
lux)
(type: #export Address Text)
diff --git a/stdlib/source/lux/world/net/tcp.jvm.lux b/stdlib/source/lux/world/net/tcp.jvm.lux
index f279a0873..3d71e85f8 100644
--- a/stdlib/source/lux/world/net/tcp.jvm.lux
+++ b/stdlib/source/lux/world/net/tcp.jvm.lux
@@ -1,4 +1,4 @@
-(;module:
+(.module:
lux
(lux (control monad)
(concurrency ["P" promise]
@@ -11,24 +11,24 @@
[host])
[//])
-(host;import java/lang/AutoCloseable
+(host.import java/lang/AutoCloseable
(close [] #io #try void))
-(host;import java/io/Flushable
+(host.import java/io/Flushable
(flush [] #io #try void))
-(host;import java/io/InputStream
+(host.import java/io/InputStream
(read [(Array byte) int int] #io #try int))
-(host;import java/io/OutputStream
+(host.import java/io/OutputStream
(write [(Array byte) int int] #io #try void))
-(host;import java/net/Socket
+(host.import java/net/Socket
(new [String int] #io #try)
(getInputStream [] #io #try InputStream)
(getOutputStream [] #io #try OutputStream))
-(host;import java/net/ServerSocket
+(host.import java/net/ServerSocket
(new [int] #io #try)
(accept [] #io #try Socket))
@@ -43,31 +43,31 @@
(def: #export (read data offset length self)
(let [in (get@ #in (@repr self))]
- (P;future
- (do (e;ErrorT io;Monad<IO>)
+ (P.future
+ (do (e.ErrorT io.Monad<IO>)
[bytes-read (InputStream::read [data (nat-to-int offset) (nat-to-int length)]
in)]
(wrap (int-to-nat bytes-read))))))
(def: #export (write data offset length self)
(let [out (get@ #out (@repr self))]
- (P;future
- (do (e;ErrorT io;Monad<IO>)
+ (P.future
+ (do (e.ErrorT io.Monad<IO>)
[_ (OutputStream::write [data (nat-to-int offset) (nat-to-int length)]
out)]
(Flushable::flush [] out)))))
(def: #export (close self)
(let [(^open) (@repr self)]
- (P;future
- (do (e;ErrorT io;Monad<IO>)
+ (P.future
+ (do (e.ErrorT io.Monad<IO>)
[_ (AutoCloseable::close [] in)
_ (AutoCloseable::close [] out)]
(AutoCloseable::close [] socket)))))
(def: (tcp-client socket)
- (-> Socket (io;IO (e;Error TCP)))
- (do (e;ErrorT io;Monad<IO>)
+ (-> Socket (io.IO (e.Error TCP)))
+ (do (e.ErrorT io.Monad<IO>)
[input (Socket::getInputStream [] socket)
output (Socket::getOutputStream [] socket)]
(wrap (@opaque {#socket socket
@@ -75,55 +75,55 @@
#out output}))))
(def: #export (client address port)
- (-> //;Address //;Port (T;Task TCP))
- (P;future
- (do (e;ErrorT io;Monad<IO>)
+ (-> //.Address //.Port (T.Task TCP))
+ (P.future
+ (do (e.ErrorT io.Monad<IO>)
[socket (Socket::new [address (nat-to-int port)])]
(tcp-client socket))))
(def: (await-server-release client-channel server)
- (-> (frp;Channel TCP) ServerSocket (P;Promise Unit))
- (do P;Monad<Promise>
+ (-> (frp.Channel TCP) ServerSocket (P.Promise Unit))
+ (do P.Monad<Promise>
[outcome client-channel]
(case outcome
## Channel has been closed.
## Must close associated server.
- #;None
- (P;future
- (do io;Monad<IO>
+ #.None
+ (P.future
+ (do io.Monad<IO>
[_ (AutoCloseable::close [] server)]
(wrap [])))
## A client was generated.
## Nothing to be done...
- (#;Some _)
+ (#.Some _)
(wrap []))))
(def: #export (server port)
- (-> //;Port (T;Task (frp;Channel TCP)))
- (P;future
- (do (e;ErrorT io;Monad<IO>)
+ (-> //.Port (T.Task (frp.Channel TCP)))
+ (P.future
+ (do (e.ErrorT io.Monad<IO>)
[server (ServerSocket::new [(nat-to-int port)])
- #let [output (frp;channel TCP)
- _ (: (P;Promise Bool)
- (P;future
+ #let [output (frp.channel TCP)
+ _ (: (P.Promise Bool)
+ (P.future
(loop [tail output]
- (do io;Monad<IO>
- [?client (do (e;ErrorT io;Monad<IO>)
+ (do io.Monad<IO>
+ [?client (do (e.ErrorT io.Monad<IO>)
[socket (ServerSocket::accept [] server)]
(tcp-client socket))]
(case ?client
- (#e;Error error)
- (frp;close tail)
+ (#e.Error error)
+ (frp.close tail)
- (#e;Success client)
+ (#e.Success client)
(do @
- [?tail' (frp;write client tail)]
+ [?tail' (frp.write client tail)]
(case ?tail'
- #;None
+ #.None
(wrap true)
- (#;Some tail')
+ (#.Some tail')
(exec (await-server-release tail' server)
(recur tail')))))))))]]
(wrap output))))
diff --git a/stdlib/source/lux/world/net/udp.jvm.lux b/stdlib/source/lux/world/net/udp.jvm.lux
index 3bb94e112..4f58f1563 100644
--- a/stdlib/source/lux/world/net/udp.jvm.lux
+++ b/stdlib/source/lux/world/net/udp.jvm.lux
@@ -1,4 +1,4 @@
-(;module:
+(.module:
lux
(lux (control monad
["ex" exception #+ exception:])
@@ -14,24 +14,24 @@
[host])
[//])
-(host;import java/lang/AutoCloseable
+(host.import java/lang/AutoCloseable
(close [] #io #try void))
-(host;import java/io/Flushable
+(host.import java/io/Flushable
(flush [] #io #try void))
-(host;import java/net/InetAddress
+(host.import java/net/InetAddress
(#static getAllByName [String] #io #try (Array InetAddress))
(getHostAddress [] String))
-(host;import java/net/DatagramPacket
+(host.import java/net/DatagramPacket
(new #as new|send [(Array byte) int int InetAddress int])
(new #as new|receive [(Array byte) int int])
(getAddress [] InetAddress)
(getPort [] int)
(getLength [] int))
-(host;import java/net/DatagramSocket
+(host.import java/net/DatagramSocket
(new #as new|client [] #io #try)
(new #as new|server [int] #io #try)
(receive [DatagramPacket] #io #try void)
@@ -45,24 +45,24 @@
(exception: #export Multiple-Candidate-Addresses)
(def: (resolve address)
- (-> //;Address (io;IO (e;Error InetAddress)))
- (do (e;ErrorT io;Monad<IO>)
+ (-> //.Address (io.IO (e.Error InetAddress)))
+ (do (e.ErrorT io.Monad<IO>)
[addresses (InetAddress::getAllByName [address])]
- (: (io;IO (e;Error InetAddress))
- (case (array;size addresses)
- +0 (io;io (ex;throw Cannot-Resolve-Address address))
- +1 (wrap (maybe;assume (array;read +0 addresses)))
- _ (io;io (ex;throw Multiple-Candidate-Addresses address))))))
+ (: (io.IO (e.Error InetAddress))
+ (case (array.size addresses)
+ +0 (io.io (ex.throw Cannot-Resolve-Address address))
+ +1 (wrap (maybe.assume (array.read +0 addresses)))
+ _ (io.io (ex.throw Multiple-Candidate-Addresses address))))))
(opaque: #export UDP {}
{#socket DatagramSocket}
(def: #export (read data offset length self)
- (-> Blob Nat Nat UDP (T;Task [Nat //;Address //;Port]))
+ (-> Blob Nat Nat UDP (T.Task [Nat //.Address //.Port]))
(let [(^open) (@repr self)
packet (DatagramPacket::new|receive [data (nat-to-int offset) (nat-to-int length)])]
- (P;future
- (do (e;ErrorT io;Monad<IO>)
+ (P.future
+ (do (e.ErrorT io.Monad<IO>)
[_ (DatagramSocket::receive [packet] socket)
#let [bytes-read (int-to-nat (DatagramPacket::getLength [] packet))]]
(wrap [bytes-read
@@ -70,31 +70,31 @@
(int-to-nat (DatagramPacket::getPort [] packet))])))))
(def: #export (write address port data offset length self)
- (-> //;Address //;Port Blob Nat Nat UDP (T;Task Unit))
- (P;future
- (do (e;ErrorT io;Monad<IO>)
+ (-> //.Address //.Port Blob Nat Nat UDP (T.Task Unit))
+ (P.future
+ (do (e.ErrorT io.Monad<IO>)
[address (resolve address)
#let [(^open) (@repr self)]]
(DatagramSocket::send (DatagramPacket::new|send [data (nat-to-int offset) (nat-to-int length) address (nat-to-int port)])
socket))))
(def: #export (close self)
- (-> UDP (T;Task Unit))
+ (-> UDP (T.Task Unit))
(let [(^open) (@repr self)]
- (P;future
+ (P.future
(AutoCloseable::close [] socket))))
(def: #export (client _)
- (-> Unit (T;Task UDP))
- (P;future
- (do (e;ErrorT io;Monad<IO>)
+ (-> Unit (T.Task UDP))
+ (P.future
+ (do (e.ErrorT io.Monad<IO>)
[socket (DatagramSocket::new|client [])]
(wrap (@opaque (#socket socket))))))
(def: #export (server port)
- (-> //;Port (T;Task UDP))
- (P;future
- (do (e;ErrorT io;Monad<IO>)
+ (-> //.Port (T.Task UDP))
+ (P.future
+ (do (e.ErrorT io.Monad<IO>)
[socket (DatagramSocket::new|server [(nat-to-int port)])]
(wrap (@opaque (#socket socket))))))
)