mirror of
https://github.com/unisonweb/unison.git
synced 2024-11-04 01:03:36 +03:00
update transcripts
This commit is contained in:
parent
bd8b2a9af0
commit
685a202319
@ -9,6 +9,7 @@ compose2 f g = a -> b -> f (g a b)
|
||||
compose3 f g = a -> b -> c -> f (g a b c)
|
||||
|
||||
id a = a
|
||||
void x = ()
|
||||
|
||||
structural ability Exception where
|
||||
raise: io2.Failure -> anything
|
||||
|
@ -13,12 +13,12 @@ tested here.
|
||||
```unison
|
||||
test1 : '{IO, Exception} [Result]
|
||||
test1 = do
|
||||
fromUtf8 0xsee
|
||||
_ = fromUtf8 0xsee
|
||||
[Ok "test1"]
|
||||
|
||||
test2 : '{IO, Exception} [Result]
|
||||
test2 = do
|
||||
tryEval '(bug "whoa")
|
||||
_ = tryEval '(bug "whoa")
|
||||
[Ok "test2"]
|
||||
```
|
||||
|
||||
|
@ -9,12 +9,12 @@ tested here.
|
||||
```unison
|
||||
test1 : '{IO, Exception} [Result]
|
||||
test1 = do
|
||||
fromUtf8 0xsee
|
||||
_ = fromUtf8 0xsee
|
||||
[Ok "test1"]
|
||||
|
||||
test2 : '{IO, Exception} [Result]
|
||||
test2 = do
|
||||
tryEval '(bug "whoa")
|
||||
_ = tryEval '(bug "whoa")
|
||||
[Ok "test2"]
|
||||
```
|
||||
|
||||
|
@ -15,7 +15,7 @@ tests _ =
|
||||
[ catcher do
|
||||
match None with Some x -> x
|
||||
, catcher do
|
||||
1/0
|
||||
_ = 1/0
|
||||
()
|
||||
, catcher '(bug "testing")
|
||||
, handle tryEval (do 1+1) with cases
|
||||
|
@ -11,7 +11,7 @@ tests _ =
|
||||
[ catcher do
|
||||
match None with Some x -> x
|
||||
, catcher do
|
||||
1/0
|
||||
_ = 1/0
|
||||
()
|
||||
, catcher '(bug "testing")
|
||||
, handle tryEval (do 1+1) with cases
|
||||
|
@ -8,7 +8,7 @@ functions.
|
||||
```unison
|
||||
Stream.fromList : [a] -> '{Stream a} ()
|
||||
Stream.fromList l _ =
|
||||
List.map (x -> emit x) l
|
||||
_ = List.map (x -> emit x) l
|
||||
()
|
||||
|
||||
Stream.map : (a -> b) -> '{Stream a} r -> '{Stream b} r
|
||||
|
@ -4,7 +4,7 @@ functions.
|
||||
```unison
|
||||
Stream.fromList : [a] -> '{Stream a} ()
|
||||
Stream.fromList l _ =
|
||||
List.map (x -> emit x) l
|
||||
_ = List.map (x -> emit x) l
|
||||
()
|
||||
|
||||
Stream.map : (a -> b) -> '{Stream a} r -> '{Stream b} r
|
||||
|
@ -137,8 +137,8 @@ testTcpConnect = 'let
|
||||
|
||||
toSend = "12345"
|
||||
|
||||
forkComp (serverThread portVar toSend)
|
||||
forkComp (clientThread portVar resultVar)
|
||||
void (forkComp (serverThread portVar toSend))
|
||||
void (forkComp (clientThread portVar resultVar))
|
||||
|
||||
received = take resultVar
|
||||
|
||||
|
@ -165,8 +165,8 @@ testTcpConnect = 'let
|
||||
|
||||
toSend = "12345"
|
||||
|
||||
forkComp (serverThread portVar toSend)
|
||||
forkComp (clientThread portVar resultVar)
|
||||
void (forkComp (serverThread portVar toSend))
|
||||
void (forkComp (clientThread portVar resultVar))
|
||||
|
||||
received = take resultVar
|
||||
|
||||
|
@ -39,8 +39,8 @@ spawn k = let
|
||||
out1 = TVar.newIO None
|
||||
out2 = TVar.newIO None
|
||||
counter = atomically '(TVar.new 0)
|
||||
forkComp '(Right (body k out1 counter))
|
||||
forkComp '(Right (body k out2 counter))
|
||||
void (forkComp '(Right (body k out1 counter)))
|
||||
void (forkComp '(Right (body k out2 counter)))
|
||||
p = atomically 'let
|
||||
r1 = TVar.read out1
|
||||
r2 = TVar.swap out2 None
|
||||
|
@ -60,8 +60,8 @@ spawn k = let
|
||||
out1 = TVar.newIO None
|
||||
out2 = TVar.newIO None
|
||||
counter = atomically '(TVar.new 0)
|
||||
forkComp '(Right (body k out1 counter))
|
||||
forkComp '(Right (body k out2 counter))
|
||||
void (forkComp '(Right (body k out1 counter)))
|
||||
void (forkComp '(Right (body k out2 counter)))
|
||||
p = atomically 'let
|
||||
r1 = TVar.read out1
|
||||
r2 = TVar.swap out2 None
|
||||
|
@ -38,7 +38,7 @@ testBasicMultiThreadMVar : '{io2.IO} [Result]
|
||||
testBasicMultiThreadMVar = 'let
|
||||
test = 'let
|
||||
mv = !newEmpty
|
||||
.builtin.io2.IO.forkComp (thread1 10 mv)
|
||||
void (forkComp (thread1 10 mv))
|
||||
next = take mv
|
||||
expectU "other thread should have incremented" 11 next
|
||||
|
||||
@ -79,8 +79,8 @@ testTwoThreads = 'let
|
||||
send = !MVar.newEmpty
|
||||
recv = !MVar.newEmpty
|
||||
|
||||
.builtin.io2.IO.forkComp (sendingThread 6 send)
|
||||
.builtin.io2.IO.forkComp (receivingThread send recv)
|
||||
void (forkComp (sendingThread 6 send))
|
||||
void (forkComp (receivingThread send recv))
|
||||
|
||||
recvd = take recv
|
||||
|
||||
|
@ -45,7 +45,7 @@ testBasicMultiThreadMVar : '{io2.IO} [Result]
|
||||
testBasicMultiThreadMVar = 'let
|
||||
test = 'let
|
||||
mv = !newEmpty
|
||||
.builtin.io2.IO.forkComp (thread1 10 mv)
|
||||
void (forkComp (thread1 10 mv))
|
||||
next = take mv
|
||||
expectU "other thread should have incremented" 11 next
|
||||
|
||||
@ -113,8 +113,8 @@ testTwoThreads = 'let
|
||||
send = !MVar.newEmpty
|
||||
recv = !MVar.newEmpty
|
||||
|
||||
.builtin.io2.IO.forkComp (sendingThread 6 send)
|
||||
.builtin.io2.IO.forkComp (receivingThread send recv)
|
||||
void (forkComp (sendingThread 6 send))
|
||||
void (forkComp (receivingThread send recv))
|
||||
|
||||
recvd = take recv
|
||||
|
||||
|
@ -137,7 +137,7 @@ testConnectSelfSigned _ =
|
||||
cert = decodeCert (toUtf8 self_signed_cert_pem2)
|
||||
received = !(testClient (Some cert) "test.unison.cloud" portVar)
|
||||
|
||||
kill.impl tid
|
||||
_ = kill.impl tid
|
||||
|
||||
expectU "should have reaped what we've sown" toSend received
|
||||
|
||||
|
@ -154,7 +154,7 @@ testConnectSelfSigned _ =
|
||||
cert = decodeCert (toUtf8 self_signed_cert_pem2)
|
||||
received = !(testClient (Some cert) "test.unison.cloud" portVar)
|
||||
|
||||
kill.impl tid
|
||||
_ = kill.impl tid
|
||||
|
||||
expectU "should have reaped what we've sown" toSend received
|
||||
|
||||
|
@ -16,10 +16,11 @@ remain in the definition of `baz`.
|
||||
```unison
|
||||
foo _ =
|
||||
id x = x
|
||||
void x = ()
|
||||
bar = let
|
||||
Debug.watch "hello" "hello"
|
||||
void (Debug.watch "hello" "hello")
|
||||
result = 5
|
||||
Debug.watch "goodbye" "goodbye"
|
||||
void (Debug.watch "goodbye" "goodbye")
|
||||
result
|
||||
baz = id bar
|
||||
baz
|
||||
|
@ -12,10 +12,11 @@ remain in the definition of `baz`.
|
||||
```unison
|
||||
foo _ =
|
||||
id x = x
|
||||
void x = ()
|
||||
bar = let
|
||||
Debug.watch "hello" "hello"
|
||||
void (Debug.watch "hello" "hello")
|
||||
result = 5
|
||||
Debug.watch "goodbye" "goodbye"
|
||||
void (Debug.watch "goodbye" "goodbye")
|
||||
result
|
||||
baz = id bar
|
||||
baz
|
||||
@ -36,7 +37,7 @@ foo _ =
|
||||
Now evaluating any watch expressions (lines starting with
|
||||
`>`)... Ctrl+C cancels.
|
||||
|
||||
11 | > !foo
|
||||
12 | > !foo
|
||||
⧩
|
||||
5
|
||||
|
||||
|
@ -9,7 +9,7 @@ Docs can be used as inline code comments.
|
||||
```unison
|
||||
foo : Nat -> Nat
|
||||
foo n =
|
||||
[: do the thing :]
|
||||
_ = [: do the thing :]
|
||||
n + 1
|
||||
```
|
||||
|
||||
|
@ -5,7 +5,7 @@ Docs can be used as inline code comments.
|
||||
```unison
|
||||
foo : Nat -> Nat
|
||||
foo n =
|
||||
[: do the thing :]
|
||||
_ = [: do the thing :]
|
||||
n + 1
|
||||
```
|
||||
|
||||
@ -26,7 +26,7 @@ foo n =
|
||||
foo : Nat -> Nat
|
||||
foo n =
|
||||
use Nat +
|
||||
[: do the thing :]
|
||||
_ = [: do the thing :]
|
||||
n + 1
|
||||
|
||||
```
|
||||
@ -500,7 +500,7 @@ But note it's not obvious how display should best be handling this. At the mome
|
||||
foo : Nat -> Nat
|
||||
foo n =
|
||||
use Nat +
|
||||
[: do the thing :]
|
||||
_ = [: do the thing :]
|
||||
n + 1 ▶ bar
|
||||
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
```unison:hide
|
||||
printLine : Text ->{IO} ()
|
||||
printLine msg =
|
||||
putBytes.impl (stdHandle StdOut) (Text.toUtf8 (msg ++ "\n"))
|
||||
_ = putBytes.impl (stdHandle StdOut) (Text.toUtf8 (msg ++ "\n"))
|
||||
()
|
||||
|
||||
-- An unannotated main function
|
||||
|
@ -2,7 +2,7 @@
|
||||
```unison
|
||||
printLine : Text ->{IO} ()
|
||||
printLine msg =
|
||||
putBytes.impl (stdHandle StdOut) (Text.toUtf8 (msg ++ "\n"))
|
||||
_ = putBytes.impl (stdHandle StdOut) (Text.toUtf8 (msg ++ "\n"))
|
||||
()
|
||||
|
||||
-- An unannotated main function
|
||||
|
@ -21,7 +21,7 @@ Another example, involving abilities. Here the ability-polymorphic function is i
|
||||
```unison
|
||||
f : (forall a g . '{g} a -> '{g} a) -> () -> ()
|
||||
f id _ =
|
||||
(id ('1 : '{} Nat), id ('("hi") : '{IO} Text))
|
||||
_ = (id ('1 : '{} Nat), id ('("hi") : '{IO} Text))
|
||||
()
|
||||
```
|
||||
|
||||
|
@ -33,7 +33,7 @@ Another example, involving abilities. Here the ability-polymorphic function is i
|
||||
```unison
|
||||
f : (forall a g . '{g} a -> '{g} a) -> () -> ()
|
||||
f id _ =
|
||||
(id ('1 : '{} Nat), id ('("hi") : '{IO} Text))
|
||||
_ = (id ('1 : '{} Nat), id ('("hi") : '{IO} Text))
|
||||
()
|
||||
```
|
||||
|
||||
|
@ -38,7 +38,8 @@ testCreateRename _ =
|
||||
tempDir = newTempDir "fileio"
|
||||
fooDir = tempDir ++ "/foo"
|
||||
barDir = tempDir ++ "/bar"
|
||||
createDirectory.impl fooDir
|
||||
void x = ()
|
||||
void (createDirectory.impl fooDir)
|
||||
check "create a foo directory" (isDirectory fooDir)
|
||||
check "directory should exist" (fileExists fooDir)
|
||||
renameDirectory fooDir barDir
|
||||
@ -47,8 +48,8 @@ testCreateRename _ =
|
||||
check "bar should now exist" (fileExists barDir)
|
||||
|
||||
bazDir = barDir ++ "/baz"
|
||||
createDirectory.impl bazDir
|
||||
removeDirectory.impl barDir
|
||||
void (createDirectory.impl bazDir)
|
||||
void (removeDirectory.impl barDir)
|
||||
|
||||
check "removeDirectory works recursively" (not (isDirectory barDir))
|
||||
check "removeDirectory works recursively" (not (isDirectory bazDir))
|
||||
|
@ -26,7 +26,8 @@ testCreateRename _ =
|
||||
tempDir = newTempDir "fileio"
|
||||
fooDir = tempDir ++ "/foo"
|
||||
barDir = tempDir ++ "/bar"
|
||||
createDirectory.impl fooDir
|
||||
void x = ()
|
||||
void (createDirectory.impl fooDir)
|
||||
check "create a foo directory" (isDirectory fooDir)
|
||||
check "directory should exist" (fileExists fooDir)
|
||||
renameDirectory fooDir barDir
|
||||
@ -35,8 +36,8 @@ testCreateRename _ =
|
||||
check "bar should now exist" (fileExists barDir)
|
||||
|
||||
bazDir = barDir ++ "/baz"
|
||||
createDirectory.impl bazDir
|
||||
removeDirectory.impl barDir
|
||||
void (createDirectory.impl bazDir)
|
||||
void (removeDirectory.impl barDir)
|
||||
|
||||
check "removeDirectory works recursively" (not (isDirectory barDir))
|
||||
check "removeDirectory works recursively" (not (isDirectory bazDir))
|
||||
|
@ -12,9 +12,7 @@ unique type A = A
|
||||
threadEyeDeez _ =
|
||||
t1 = forkComp '()
|
||||
t2 = forkComp '()
|
||||
t1 == t2
|
||||
t1 < t2
|
||||
()
|
||||
(t1 == t2, t1 < t2)
|
||||
```
|
||||
|
||||
```ucm
|
||||
|
@ -8,9 +8,7 @@ unique type A = A
|
||||
threadEyeDeez _ =
|
||||
t1 = forkComp '()
|
||||
t2 = forkComp '()
|
||||
t1 == t2
|
||||
t1 < t2
|
||||
()
|
||||
(t1 == t2, t1 < t2)
|
||||
```
|
||||
|
||||
```ucm
|
||||
@ -22,7 +20,7 @@ threadEyeDeez _ =
|
||||
⍟ These new definitions are ok to `add`:
|
||||
|
||||
unique type A
|
||||
threadEyeDeez : ∀ _. _ ->{IO} ()
|
||||
threadEyeDeez : ∀ _. _ ->{IO} (Boolean, Boolean)
|
||||
|
||||
```
|
||||
```ucm
|
||||
@ -31,11 +29,11 @@ threadEyeDeez _ =
|
||||
⍟ I've added these definitions:
|
||||
|
||||
unique type A
|
||||
threadEyeDeez : ∀ _. _ ->{IO} ()
|
||||
threadEyeDeez : ∀ _. _ ->{IO} (Boolean, Boolean)
|
||||
|
||||
.> run threadEyeDeez
|
||||
|
||||
()
|
||||
(false, true)
|
||||
|
||||
```
|
||||
```unison
|
||||
|
Loading…
Reference in New Issue
Block a user