From 5a7e3b49323c0beb61942527224a826b72d2d784 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Sun, 14 Apr 2024 20:01:39 -0400 Subject: [PATCH] cleanup --- .../binary-encoding-nats.md | 9 --- .../binary-encoding-nats.output.md | 1 - unison-src/transcripts-using-base/codeops.md | 8 +-- .../transcripts-using-base/codeops.output.md | 4 +- unison-src/transcripts-using-base/doc.md | 4 -- .../transcripts-using-base/failure-tests.md | 4 -- unison-src/transcripts-using-base/fix2049.md | 30 ---------- .../transcripts-using-base/fix2049.output.md | 56 ------------------- unison-src/transcripts-using-base/tls.md | 7 --- unison-src/transcripts-using-base/utf8.md | 4 -- .../fix2027.md | 2 +- .../fix2027.output.md | 26 ++++----- unison-src/transcripts/fix2049.md | 26 +++++++++ unison-src/transcripts/fix2049.output.md | 56 +++++++++++++++++++ unison-src/transcripts/fix2053.md | 2 +- unison-src/transcripts/fix2187.output.md | 6 +- .../fix2244.md | 1 - .../fix2244.output.md | 0 .../fix2244.u | 0 19 files changed, 102 insertions(+), 144 deletions(-) rename unison-src/{transcripts-using-base => transcripts}/fix2027.md (98%) rename unison-src/{transcripts-using-base => transcripts}/fix2027.output.md (77%) rename unison-src/{transcripts-using-base => transcripts}/fix2244.md (99%) rename unison-src/{transcripts-using-base => transcripts}/fix2244.output.md (100%) rename unison-src/{transcripts-using-base => transcripts}/fix2244.u (100%) diff --git a/unison-src/transcripts-using-base/binary-encoding-nats.md b/unison-src/transcripts-using-base/binary-encoding-nats.md index 396801190..711bcb330 100644 --- a/unison-src/transcripts-using-base/binary-encoding-nats.md +++ b/unison-src/transcripts-using-base/binary-encoding-nats.md @@ -1,12 +1,3 @@ - -```ucm:hide -.> builtins.merge -.> builtins.mergeio -.> load unison-src/transcripts-using-base/base.u -.> add -.> find -``` - ```unison unique type EncDec = EncDec Text (Nat -> Bytes) (Bytes -> Optional (Nat, Bytes)) diff --git a/unison-src/transcripts-using-base/binary-encoding-nats.output.md b/unison-src/transcripts-using-base/binary-encoding-nats.output.md index 773d53a24..0227ff8e2 100644 --- a/unison-src/transcripts-using-base/binary-encoding-nats.output.md +++ b/unison-src/transcripts-using-base/binary-encoding-nats.output.md @@ -1,4 +1,3 @@ - ```unison unique type EncDec = EncDec Text (Nat -> Bytes) (Bytes -> Optional (Nat, Bytes)) diff --git a/unison-src/transcripts-using-base/codeops.md b/unison-src/transcripts-using-base/codeops.md index 2bc9c99ca..4754eb0aa 100644 --- a/unison-src/transcripts-using-base/codeops.md +++ b/unison-src/transcripts-using-base/codeops.md @@ -1,10 +1,6 @@ Test for code serialization operations. -```ucm:hide -.> builtins.merge -``` - Define a function, serialize it, then deserialize it back to an actual function. Also ask for its dependencies for display later. @@ -138,8 +134,8 @@ verified name link = with handleTest ("verified " ++ name) rejected : Text -> [(Link.Term,Code)] ->{io2.IO} Result -rejected name rco = - handle verify name rco +rejected name rco = + handle verify name rco with expectFailure ("rejected " ++ name) missed : Text -> Link.Term -> Result diff --git a/unison-src/transcripts-using-base/codeops.output.md b/unison-src/transcripts-using-base/codeops.output.md index ac5fd9102..3f76560f4 100644 --- a/unison-src/transcripts-using-base/codeops.output.md +++ b/unison-src/transcripts-using-base/codeops.output.md @@ -134,8 +134,8 @@ verified name link = with handleTest ("verified " ++ name) rejected : Text -> [(Link.Term,Code)] ->{io2.IO} Result -rejected name rco = - handle verify name rco +rejected name rco = + handle verify name rco with expectFailure ("rejected " ++ name) missed : Text -> Link.Term -> Result diff --git a/unison-src/transcripts-using-base/doc.md b/unison-src/transcripts-using-base/doc.md index 518a5b1ca..461a4f04b 100644 --- a/unison-src/transcripts-using-base/doc.md +++ b/unison-src/transcripts-using-base/doc.md @@ -1,9 +1,5 @@ # Computable documents in Unison -```ucm:hide -.> builtins.mergeio -``` - Unison documentation is written in Unison and has some neat features: * The documentation type provides a rich vocabulary of elements that go beyond markdown, including asides, callouts, tooltips, and more. diff --git a/unison-src/transcripts-using-base/failure-tests.md b/unison-src/transcripts-using-base/failure-tests.md index 9affd7aff..049b4fcbb 100644 --- a/unison-src/transcripts-using-base/failure-tests.md +++ b/unison-src/transcripts-using-base/failure-tests.md @@ -6,10 +6,6 @@ Exception ability directly, and the last is code validation. I don't have an easy way to test the last at the moment, but the other two are tested here. -```ucm:hide -.> builtins.mergeio -``` - ```unison test1 : '{IO, Exception} [Result] test1 = do diff --git a/unison-src/transcripts-using-base/fix2049.md b/unison-src/transcripts-using-base/fix2049.md index 5ccb89a46..e69de29bb 100644 --- a/unison-src/transcripts-using-base/fix2049.md +++ b/unison-src/transcripts-using-base/fix2049.md @@ -1,30 +0,0 @@ -```ucm:hide -.> builtins.mergeio -``` - -Tests some capabilities for catching runtime exceptions. - -```unison -catcher : '{IO} () ->{IO} Result -catcher act = - handle tryEval act with cases - { raise _ -> _ } -> Ok "caught" - { _ } -> Fail "nothing to catch" - -tests _ = - [ catcher do - _ = 1/0 - () - , catcher '(bug "testing") - , handle tryEval (do 1+1) with cases - { raise _ -> _ } -> Fail "1+1 failed" - { 2 } -> Ok "got the right answer" - { _ } -> Fail "got the wrong answer" - ] -``` - -```ucm -.> add -.> io.test tests -``` - diff --git a/unison-src/transcripts-using-base/fix2049.output.md b/unison-src/transcripts-using-base/fix2049.output.md index 79ae3d0b6..e69de29bb 100644 --- a/unison-src/transcripts-using-base/fix2049.output.md +++ b/unison-src/transcripts-using-base/fix2049.output.md @@ -1,56 +0,0 @@ -Tests some capabilities for catching runtime exceptions. - -```unison -catcher : '{IO} () ->{IO} Result -catcher act = - handle tryEval act with cases - { raise _ -> _ } -> Ok "caught" - { _ } -> Fail "nothing to catch" - -tests _ = - [ catcher do - _ = 1/0 - () - , catcher '(bug "testing") - , handle tryEval (do 1+1) with cases - { raise _ -> _ } -> Fail "1+1 failed" - { 2 } -> Ok "got the right answer" - { _ } -> Fail "got the wrong answer" - ] -``` - -```ucm - - Loading changes detected in scratch.u. - - I found and typechecked these definitions in scratch.u. If you - do an `add` or `update`, here's how your codebase would - change: - - ⍟ These new definitions are ok to `add`: - - catcher : '{IO} () ->{IO} Result - tests : ∀ _. _ ->{IO} [Result] - -``` -```ucm -.> add - - ⍟ I've added these definitions: - - catcher : '{IO} () ->{IO} Result - tests : ∀ _. _ ->{IO} [Result] - -.> io.test tests - - New test results: - - ◉ tests caught - ◉ tests caught - ◉ tests got the right answer - - ✅ 3 test(s) passing - - Tip: Use view tests to view the source of a test. - -``` diff --git a/unison-src/transcripts-using-base/tls.md b/unison-src/transcripts-using-base/tls.md index cb929786d..77c66db49 100644 --- a/unison-src/transcripts-using-base/tls.md +++ b/unison-src/transcripts-using-base/tls.md @@ -1,12 +1,5 @@ # Tests for TLS builtins -```ucm:hide -.> builtins.merge -.> builtins.mergeio -.> load unison-src/transcripts-using-base/base.u -.> add -``` - ```unison:hide -- generated with: -- openssl req -newkey rsa:2048 -subj '/CN=test.unison.cloud/O=Unison/C=US' -nodes -keyout key.pem -x509 -days 3650 -out cert.pem diff --git a/unison-src/transcripts-using-base/utf8.md b/unison-src/transcripts-using-base/utf8.md index 56a84bc0c..107bd260c 100644 --- a/unison-src/transcripts-using-base/utf8.md +++ b/unison-src/transcripts-using-base/utf8.md @@ -1,9 +1,5 @@ Test for new Text -> Bytes conversions explicitly using UTF-8 as the encoding -```ucm:hide -.> builtins.merge -``` - Unison has function for converting between `Text` and a UTF-8 `Bytes` encoding of the Text. ```ucm diff --git a/unison-src/transcripts-using-base/fix2027.md b/unison-src/transcripts/fix2027.md similarity index 98% rename from unison-src/transcripts-using-base/fix2027.md rename to unison-src/transcripts/fix2027.md index 23e9498ca..665ee6f21 100644 --- a/unison-src/transcripts-using-base/fix2027.md +++ b/unison-src/transcripts/fix2027.md @@ -1,7 +1,7 @@ ```ucm:hide -.> builtins.mergeio +.> builtins.merge ``` ```unison diff --git a/unison-src/transcripts-using-base/fix2027.output.md b/unison-src/transcripts/fix2027.output.md similarity index 77% rename from unison-src/transcripts-using-base/fix2027.output.md rename to unison-src/transcripts/fix2027.output.md index 2ea0abfe6..4f515e763 100644 --- a/unison-src/transcripts-using-base/fix2027.output.md +++ b/unison-src/transcripts/fix2027.output.md @@ -54,33 +54,29 @@ myServer = unsafeRun! '(hello "127.0.0.1" "0") do an `add` or `update`, here's how your codebase would change: - ⊡ Previously added definitions will be ignored: Exception - ⍟ These new definitions are ok to `add`: structural type Either a b (also named builtin.Either) - bugFail : Failure -> r - hello : Text -> Text ->{IO, Exception} () - myServer : '{IO} () - putText : Handle -> Text ->{IO, Exception} () - reraise : Either Failure b ->{Exception} b - (also named Exception.reraise) - socketSend : Socket -> Bytes ->{IO, Exception} () - toException : Either Failure a ->{Exception} a - (also named Exception.reraise) - - ⍟ These names already exist. You can `update` them to your - new definition: - + structural ability Exception + (also named builtin.Exception) Exception.unsafeRun! : '{g, Exception} a -> '{g} a + bugFail : Failure -> r closeSocket : Socket ->{IO, Exception} () + hello : Text -> Text ->{IO, Exception} () + myServer : '{IO} () putBytes : Handle -> Bytes ->{IO, Exception} () + putText : Handle -> Text ->{IO, Exception} () + reraise : Either Failure b ->{Exception} b serverSocket : Optional Text -> Text ->{IO, Exception} Socket + socketSend : Socket + -> Bytes + ->{IO, Exception} () + toException : Either Failure a ->{Exception} a ``` ```ucm diff --git a/unison-src/transcripts/fix2049.md b/unison-src/transcripts/fix2049.md index 02a8052bb..ab1983e95 100644 --- a/unison-src/transcripts/fix2049.md +++ b/unison-src/transcripts/fix2049.md @@ -51,3 +51,29 @@ Fold.Stream.fold = res = Fold.Stream.fold (folds.all pred) (Stream.range 1 5) !res Universal.== false ``` + +Tests some capabilities for catching runtime exceptions. + +```unison +catcher : '{IO} () ->{IO} Result +catcher act = + handle tryEval act with cases + { raise _ -> _ } -> Ok "caught" + { _ } -> Fail "nothing to catch" + +tests _ = + [ catcher do + _ = 1/0 + () + , catcher '(bug "testing") + , handle tryEval (do 1+1) with cases + { raise _ -> _ } -> Fail "1+1 failed" + { 2 } -> Ok "got the right answer" + { _ } -> Fail "got the wrong answer" + ] +``` + +```ucm +.> add +.> io.test tests +``` diff --git a/unison-src/transcripts/fix2049.output.md b/unison-src/transcripts/fix2049.output.md index db7ef6106..7e18e1f6c 100644 --- a/unison-src/transcripts/fix2049.output.md +++ b/unison-src/transcripts/fix2049.output.md @@ -85,3 +85,59 @@ Fold.Stream.fold = true ``` +Tests some capabilities for catching runtime exceptions. + +```unison +catcher : '{IO} () ->{IO} Result +catcher act = + handle tryEval act with cases + { raise _ -> _ } -> Ok "caught" + { _ } -> Fail "nothing to catch" + +tests _ = + [ catcher do + _ = 1/0 + () + , catcher '(bug "testing") + , handle tryEval (do 1+1) with cases + { raise _ -> _ } -> Fail "1+1 failed" + { 2 } -> Ok "got the right answer" + { _ } -> Fail "got the wrong answer" + ] +``` + +```ucm + + Loading changes detected in scratch.u. + + I found and typechecked these definitions in scratch.u. If you + do an `add` or `update`, here's how your codebase would + change: + + ⍟ These new definitions are ok to `add`: + + catcher : '{IO} () ->{IO} Result + tests : ∀ _. _ ->{IO} [Result] + +``` +```ucm +.> add + + ⍟ I've added these definitions: + + catcher : '{IO} () ->{IO} Result + tests : ∀ _. _ ->{IO} [Result] + +.> io.test tests + + New test results: + + ◉ tests caught + ◉ tests caught + ◉ tests got the right answer + + ✅ 3 test(s) passing + + Tip: Use view tests to view the source of a test. + +``` diff --git a/unison-src/transcripts/fix2053.md b/unison-src/transcripts/fix2053.md index 7309d80b6..120bbed31 100644 --- a/unison-src/transcripts/fix2053.md +++ b/unison-src/transcripts/fix2053.md @@ -4,4 +4,4 @@ ```ucm .> display List.map -``` \ No newline at end of file +``` diff --git a/unison-src/transcripts/fix2187.output.md b/unison-src/transcripts/fix2187.output.md index 50b493aca..8f499449e 100644 --- a/unison-src/transcripts/fix2187.output.md +++ b/unison-src/transcripts/fix2187.output.md @@ -1,11 +1,11 @@ ```unison lexicalScopeEx: [Text] -lexicalScopeEx = +lexicalScopeEx = parent = "outer" - inner1 = let + inner1 = let child1 = "child1" inner2 : [Text] - inner2 = let + inner2 = let child2 = "child2" [parent, child1, child2] inner2 diff --git a/unison-src/transcripts-using-base/fix2244.md b/unison-src/transcripts/fix2244.md similarity index 99% rename from unison-src/transcripts-using-base/fix2244.md rename to unison-src/transcripts/fix2244.md index 61ae1d47c..cbf191779 100644 --- a/unison-src/transcripts-using-base/fix2244.md +++ b/unison-src/transcripts/fix2244.md @@ -11,4 +11,3 @@ Ensure closing token is emitted by closing brace in doc eval block. ```ucm:hide .> add ``` - diff --git a/unison-src/transcripts-using-base/fix2244.output.md b/unison-src/transcripts/fix2244.output.md similarity index 100% rename from unison-src/transcripts-using-base/fix2244.output.md rename to unison-src/transcripts/fix2244.output.md diff --git a/unison-src/transcripts-using-base/fix2244.u b/unison-src/transcripts/fix2244.u similarity index 100% rename from unison-src/transcripts-using-base/fix2244.u rename to unison-src/transcripts/fix2244.u