Skip to content

Commit fa86381

Browse files
committed
WIP
1 parent a0fc6e6 commit fa86381

File tree

2 files changed

+5
-32
lines changed

2 files changed

+5
-32
lines changed

README.md

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ rm -rf /usr/local/share/emacs/site-lisp/agda
6868
Save the following code into a file called `hello.agda`.
6969

7070
```agda
71+
{-# OPTIONS --guardedness #-}
72+
7173
open import Prelude
7274
open import System.IO
7375
@@ -85,38 +87,7 @@ agda --compile hello.agda
8587

8688
Save the following code into a file called `echo-server.agda`:
8789

88-
```agda
89-
{-# OPTIONS --guardedness #-}
90-
91-
open import Prelude
92-
93-
open import Data.Bytes as Bytes using ()
94-
open import Data.List as List using ()
95-
open import Data.String.Encoding
96-
open import Network.Socket
97-
open import System.IO
98-
99-
runTCPEchoServer : IO Unit
100-
runTCPEchoServer = do
101-
(serverAddr , _) <- getAddrInfo nothing (just "127.0.0.1") (just "7000")
102-
serverSocket <- socket (addrFamily serverAddr) sockStream defaultProtocol
103-
setSocketOption serverSocket reuseAddr 1
104-
bind serverSocket (addrAddress serverAddr)
105-
listen serverSocket 1
106-
(clientSocket , _) <- accept serverSocket
107-
print {String} "Waiting for a message..."
108-
message <- recv clientSocket 1024
109-
unless (Bytes.null message) do
110-
print ("Received: " <> decodeUtf8 message)
111-
print {String} "Echoing..."
112-
sendAll clientSocket message
113-
print {String} "Closing..."
114-
close clientSocket
115-
close serverSocket
116-
117-
main : IO Unit
118-
main = runTCPEchoServer
119-
```
90+
https://github.com/berndlosert/agda-base/blob/master/examples/echo-server.agda#L1-L30
12091

12192
Compile this code by running `agda --compile echo-server.agda`. If you get the
12293
following errors:

examples/echo-server.agda

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{-# OPTIONS --guardedness #-}
2+
13
open import Prelude
24

35
open import Data.Bytes as Bytes using ()

0 commit comments

Comments
 (0)