From 15cd84c5c83dffaff60b03004a5b4bbbfd7cfecb Mon Sep 17 00:00:00 2001 From: Chris Penner Date: Tue, 7 Jan 2025 14:04:58 -0800 Subject: [PATCH 1/2] Fix old bool wrapper on setEcho builtin --- unison-runtime/src/Unison/Runtime/Builtin.hs | 5 ++--- unison-runtime/src/Unison/Runtime/Stack.hs | 2 +- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/unison-runtime/src/Unison/Runtime/Builtin.hs b/unison-runtime/src/Unison/Runtime/Builtin.hs index f6e610cdf7..6752dcbd34 100644 --- a/unison-runtime/src/Unison/Runtime/Builtin.hs +++ b/unison-runtime/src/Unison/Runtime/Builtin.hs @@ -1015,11 +1015,10 @@ set'echo :: ForeignOp set'echo instr = ([BX, BX],) . TAbss [arg1, arg2] - . unenum 2 arg2 Ty.booleanRef bol - . TLetD result UN (TFOp instr [arg1, bol]) + . TLetD result UN (TFOp instr [arg1, arg2]) $ outIoFailUnit stack1 stack2 stack3 unit fail result where - (arg1, arg2, bol, stack1, stack2, stack3, unit, fail, result) = fresh + (arg1, arg2, stack1, stack2, stack3, unit, fail, result) = fresh -- a -> IOMode -> ... inIomr :: forall v. (Var v) => v -> v -> v -> v -> ANormal v -> ForeignFunc -> ([Mem], ANormal v) diff --git a/unison-runtime/src/Unison/Runtime/Stack.hs b/unison-runtime/src/Unison/Runtime/Stack.hs index 595bc2818d..4babe7f3d7 100644 --- a/unison-runtime/src/Unison/Runtime/Stack.hs +++ b/unison-runtime/src/Unison/Runtime/Stack.hs @@ -1181,7 +1181,7 @@ peekOffBool stk i = do b <- bpeekOff stk i pure $ case b of Enum _ t -> t /= TT.falseTag - _ -> error "peekBool: not a boolean" + _ -> error "peekOffBool: not a boolean" {-# INLINE peekOffBool #-} peekOffS :: Stack -> Int -> IO USeq From e5242d2843a79d510cd730e51b7ecb2c41ab3d46 Mon Sep 17 00:00:00 2001 From: Chris Penner Date: Tue, 7 Jan 2025 14:19:07 -0800 Subject: [PATCH 2/2] Add transcript for setEcho --- unison-src/transcripts/idempotent/io.md | 28 +++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/unison-src/transcripts/idempotent/io.md b/unison-src/transcripts/idempotent/io.md index 314a76e1b4..6244e80ad8 100644 --- a/unison-src/transcripts/idempotent/io.md +++ b/unison-src/transcripts/idempotent/io.md @@ -319,6 +319,14 @@ testSeek _ = runTest test +testSetEcho : '{io2.IO} [Result] +testSetEcho = do + a = setEcho.impl (stdHandle StdErr) true + b = setEcho.impl (stdHandle StdErr) false + match (a, b) with + (Right _, Right _) -> [ Ok "setEcho works" ] + _ -> [ Fail "setEcho failure" ] + testAppend : '{io2.IO} [Result] testAppend _ = test = 'let @@ -352,8 +360,9 @@ testAppend _ = ⍟ These new definitions are ok to `add`: - testAppend : '{IO} [Result] - testSeek : '{IO} [Result] + testAppend : '{IO} [Result] + testSeek : '{IO} [Result] + testSetEcho : '{IO} [Result] ``` ``` ucm @@ -361,8 +370,9 @@ scratch/main> add ⍟ I've added these definitions: - testAppend : '{IO} [Result] - testSeek : '{IO} [Result] + testAppend : '{IO} [Result] + testSeek : '{IO} [Result] + testSetEcho : '{IO} [Result] scratch/main> io.test testSeek @@ -380,6 +390,16 @@ scratch/main> io.test testSeek Tip: Use view 1 to view the source of a test. +scratch/main> io.test testSetEcho + + New test results: + + 1. testSetEcho ◉ setEcho works + + ✅ 1 test(s) passing + + Tip: Use view 1 to view the source of a test. + scratch/main> io.test testAppend New test results: