aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEduardo Julian2019-06-20 19:49:34 -0400
committerEduardo Julian2019-06-20 19:49:34 -0400
commitfcee38da766a683ed5569978be153c6e7a8ae0af (patch)
tree8d75d3c70de9f3ec4518a58d88b036207f4cc9d3
parent67687850677bb34df37d6e9d1a2578d1198108d6 (diff)
Removed the TCP & UDP code for the moment.
It needs to be re-designed with a multi-platform focus in mind.
Diffstat (limited to '')
-rw-r--r--documentation/research/database.md1
-rw-r--r--documentation/research/operating_system.md4
-rw-r--r--documentation/research/paradigm/flow_based_programming.md4
-rw-r--r--documentation/research/web_framework.md1
-rw-r--r--stdlib/source/lux/world/net/tcp.lux131
-rw-r--r--stdlib/source/lux/world/net/udp.lux123
-rw-r--r--stdlib/source/test/lux/world.lux5
-rw-r--r--stdlib/source/test/lux/world/net/tcp.lux73
-rw-r--r--stdlib/source/test/lux/world/net/udp.lux66
9 files changed, 10 insertions, 398 deletions
diff --git a/documentation/research/database.md b/documentation/research/database.md
index 21a7d54c0..de99fde3f 100644
--- a/documentation/research/database.md
+++ b/documentation/research/database.md
@@ -1,5 +1,6 @@
# Reference
+1. https://edgedb.com/blog/a-path-to-a-10x-database/
1. https://cstack.github.io/db_tutorial/
1. http://www.sql-workbench.eu/dbms_comparison.html
1. http://www.interdb.jp/pg/index.html
diff --git a/documentation/research/operating_system.md b/documentation/research/operating_system.md
index 2ae4828bf..ec9ea3678 100644
--- a/documentation/research/operating_system.md
+++ b/documentation/research/operating_system.md
@@ -85,6 +85,10 @@
1. https://grapheneproject.io/
1. https://ops.city/
+## Real-time
+
+1. https://en.wikipedia.org/wiki/VxWorks
+
# Reference
1. [Rethinking files](https://www.devever.net/~hl/objectworld)
diff --git a/documentation/research/paradigm/flow_based_programming.md b/documentation/research/paradigm/flow_based_programming.md
new file mode 100644
index 000000000..f13969722
--- /dev/null
+++ b/documentation/research/paradigm/flow_based_programming.md
@@ -0,0 +1,4 @@
+# Reference
+
+1. [Towards Separation of Concerns in Flow-Based Programming](http://orbit.dtu.dk/files/128046887/FBDSL_final.pdf)
+
diff --git a/documentation/research/web_framework.md b/documentation/research/web_framework.md
index 9ee78130c..209073106 100644
--- a/documentation/research/web_framework.md
+++ b/documentation/research/web_framework.md
@@ -96,6 +96,7 @@
# State-management
+1. https://github.com/keajs/kea
1. https://github.com/isocroft/Radixx
# Styling
diff --git a/stdlib/source/lux/world/net/tcp.lux b/stdlib/source/lux/world/net/tcp.lux
deleted file mode 100644
index d9011a5cb..000000000
--- a/stdlib/source/lux/world/net/tcp.lux
+++ /dev/null
@@ -1,131 +0,0 @@
-(.module:
- [lux #*
- [host (#+ import:)]
- ["@" target]
- [abstract
- monad]
- [control
- ["." io (#+ IO)]
- [concurrency
- ["." promise (#+ Promise Resolver)]
- ["." frp (#+ Channel Sink)]]
- [security
- ["!" capability]]]
- [data
- ["." error (#+ Error)]]
- [world
- ["." binary (#+ Binary)]]]
- ["." // (#+ Can-Read Can-Write Can-Close)])
-
-(signature: #export (TCP !)
- (: (Can-Read ! [Nat Binary])
- read)
-
- (: (Can-Write ! Binary)
- write)
-
- (: (Can-Close !)
- close))
-
-(def: #export (async tcp)
- (-> (TCP IO) (TCP Promise))
- (`` (structure (~~ (template [<capability> <forge>]
- [(def: <capability> (<forge> (|>> (!.use (:: tcp <capability>)) promise.future)))]
-
- [read //.can-read]
- [write //.can-write]
- [close //.can-close])))))
-
-(with-expansions [<for-jvm> (as-is (import: #long java/lang/String)
-
- (import: #long java/lang/AutoCloseable
- (close [] #io #try void))
-
- (import: #long java/io/Flushable
- (flush [] #io #try void))
-
- (import: #long java/io/InputStream
- (read [[byte] int int] #io #try int))
-
- (import: #long java/io/OutputStream
- (write [[byte] int int] #io #try void))
-
- (import: #long java/net/Socket
- (new [java/lang/String int] #io #try)
- (getInputStream [] #try java/io/InputStream)
- (getOutputStream [] #try java/io/OutputStream))
-
- (import: #long java/net/ServerSocket
- (new [int] #io #try)
- (accept [] #io #try java/net/Socket))
-
- (def: (tcp socket)
- (-> java/net/Socket (Error (TCP IO)))
- (do error.monad
- [input (java/net/Socket::getInputStream socket)
- output (java/net/Socket::getOutputStream socket)]
- (wrap (: (TCP IO)
- (structure (def: read
- (//.can-read
- (function (read size)
- (do (error.with io.monad)
- [#let [data (binary.create size)]
- bytes-read (java/io/InputStream::read data +0 (.int size) input)]
- (wrap [(.nat bytes-read)
- data])))))
-
- (def: write
- (//.can-write
- (function (write data)
- (do (error.with io.monad)
- [_ (java/io/OutputStream::write data +0 (.int (binary.size data))
- output)]
- (java/io/Flushable::flush output)))))
-
- (def: close
- (//.can-close
- (function (close _)
- (do (error.with io.monad)
- [_ (java/lang/AutoCloseable::close input)
- _ (java/lang/AutoCloseable::close output)]
- (java/lang/AutoCloseable::close socket))))))))))
-
- (def: #export (client address port)
- (-> //.Address //.Port (IO (Error (TCP IO))))
- (do (error.with io.monad)
- [socket (java/net/Socket::new address (.int port))]
- (io.io (tcp socket))))
-
- (def: #export (server port)
- (-> //.Port (IO (Error [(Resolver Any)
- (Channel (TCP IO))])))
- (do (error.with io.monad)
- [server (java/net/ServerSocket::new (.int port))
- #let [[close-signal close-resolver] (: [(Promise Any) (Resolver Any)]
- (promise.promise []))
- _ (promise.await (function (_ _)
- (java/lang/AutoCloseable::close server))
- close-signal)
- [output sink] (: [(Channel (TCP IO)) (Sink (TCP IO))]
- (frp.channel []))
- _ (: (Promise Any)
- (promise.future
- (loop [_ []]
- (do io.monad
- [?client (do (error.with io.monad)
- [socket (java/net/ServerSocket::accept server)]
- (io.io (tcp socket)))]
- (case ?client
- (#error.Failure error)
- (wrap [])
-
- (#error.Success client)
- (do @
- [_ (:: sink feed client)]
- (recur [])))))))]]
- (wrap [close-resolver output]))))]
- (`` (for {(~~ (static @.old))
- (as-is <for-jvm>)
-
- (~~ (static @.jvm))
- (as-is <for-jvm>)})))
diff --git a/stdlib/source/lux/world/net/udp.lux b/stdlib/source/lux/world/net/udp.lux
deleted file mode 100644
index 44a1354cc..000000000
--- a/stdlib/source/lux/world/net/udp.lux
+++ /dev/null
@@ -1,123 +0,0 @@
-(.module:
- [lux #*
- [host (#+ import:)]
- ["@" target]
- [abstract
- monad]
- [control
- ["ex" exception (#+ exception:)]
- ["." io (#+ IO)]
- [concurrency
- ["." promise (#+ Promise)]]
- [security
- ["!" capability]]]
- [data
- ["." error (#+ Error)]
- ["." maybe]
- [collection
- ["." array]]]
- [world
- ["." binary (#+ Binary)]]]
- ["." // (#+ Location Can-Read Can-Write Can-Close)])
-
-(exception: #export (cannot-resolve-address {address //.Address})
- (ex.report ["Address" address]))
-
-(exception: #export (multiple-candidate-addresses {address //.Address})
- (ex.report ["Address" address]))
-
-(signature: #export (UDP !)
- (: (Can-Read ! [Nat Location Binary])
- read)
-
- (: (Can-Write ! [Location Binary])
- write)
-
- (: (Can-Close !)
- close))
-
-(def: #export (async udp)
- (-> (UDP IO) (UDP Promise))
- (`` (structure (~~ (template [<name> <forge>]
- [(def: <name> (<forge> (|>> (!.use (:: udp <name>)) promise.future)))]
-
- [read //.can-read]
- [write //.can-write]
- [close //.can-close])))))
-
-(with-expansions [<for-jvm> (as-is (import: #long java/lang/String)
-
- (import: #long java/lang/AutoCloseable
- (close [] #io #try void))
-
- (import: #long java/net/InetAddress
- (#static getAllByName [java/lang/String] #io #try [java/net/InetAddress])
- (getHostAddress [] java/lang/String))
-
- (import: #long java/net/DatagramPacket
- (new #as new|send [[byte] int int java/net/InetAddress int])
- (new #as new|receive [[byte] int int])
- (getAddress [] java/net/InetAddress)
- (getPort [] int)
- (getLength [] int))
-
- (import: #long java/net/DatagramSocket
- (new #as new|client [] #io #try)
- (new #as new|server [int] #io #try)
- (receive [java/net/DatagramPacket] #io #try void)
- (send [java/net/DatagramPacket] #io #try void))
-
- (def: (resolve address)
- (-> //.Address (IO (Error java/net/InetAddress)))
- (do (error.with io.monad)
- [addresses (java/net/InetAddress::getAllByName address)]
- (: (IO (Error java/net/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))))))
-
- (def: (udp socket)
- (-> java/net/DatagramSocket (UDP IO))
- (structure (def: read
- (//.can-read
- (function (read size)
- (let [data (binary.create size)
- packet (java/net/DatagramPacket::new|receive data +0 (.int size))]
- (do (error.with io.monad)
- [_ (java/net/DatagramSocket::receive packet socket)
- #let [bytes-read (.nat (java/net/DatagramPacket::getLength packet))]]
- (wrap [bytes-read
- {#//.address (|> packet java/net/DatagramPacket::getAddress java/net/InetAddress::getHostAddress)
- #//.port (.nat (java/net/DatagramPacket::getPort packet))}
- data]))))))
-
- (def: write
- (//.can-write
- (function (write [location data])
- (do (error.with io.monad)
- [address (resolve (get@ #//.address location))]
- (java/net/DatagramSocket::send (java/net/DatagramPacket::new|send data +0 (.int (binary.size data)) address (.int (get@ #//.port location)))
- socket)))))
-
- (def: close
- (//.can-close
- (function (close _)
- (java/lang/AutoCloseable::close socket))))))
-
- (def: #export client
- (IO (Error (UDP IO)))
- (|> (java/net/DatagramSocket::new|client)
- (:: (error.with io.monad) map ..udp)))
-
- (def: #export server
- (-> //.Port (IO (Error (UDP IO))))
- (|>> .int
- java/net/DatagramSocket::new|server
- (:: (error.with io.monad) map ..udp)))
- )]
- (`` (for {(~~ (static @.old))
- (as-is <for-jvm>)
-
- (~~ (static @.jvm))
- (as-is <for-jvm>)})))
diff --git a/stdlib/source/test/lux/world.lux b/stdlib/source/test/lux/world.lux
index b23b29dbe..bfd9e6194 100644
--- a/stdlib/source/test/lux/world.lux
+++ b/stdlib/source/test/lux/world.lux
@@ -4,9 +4,6 @@
["." / #_
["#." binary]
["#." file]
- ["#." net #_
- ["#/." tcp]
- ["#/." udp]]
])
(def: #export test
@@ -14,6 +11,4 @@
($_ _.and
/binary.test
/file.test
- /net/tcp.test
- /net/udp.test
))
diff --git a/stdlib/source/test/lux/world/net/tcp.lux b/stdlib/source/test/lux/world/net/tcp.lux
deleted file mode 100644
index fb4983302..000000000
--- a/stdlib/source/test/lux/world/net/tcp.lux
+++ /dev/null
@@ -1,73 +0,0 @@
-(.module:
- [lux #*
- data/text/format
- ["r" math/random (#+ Random)]
- ["_" test (#+ Test)]
- ["." abstract/monad (#+ do)]
- [control
- ["ex" exception (#+ exception:)]
- ["." io (#+ IO)]
- [concurrency
- ["." promise (#+ Promise Resolver)]
- ["." frp ("#@." functor)]]
- [security
- ["!" capability]]]
- [data
- ["." error (#+ Error)]
- ["." text]]
- [world
- ["." binary]
- ["." net]]]
- {1
- ["." /]}
- [///
- ["_." binary]])
-
-(def: localhost net.Address "127.0.0.1")
-
-(def: port
- (r.Random net.Port)
- (|> r.nat
- (:: r.monad map
- (|>> (n/% 1000)
- (n/+ 8000)))))
-
-(def: #export test
- Test
- (<| (_.context (%name (name-of /._)))
- (do r.monad
- [port ..port
- size (|> r.nat (:: @ map (|>> (n/% 100) (n/max 10))))
- from (_binary.binary size)
- to (_binary.binary size)]
- ($_ _.and
- (wrap (do promise.monad
- [#let [[from-worked? from-worked!] (: [(Promise Bit) (Resolver Bit)]
- (promise.promise []))]
- result (promise.future
- (do (error.with io.monad)
- [[close! server] (/.server port)
- #let [_ (frp@map (function (_ client)
- (promise.future
- (do @
- [[trasmission-size transmission] (!.use (:: client read) size)
- #let [_ (io.run (from-worked! (and (n/= size trasmission-size)
- (:: binary.equivalence = from transmission))))]]
- (!.use (:: client write) to))))
- server)]
- client (/.client localhost port)
- _ (!.use (:: client write) from)
- ####################
- [trasmission-size transmission] (!.use (:: client read) size)
- #let [to-worked? (and (n/= size trasmission-size)
- (:: binary.equivalence = to transmission))]
- ####################
- _ (!.use (:: client close) [])
- _ (: (IO (Error Bit))
- (error.lift io.monad (close! [])))]
- (wrap to-worked?)))
- from-worked? from-worked?]
- (_.assert "Can communicate between client and server."
- (and from-worked?
- (error.default #0 result)))))
- ))))
diff --git a/stdlib/source/test/lux/world/net/udp.lux b/stdlib/source/test/lux/world/net/udp.lux
deleted file mode 100644
index 44765acab..000000000
--- a/stdlib/source/test/lux/world/net/udp.lux
+++ /dev/null
@@ -1,66 +0,0 @@
-(.module:
- [lux #*
- data/text/format
- ["r" math/random (#+ Random)]
- ["_" test (#+ Test)]
- ["." abstract/monad (#+ do)]
- [control
- ["." io]
- [concurrency
- ["." promise]]
- [security
- ["!" capability]]]
- [data
- ["." error]
- ["." text]]
- [world
- ["." binary]
- ["." net]]]
- {1
- ["." /]}
- [///
- ["_." binary]])
-
-(def: localhost net.Address "127.0.0.1")
-(def: port
- (r.Random net.Port)
- (|> r.nat
- (:: r.monad map
- (|>> (n/% 1000)
- (n/+ 8000)))))
-
-(def: #export test
- Test
- (<| (_.context (%name (name-of /._)))
- (do r.monad
- [port ..port
- size (|> r.nat (:: @ map (|>> (n/% 100) (n/max 10))))
- from (_binary.binary size)
- to (_binary.binary size)]
- ($_ _.and
- (wrap (do promise.monad
- [result (promise.future
- (do (error.with io.monad)
- [server (/.server port)
- client /.client
- ####################
- _ (!.use (:: client write) [[localhost port] from])
- [bytes-from [from-address from-port] temp] (!.use (:: server read) size)
- #let [from-worked? (and (n/= size bytes-from)
- (:: binary.equivalence = from temp))]
- ####################
- _ (!.use (:: server write) [[from-address from-port] to])
- [bytes-to [to-address to-port] temp] (!.use (:: client read) size)
- #let [to-worked? (and (n/= size bytes-to)
- (:: binary.equivalence = to temp)
- (n/= port to-port))]
- ####################
- _ (!.use (:: client close) [])
- _ (!.use (:: server close) [])]
- ## (wrap false)
- (wrap (and from-worked?
- to-worked?))
- ))]
- (_.assert "Can communicate between client and server."
- (error.default #0 result))))
- ))))