From 79facf96de5dc376d397f3f07e48072694212cc1 Mon Sep 17 00:00:00 2001 From: Dan Doel Date: Wed, 9 Oct 2024 17:27:48 -0400 Subject: [PATCH 1/4] Change the value serialization format to be an extension of v4 Instead of serializing code as: CodeTag|SuperGroup|Cacheability use one of the two following: CodeTag|SuperGroup <-- uncacheable CacheCodeTag|SuperGroup <-- cacheable Since this is a strict addition to the format, it's not necessary to bump the version to properly parse newly serialized values. Old installations will fail to recognize certain byte representations, but in a way that they are able to recognize and error on, rather than silently parsing things incorrectly. --- .github/workflows/ci-test-jit.yaml | 2 +- .github/workflows/ci.yaml | 2 +- .../src/Unison/Runtime/ANF/Serialize.hs | 22 ++++++++++++++----- unison-src/builtin-tests/interpreter-tests.sh | 4 ++-- unison-src/builtin-tests/jit-tests.sh | 2 +- .../transcripts-using-base/random-deserial.md | 11 ++-------- .../random-deserial.output.md | 11 ++-------- .../transcripts-using-base/serial-test-00.md | 2 +- .../serial-test-00.output.md | 2 +- .../transcripts-using-base/serial-test-01.md | 2 +- .../serial-test-01.output.md | 2 +- .../transcripts-using-base/serial-test-02.md | 2 +- .../serial-test-02.output.md | 2 +- .../transcripts-using-base/serial-test-03.md | 2 +- .../serial-test-03.output.md | 2 +- .../transcripts-using-base/serial-test-04.md | 2 +- .../serial-test-04.output.md | 2 +- 17 files changed, 35 insertions(+), 39 deletions(-) diff --git a/.github/workflows/ci-test-jit.yaml b/.github/workflows/ci-test-jit.yaml index 0ab3c291d6..1d062a5ca2 100644 --- a/.github/workflows/ci-test-jit.yaml +++ b/.github/workflows/ci-test-jit.yaml @@ -4,7 +4,7 @@ on: workflow_call: env: - runtime_tests_version: "@unison/runtime-tests/releases/0.0.2" + runtime_tests_version: "@unison/runtime-tests/releases/0.0.1" # for best results, this should match the path in ci.yaml too; but GH doesn't make it easy to share them. runtime_tests_codebase: "~/.cache/unisonlanguage/runtime-tests.unison" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 23e9b8aeaa..51059d3778 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -15,7 +15,7 @@ env: ## Some version numbers that are used during CI ormolu_version: 0.7.2.0 jit_version: "@unison/internal/releases/0.0.21" - runtime_tests_version: "@unison/runtime-tests/releases/0.0.2" + runtime_tests_version: "@unison/runtime-tests/releases/0.0.1" ## Some cached directories # a temp path for caching a built `ucm` diff --git a/unison-runtime/src/Unison/Runtime/ANF/Serialize.hs b/unison-runtime/src/Unison/Runtime/ANF/Serialize.hs index ba97dfa080..f404435179 100644 --- a/unison-runtime/src/Unison/Runtime/ANF/Serialize.hs +++ b/unison-runtime/src/Unison/Runtime/ANF/Serialize.hs @@ -88,6 +88,7 @@ data BLTag | CharT | FloatT | ArrT + | CachedCodeT data VaTag = PartialT | DataT | ContT | BLitT @@ -197,6 +198,7 @@ instance Tag BLTag where CharT -> 10 FloatT -> 11 ArrT -> 12 + CachedCodeT -> 13 word2tag = \case 0 -> pure TextT @@ -212,6 +214,7 @@ instance Tag BLTag where 10 -> pure CharT 11 -> pure FloatT 12 -> pure ArrT + 13 -> pure CachedCodeT t -> unknownTag "BLTag" t instance Tag VaTag where @@ -678,7 +681,10 @@ putBLit (TmLink r) = putTag TmLinkT *> putReferent r putBLit (TyLink r) = putTag TyLinkT *> putReference r putBLit (Bytes b) = putTag BytesT *> putBytes b putBLit (Quote v) = putTag QuoteT *> putValue v -putBLit (Code co) = putTag CodeT *> putCode mempty co +putBLit (Code (CodeRep sg ch)) = + putTag tag *> putGroup mempty mempty sg + where + tag | Cacheable <- ch = CachedCodeT | otherwise = CodeT putBLit (BArr a) = putTag BArrT *> putByteArray a putBLit (Pos n) = putTag PosT *> putPositive n putBLit (Neg n) = putTag NegT *> putPositive n @@ -695,15 +701,14 @@ getBLit v = TyLinkT -> TyLink <$> getReference BytesT -> Bytes <$> getBytes QuoteT -> Quote <$> getValue v - CodeT -> Code <$> getCode cv - where - cv | v == 5 = 3 | otherwise = 2 + CodeT -> Code . flip CodeRep Uncacheable <$> getGroup BArrT -> BArr <$> getByteArray PosT -> Pos <$> getPositive NegT -> Neg <$> getPositive CharT -> Char <$> getChar FloatT -> Float <$> getFloat ArrT -> Arr . GHC.IsList.fromList <$> getList (getValue v) + CachedCodeT -> Code . flip CodeRep Cacheable <$> getGroup putRefs :: (MonadPut m) => [Reference] -> m () putRefs rs = putFoldable putReference rs @@ -989,7 +994,7 @@ getVersionedValue = getVersion >>= getValue n | n < 1 -> fail $ "deserializeValue: unknown version: " ++ show n | n < 3 -> fail $ "deserializeValue: unsupported version: " ++ show n - | n <= 5 -> pure n + | n <= 4 -> pure n | otherwise -> fail $ "deserializeValue: unknown version: " ++ show n deserializeValue :: ByteString -> Either String Value @@ -1008,13 +1013,18 @@ serializeValue v = runPutS (putVersion *> putValue v) -- The 4 prefix is used because we were previously including the -- version in the hash, so to maintain the same hashes, we need to -- include the extra bytes that were previously there. +-- +-- Additionally, any major serialization changes should consider +-- retaining this representation as much as possible, even if it +-- becomes a separate format, because there is no need to parse from +-- the hash serialization, just generate and hash it. serializeValueForHash :: Value -> L.ByteString serializeValueForHash v = runPutLazy (putPrefix *> putValue v) where putPrefix = putWord32be 4 valueVersion :: Word32 -valueVersion = 5 +valueVersion = 4 codeVersion :: Word32 codeVersion = 3 diff --git a/unison-src/builtin-tests/interpreter-tests.sh b/unison-src/builtin-tests/interpreter-tests.sh index 94c0aeea4b..0da849df3b 100755 --- a/unison-src/builtin-tests/interpreter-tests.sh +++ b/unison-src/builtin-tests/interpreter-tests.sh @@ -1,10 +1,10 @@ #!/bin/bash set -ex -ucm=$(stack exec -- which unison) +ucm=$(cabal exec -- which unison) echo "$ucm" -runtime_tests_version="@unison/runtime-tests/releases/0.0.2" +runtime_tests_version="@unison/runtime-tests/releases/0.0.1" echo $runtime_tests_version codebase=${XDG_CACHE_HOME:-"$HOME/.cache"}/unisonlanguage/runtime-tests.unison diff --git a/unison-src/builtin-tests/jit-tests.sh b/unison-src/builtin-tests/jit-tests.sh index bd3464b4ab..1cba258c06 100755 --- a/unison-src/builtin-tests/jit-tests.sh +++ b/unison-src/builtin-tests/jit-tests.sh @@ -8,7 +8,7 @@ if [ -z "$1" ]; then exit 1 fi -runtime_tests_version="@unison/runtime-tests/releases/0.0.2" +runtime_tests_version="@unison/runtime-tests/releases/0.0.1" echo $runtime_tests_version codebase=${XDG_CACHE_HOME:-"$HOME/.cache"}/unisonlanguage/runtime-tests.unison diff --git a/unison-src/transcripts-using-base/random-deserial.md b/unison-src/transcripts-using-base/random-deserial.md index 5ceb2900d4..ec860c717e 100644 --- a/unison-src/transcripts-using-base/random-deserial.md +++ b/unison-src/transcripts-using-base/random-deserial.md @@ -25,21 +25,16 @@ shuffle = runTestCase : Text ->{Exception,IO} (Text, Test.Result) runTestCase name = - sfile = directory ++ name ++ ".v5.ser" + sfile = directory ++ name ++ ".v4.ser" ls3file = directory ++ name ++ ".v3.ser" - ls4file = directory ++ name ++ ".v4.ser" ofile = directory ++ name ++ ".out" - hfile = directory ++ name ++ ".v5.hash" + hfile = directory ++ name ++ ".v4.hash" p@(f, i) = loadSelfContained sfile pl3@(fl3, il3) = if fileExists ls3file then loadSelfContained ls3file else p - pl4@(fl4, il4) = - if fileExists ls4file - then loadSelfContained ls4file - else p o = fromUtf8 (readFile ofile) h = readFile hfile @@ -50,8 +45,6 @@ runTestCase name = then Fail (name ++ " hash mismatch") else if not (fl3 il3 == f i) then Fail (name ++ " legacy v3 mismatch") - else if not (fl4 il4 == f i) - then Fail (name ++ " legacy v4 mismatch") else Ok name (name, result) diff --git a/unison-src/transcripts-using-base/random-deserial.output.md b/unison-src/transcripts-using-base/random-deserial.output.md index 316132ed4d..f2552a3e29 100644 --- a/unison-src/transcripts-using-base/random-deserial.output.md +++ b/unison-src/transcripts-using-base/random-deserial.output.md @@ -25,21 +25,16 @@ shuffle = runTestCase : Text ->{Exception,IO} (Text, Test.Result) runTestCase name = - sfile = directory ++ name ++ ".v5.ser" + sfile = directory ++ name ++ ".v4.ser" ls3file = directory ++ name ++ ".v3.ser" - ls4file = directory ++ name ++ ".v4.ser" ofile = directory ++ name ++ ".out" - hfile = directory ++ name ++ ".v5.hash" + hfile = directory ++ name ++ ".v4.hash" p@(f, i) = loadSelfContained sfile pl3@(fl3, il3) = if fileExists ls3file then loadSelfContained ls3file else p - pl4@(fl4, il4) = - if fileExists ls4file - then loadSelfContained ls4file - else p o = fromUtf8 (readFile ofile) h = readFile hfile @@ -50,8 +45,6 @@ runTestCase name = then Fail (name ++ " hash mismatch") else if not (fl3 il3 == f i) then Fail (name ++ " legacy v3 mismatch") - else if not (fl4 il4 == f i) - then Fail (name ++ " legacy v4 mismatch") else Ok name (name, result) diff --git a/unison-src/transcripts-using-base/serial-test-00.md b/unison-src/transcripts-using-base/serial-test-00.md index d1a0b8e282..21860243e3 100644 --- a/unison-src/transcripts-using-base/serial-test-00.md +++ b/unison-src/transcripts-using-base/serial-test-00.md @@ -64,7 +64,7 @@ mkTestCase = do f = evaluate balancedSum catenate tup = (tree0, tree1, tree2, tree3) - saveTestCase "case-00" "v5" f tup + saveTestCase "case-00" "v4" f tup ``` ```ucm diff --git a/unison-src/transcripts-using-base/serial-test-00.output.md b/unison-src/transcripts-using-base/serial-test-00.output.md index 4483682980..ce996f93ba 100644 --- a/unison-src/transcripts-using-base/serial-test-00.output.md +++ b/unison-src/transcripts-using-base/serial-test-00.output.md @@ -64,7 +64,7 @@ mkTestCase = do f = evaluate balancedSum catenate tup = (tree0, tree1, tree2, tree3) - saveTestCase "case-00" "v5" f tup + saveTestCase "case-00" "v4" f tup ``` ``` ucm diff --git a/unison-src/transcripts-using-base/serial-test-01.md b/unison-src/transcripts-using-base/serial-test-01.md index 7d5f1ffa07..bc5f84af0d 100644 --- a/unison-src/transcripts-using-base/serial-test-01.md +++ b/unison-src/transcripts-using-base/serial-test-01.md @@ -12,7 +12,7 @@ combines = cases "(" ++ toText rx ++ ", " ++ toText ry ++ ", \"" ++ rz ++ "\")" mkTestCase = do - saveTestCase "case-01" "v5" combines (l1, l2, l3) + saveTestCase "case-01" "v4" combines (l1, l2, l3) ``` ```ucm diff --git a/unison-src/transcripts-using-base/serial-test-01.output.md b/unison-src/transcripts-using-base/serial-test-01.output.md index f2734eb118..a6654a2547 100644 --- a/unison-src/transcripts-using-base/serial-test-01.output.md +++ b/unison-src/transcripts-using-base/serial-test-01.output.md @@ -12,7 +12,7 @@ combines = cases "(" ++ toText rx ++ ", " ++ toText ry ++ ", \"" ++ rz ++ "\")" mkTestCase = do - saveTestCase "case-01" "v5" combines (l1, l2, l3) + saveTestCase "case-01" "v4" combines (l1, l2, l3) ``` ``` ucm diff --git a/unison-src/transcripts-using-base/serial-test-02.md b/unison-src/transcripts-using-base/serial-test-02.md index 06a6d255f1..15518165a0 100644 --- a/unison-src/transcripts-using-base/serial-test-02.md +++ b/unison-src/transcripts-using-base/serial-test-02.md @@ -25,7 +25,7 @@ products = cases (x, y, z) -> "(" ++ toText px ++ ", " ++ toText py ++ ", \"" ++ toText pz ++ "\")" mkTestCase = do - saveTestCase "case-02" "v5" products (l1, l2, l3) + saveTestCase "case-02" "v4" products (l1, l2, l3) ``` diff --git a/unison-src/transcripts-using-base/serial-test-02.output.md b/unison-src/transcripts-using-base/serial-test-02.output.md index 08339ffd0f..102fea092b 100644 --- a/unison-src/transcripts-using-base/serial-test-02.output.md +++ b/unison-src/transcripts-using-base/serial-test-02.output.md @@ -25,7 +25,7 @@ products = cases (x, y, z) -> "(" ++ toText px ++ ", " ++ toText py ++ ", \"" ++ toText pz ++ "\")" mkTestCase = do - saveTestCase "case-02" "v5" products (l1, l2, l3) + saveTestCase "case-02" "v4" products (l1, l2, l3) ``` diff --git a/unison-src/transcripts-using-base/serial-test-03.md b/unison-src/transcripts-using-base/serial-test-03.md index c7b514de72..2e66f687d9 100644 --- a/unison-src/transcripts-using-base/serial-test-03.md +++ b/unison-src/transcripts-using-base/serial-test-03.md @@ -40,7 +40,7 @@ finish = cases (x, y, z) -> mkTestCase = do trip = (suspSum l1, suspSum l2, suspSum l3) - saveTestCase "case-03" "v5" finish trip + saveTestCase "case-03" "v4" finish trip ``` ```ucm diff --git a/unison-src/transcripts-using-base/serial-test-03.output.md b/unison-src/transcripts-using-base/serial-test-03.output.md index 824cab1a39..a20eafe7f6 100644 --- a/unison-src/transcripts-using-base/serial-test-03.output.md +++ b/unison-src/transcripts-using-base/serial-test-03.output.md @@ -40,7 +40,7 @@ finish = cases (x, y, z) -> mkTestCase = do trip = (suspSum l1, suspSum l2, suspSum l3) - saveTestCase "case-03" "v5" finish trip + saveTestCase "case-03" "v4" finish trip ``` ``` ucm diff --git a/unison-src/transcripts-using-base/serial-test-04.md b/unison-src/transcripts-using-base/serial-test-04.md index 210b42796a..212b59c9e0 100644 --- a/unison-src/transcripts-using-base/serial-test-04.md +++ b/unison-src/transcripts-using-base/serial-test-04.md @@ -10,7 +10,7 @@ mutual1 n = mutual0 n mkTestCase = do - saveTestCase "case-04" "v5" mutual1 5 + saveTestCase "case-04" "v4" mutual1 5 ``` ```ucm diff --git a/unison-src/transcripts-using-base/serial-test-04.output.md b/unison-src/transcripts-using-base/serial-test-04.output.md index bb6a6c5fa0..0c045e097d 100644 --- a/unison-src/transcripts-using-base/serial-test-04.output.md +++ b/unison-src/transcripts-using-base/serial-test-04.output.md @@ -10,7 +10,7 @@ mutual1 n = mutual0 n mkTestCase = do - saveTestCase "case-04" "v5" mutual1 5 + saveTestCase "case-04" "v4" mutual1 5 ``` ``` ucm From fa2af63dea88d9f8dfb7eaf2fb57a7cd5b8c0a3a Mon Sep 17 00:00:00 2001 From: Dan Doel Date: Wed, 9 Oct 2024 17:43:07 -0400 Subject: [PATCH 2/4] Update to new unison internal libraries, with support I'd already been working on caching values in the jit in the internal libraries, so it was convenient to include those changes in the update that also parses the extended v4 format. This requires a bit of additional racket code, but the consequences are disabled until some supporting code is available in the base library. Some definitions will be tagged as `value` indicating that they can be expanded into racket definitions that will only be evaluated once. The code for expanding things that way is included, too. But the feature is turned off, so everything will expand in the old way. --- scheme-libs/racket/unison/boot.ss | 82 ++++++++++++------- .../racket/unison/primops-generated.rkt | 32 ++++++-- .../transcripts-manual/gen-racket-libs.md | 2 +- .../gen-racket-libs.output.md | 8 +- 4 files changed, 84 insertions(+), 40 deletions(-) diff --git a/scheme-libs/racket/unison/boot.ss b/scheme-libs/racket/unison/boot.ss index b046485638..7deb180b0e 100644 --- a/scheme-libs/racket/unison/boot.ss +++ b/scheme-libs/racket/unison/boot.ss @@ -216,12 +216,17 @@ ; This builds the core definition for a unison definition. It is just ; a lambda expression with the original code, but with an additional ; keyword argument for threading purity information. -(define-for-syntax (make-impl name:impl:stx arg:stx body:stx) +(define-for-syntax (make-impl value? name:impl:stx arg:stx body:stx) (with-syntax ([name:impl name:impl:stx] [args arg:stx] [body body:stx]) - (syntax/loc body:stx - (define (name:impl . args) . body)))) + (cond + [value? + (syntax/loc body:stx + (define name:impl . body))] + [else + (syntax/loc body:stx + (define (name:impl . args) . body))]))) (define frame-contents (gensym)) @@ -235,6 +240,7 @@ (define-for-syntax (make-fast-path #:force-pure force-pure? + #:value value? loc ; original location name:fast:stx name:impl:stx arg:stx) @@ -242,34 +248,45 @@ (with-syntax ([name:impl name:impl:stx] [name:fast name:fast:stx] [args arg:stx]) - (if force-pure? - (syntax/loc loc - ; note: for some reason this performs better than - ; (define name:fast name:impl) - (define (name:fast . args) (name:impl . args))) - - (syntax/loc loc - (define (name:fast #:pure pure? . args) - (if pure? - (name:impl #:pure pure? . args) - (with-continuation-mark - frame-contents - (vector . args) - (name:impl #:pure pure? . args)))))))) + (cond + [value? + (syntax/loc loc + (define (name:fast) name:impl))] + + [force-pure? + (syntax/loc loc + ; note: for some reason this performs better than + ; (define name:fast name:impl) + (define (name:fast . args) (name:impl . args)))] + + [else + (syntax/loc loc + (define (name:fast #:pure pure? . args) + (if pure? + (name:impl #:pure pure? . args) + (with-continuation-mark + frame-contents + (vector . args) + (name:impl #:pure pure? . args)))))]))) (define-for-syntax - (make-main loc inline? name:stx ref:stx name:impl:stx n) + (make-main loc value? inline? name:stx ref:stx name:impl:stx n) (with-syntax ([name name:stx] [name:impl name:impl:stx] [gr ref:stx] [n (datum->syntax loc n)]) - (if inline? - (syntax/loc loc - (define name - (unison-curry #:inline n gr name:impl))) - (syntax/loc loc - (define name - (unison-curry n gr name:impl)))))) + (cond + [value? + (syntax/loc loc + (define (name) name:impl))] + [inline? + (syntax/loc loc + (define name + (unison-curry #:inline n gr name:impl)))] + [else + (syntax/loc loc + (define name + (unison-curry n gr name:impl)))]))) (define-for-syntax (link-decl no-link-decl? loc name:stx name:fast:stx name:impl:stx) @@ -299,7 +316,8 @@ [no-link-decl? #f] [trace? #f] [inline? #f] - [recursive? #f]) + [recursive? #f] + [value? #f]) ([h hs]) (values (or internal? (eq? h 'internal)) @@ -308,7 +326,9 @@ (or no-link-decl? (eq? h 'no-link-decl)) (or trace? (eq? h 'trace)) (or inline? (eq? h 'inline)) - (or recursive? (eq? h 'recursive))))) + (or recursive? (eq? h 'recursive)) + ; TODO: enable values + value?))) (define-for-syntax (make-link-def gen-link? loc name:stx name:link:stx) @@ -343,7 +363,8 @@ no-link-decl? trace? inline? - recursive?) + recursive? + value?) (process-hints hints)) @@ -356,9 +377,10 @@ ([(link ...) (make-link-def gen-link? loc name:stx name:link:stx)] [fast (make-fast-path #:force-pure #t ; force-pure? + #:value value? loc name:fast:stx name:impl:stx arg:stx)] - [impl (make-impl name:impl:stx arg:stx expr:stx)] - [main (make-main loc inline? name:stx ref:stx name:impl:stx arity)] + [impl (make-impl value? name:impl:stx arg:stx expr:stx)] + [main (make-main loc value? inline? name:stx ref:stx name:impl:stx arity)] ; [(decls ...) ; (link-decl no-link-decl? loc name:stx name:fast:stx name:impl:stx)] [(traces ...) diff --git a/scheme-libs/racket/unison/primops-generated.rkt b/scheme-libs/racket/unison/primops-generated.rkt index 89ba99a988..e73e8de8db 100644 --- a/scheme-libs/racket/unison/primops-generated.rkt +++ b/scheme-libs/racket/unison/primops-generated.rkt @@ -176,6 +176,13 @@ (if (null? hints) (list def '#:local ln head body) (list def '#:local ln '#:hints hints head body)))] + [(unison-data _ t (list nm hs bd)) + #:when (= t ref-schemedefn-defineval:tag) + (let-values + ([(head) (text->ident nm)] + [(def hints) (decode-hints (chunked-list->list hs))] + [(body) (decode-term bd)]) + (list def '#:hints (cons 'value hints) (list head) body))] [(unison-data _ t (list nm bd)) #:when (= t ref-schemedefn-alias:tag) (list 'define (text->ident nm) (decode-term bd))] @@ -684,16 +691,31 @@ "unison-termlink-derived?" tl)])) +; Converts a link->code map into an appropriately sorted list +; for code generation. It's necessary to topologically sort +; the code so that values occur after the things they reference. +(define (codemap->link-order defs) + (define input + (for/list ([(tl co) defs]) + (unison-tuple + (termlink->reference tl) + (unison-code-rep co)))) + + (define result (topsort-code-refs (list->chunked-list input))) + + (for/list ([r (in-chunked-list result)]) + (reference->termlink r))) + ; Given a list of termlink, code pairs, returns multiple lists ; of definitions and declarations. The lists are returned as ; multiple results, each one containing a particular type of ; definition. ; -; This is the version for compiling to intermediate code. +; This is the version for compiling to runtime code. (define (gen-codes:runtime arities defs) (for/lists (lndefs lndecs dfns) - ([(tl co) defs]) - (gen-code:runtime arities tl co))) + ([tl (codemap->link-order defs)]) + (gen-code:runtime arities tl (hash-ref defs tl)))) ; Given a list of termlink, code pairs, returns multiple lists ; of definitions and declarations. The lists are returned as @@ -703,8 +725,8 @@ ; This is the version for compiling to intermediate code. (define (gen-codes:intermed arities defs) (for/lists (lndefs lndecs codefs codecls dfns) - ([(tl co) defs]) - (gen-code:intermed arities tl co))) + ([tl (codemap->link-order defs)]) + (gen-code:intermed arities tl (hash-ref defs tl)))) (define (flatten ls) (cond diff --git a/unison-src/transcripts-manual/gen-racket-libs.md b/unison-src/transcripts-manual/gen-racket-libs.md index b3137a636d..ee35427f7e 100644 --- a/unison-src/transcripts-manual/gen-racket-libs.md +++ b/unison-src/transcripts-manual/gen-racket-libs.md @@ -4,7 +4,7 @@ When we start out, `./scheme-libs/racket` contains a bunch of library files that Next, we'll download the jit project and generate a few Racket files from it. ```ucm -jit-setup/main> lib.install @unison/internal/releases/0.0.21 +jit-setup/main> lib.install @unison/internal/releases/0.0.22 ``` ```unison diff --git a/unison-src/transcripts-manual/gen-racket-libs.output.md b/unison-src/transcripts-manual/gen-racket-libs.output.md index 9586cc8d72..9852441fa7 100644 --- a/unison-src/transcripts-manual/gen-racket-libs.output.md +++ b/unison-src/transcripts-manual/gen-racket-libs.output.md @@ -3,12 +3,12 @@ When we start out, `./scheme-libs/racket` contains a bunch of library files that Next, we'll download the jit project and generate a few Racket files from it. ``` ucm -jit-setup/main> lib.install @unison/internal/releases/0.0.21 +jit-setup/main> lib.install @unison/internal/releases/0.0.22 - Downloaded 14985 entities. + Downloaded 14996 entities. - I installed @unison/internal/releases/0.0.21 as - unison_internal_0_0_21. + I installed @unison/internal/releases/0.0.22 as + unison_internal_0_0_22. ``` ``` unison From 183e02b7a37403a163dd083ae7b9cb1e69187e41 Mon Sep 17 00:00:00 2001 From: dolio Date: Wed, 9 Oct 2024 22:00:35 +0000 Subject: [PATCH 3/4] automatically run ormolu --- .../src/Unison/Runtime/ANF/Serialize.hs | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/unison-runtime/src/Unison/Runtime/ANF/Serialize.hs b/unison-runtime/src/Unison/Runtime/ANF/Serialize.hs index f404435179..7c60691300 100644 --- a/unison-runtime/src/Unison/Runtime/ANF/Serialize.hs +++ b/unison-runtime/src/Unison/Runtime/ANF/Serialize.hs @@ -333,24 +333,26 @@ getGroup = do cs <- replicateM l (getComb ctx n) Rec (zip vs cs) <$> getComb ctx n -putCode :: MonadPut m => EC.EnumMap FOp Text -> Code -> m () +putCode :: (MonadPut m) => EC.EnumMap FOp Text -> Code -> m () putCode fops (CodeRep g c) = putGroup mempty fops g *> putCacheability c -getCode :: MonadGet m => Word32 -> m Code +getCode :: (MonadGet m) => Word32 -> m Code getCode v = CodeRep <$> getGroup <*> getCache where - getCache | v == 3 = getCacheability - | otherwise = pure Uncacheable + getCache + | v == 3 = getCacheability + | otherwise = pure Uncacheable -putCacheability :: MonadPut m => Cacheability -> m () +putCacheability :: (MonadPut m) => Cacheability -> m () putCacheability Uncacheable = putWord8 0 putCacheability Cacheable = putWord8 1 -getCacheability :: MonadGet m => m Cacheability -getCacheability = getWord8 >>= \case - 0 -> pure Uncacheable - 1 -> pure Cacheable - n -> exn $ "getBLit: unrecognized cacheability byte: " ++ show n +getCacheability :: (MonadGet m) => m Cacheability +getCacheability = + getWord8 >>= \case + 0 -> pure Uncacheable + 1 -> pure Cacheable + n -> exn $ "getBLit: unrecognized cacheability byte: " ++ show n putComb :: (MonadPut m) => @@ -684,7 +686,7 @@ putBLit (Quote v) = putTag QuoteT *> putValue v putBLit (Code (CodeRep sg ch)) = putTag tag *> putGroup mempty mempty sg where - tag | Cacheable <- ch = CachedCodeT | otherwise = CodeT + tag | Cacheable <- ch = CachedCodeT | otherwise = CodeT putBLit (BArr a) = putTag BArrT *> putByteArray a putBLit (Pos n) = putTag PosT *> putPositive n putBLit (Neg n) = putTag NegT *> putPositive n From b7d2731bc68ae73d70ea6087263446bfcaab73cc Mon Sep 17 00:00:00 2001 From: Dan Doel Date: Wed, 9 Oct 2024 18:14:19 -0400 Subject: [PATCH 4/4] Bump @unison/internal version in ci.yaml --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 51059d3778..938cf7db75 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -14,7 +14,7 @@ on: env: ## Some version numbers that are used during CI ormolu_version: 0.7.2.0 - jit_version: "@unison/internal/releases/0.0.21" + jit_version: "@unison/internal/releases/0.0.22" runtime_tests_version: "@unison/runtime-tests/releases/0.0.1" ## Some cached directories