From d981d363e0c03a05ca2d91ff53d71fe81cbaffea Mon Sep 17 00:00:00 2001 From: OceanOak Date: Mon, 15 Jun 2026 20:00:49 +0000 Subject: [PATCH 01/61] Migrate Dict.size from Int64 to Int --- backend/src/Builtins/Builtins.Pure/Libs/Dict.fs | 4 ++-- backend/testfiles/execution/stdlib/dict.dark | 4 ++-- .../darklang/modelContextProtocol/serverBuilder/main.dark | 6 +++--- packages/darklang/stdlib/dict.dark | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/backend/src/Builtins/Builtins.Pure/Libs/Dict.fs b/backend/src/Builtins/Builtins.Pure/Libs/Dict.fs index 9d2833c73e..87b3ff9b66 100644 --- a/backend/src/Builtins/Builtins.Pure/Libs/Dict.fs +++ b/backend/src/Builtins/Builtins.Pure/Libs/Dict.fs @@ -18,11 +18,11 @@ let fns () : List = [ { name = fn "dictSize" 0 typeParams = [] parameters = [ Param.make "dict" (TDict varA) "" ] - returnType = TInt64 + returnType = TInt description = "Returns the number of entries in " fn = (function - | _, _, _, [ DDict(_vtTODO, o) ] -> Ply(DInt64(int64 (Map.count o))) + | _, _, _, [ DDict(_vtTODO, o) ] -> Ply(Dval.int (bigint (Map.count o))) | _ -> incorrectArgs ()) sqlSpec = NotYetImplemented previewable = Pure diff --git a/backend/testfiles/execution/stdlib/dict.dark b/backend/testfiles/execution/stdlib/dict.dark index 97d5445cb5..da1679bbb7 100644 --- a/backend/testfiles/execution/stdlib/dict.dark +++ b/backend/testfiles/execution/stdlib/dict.dark @@ -153,8 +153,8 @@ module Singleton = module Size = - Stdlib.Dict.size_v0 (Dict { a = 3L; b = 1L; c = 1L }) = 3L - Stdlib.Dict.size_v0 (Dict { }) = 0L + Stdlib.Dict.size_v0 (Dict { a = 3L; b = 1L; c = 1L }) = 3I + Stdlib.Dict.size_v0 (Dict { }) = 0I module ToList = diff --git a/packages/darklang/modelContextProtocol/serverBuilder/main.dark b/packages/darklang/modelContextProtocol/serverBuilder/main.dark index 21fa4d5abb..a239bc6fcc 100644 --- a/packages/darklang/modelContextProtocol/serverBuilder/main.dark +++ b/packages/darklang/modelContextProtocol/serverBuilder/main.dark @@ -222,9 +222,9 @@ let run (server: McpServerBuilder) : Int64 = |> Stdlib.DateTime.toString |> fun nowStr -> logWithPath logFilePath $"Running {server.name} MCP Server {nowStr}" - let toolCount = (Stdlib.Dict.size server.tools) |> Stdlib.Int64.toString - let resourceCount = (Stdlib.Dict.size server.resources) |> Stdlib.Int64.toString - let promptCount = (Stdlib.Dict.size server.prompts) |> Stdlib.Int64.toString + let toolCount = (Stdlib.Dict.size server.tools) |> Stdlib.Int.toString + let resourceCount = (Stdlib.Dict.size server.resources) |> Stdlib.Int.toString + let promptCount = (Stdlib.Dict.size server.prompts) |> Stdlib.Int.toString logWithPath logFilePath $"Server '{server.name}' features:" logWithPath logFilePath $" - Tools: {toolCount} registered" diff --git a/packages/darklang/stdlib/dict.dark b/packages/darklang/stdlib/dict.dark index 5eefc3069b..2a1ee445fa 100644 --- a/packages/darklang/stdlib/dict.dark +++ b/packages/darklang/stdlib/dict.dark @@ -13,7 +13,7 @@ let singleton (key: String) (value: 'a) : Dict<'a> = Stdlib.Dict.set (Dict { }) key value /// Returns the number of entries in -let size (dict: Dict<'a>) : Int64 = +let size (dict: Dict<'a>) : Int = Builtin.dictSize_v0 dict From ad1b85d8f7f340d9f0c9da953e5bc995f6b98faa Mon Sep 17 00:00:00 2001 From: OceanOak Date: Mon, 15 Jun 2026 20:03:38 +0000 Subject: [PATCH 02/61] Migrate DB.count and DB.queryCount from Int64 to Int --- backend/src/Builtins/Builtins.Matter/Libs/DB.fs | 6 +++--- backend/src/LibDB/UserDB.fs | 2 +- backend/testfiles/execution/cloud/db.dark | 10 +++++----- packages/darklang/stdlib/db.dark | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/backend/src/Builtins/Builtins.Matter/Libs/DB.fs b/backend/src/Builtins/Builtins.Matter/Libs/DB.fs index 2082aa1c4c..a67dfd954c 100644 --- a/backend/src/Builtins/Builtins.Matter/Libs/DB.fs +++ b/backend/src/Builtins/Builtins.Matter/Libs/DB.fs @@ -507,7 +507,7 @@ let fns () : List = { name = fn "dbCount" 0 typeParams = [] parameters = [ tableParam "a" ] - returnType = TInt64 + returnType = TInt description = "Return the number of items stored in " fn = (function @@ -517,7 +517,7 @@ let fns () : List = LibExecution.CapabilityCheck.requireDbRead exeState.grantedCaps dbname let db = exeState.program.dbs[dbname] let! (count : int) = UserDB.count exeState db - return count |> int64 |> DInt64 + return Dval.int (bigint count) } | _ -> incorrectArgs ()) sqlSpec = NotQueryable @@ -659,7 +659,7 @@ let fns () : List = { name = fn "dbQueryCount" 0 typeParams = [] parameters = [ tableParam "a"; queryFilterParam "a" ] - returnType = TInt64 + returnType = TInt description = "Return the number of items from for which filter returns true." fn = diff --git a/backend/src/LibDB/UserDB.fs b/backend/src/LibDB/UserDB.fs index 72498bba73..ae3e76ddac 100644 --- a/backend/src/LibDB/UserDB.fs +++ b/backend/src/LibDB/UserDB.fs @@ -570,5 +570,5 @@ let executeCompiledQuery |> Sql.parameters allParams |> Sql.executeRowAsync (fun read -> read.int "count") - return RT.DInt64(int64 count) + return RT.Dval.int (bigint count) } diff --git a/backend/testfiles/execution/cloud/db.dark b/backend/testfiles/execution/cloud/db.dark index 945349ac20..ad9a1edbb7 100644 --- a/backend/testfiles/execution/cloud/db.dark +++ b/backend/testfiles/execution/cloud/db.dark @@ -557,17 +557,17 @@ module DeleteAll = module Count = // empty - Stdlib.DB.count XDB = 0L + Stdlib.DB.count XDB = 0I // one entries - (let _ = Stdlib.DB.set (X { x = "hello" }) "one" XDB in Stdlib.DB.count XDB) = 1L + (let _ = Stdlib.DB.set (X { x = "hello" }) "one" XDB in Stdlib.DB.count XDB) = 1I // multiple entries (let _ = Stdlib.DB.set (X { x = "hello" }) "one" XDB let _ = Stdlib.DB.set (X { x = "goodbye" }) "two" XDB let _ = Stdlib.DB.set (X { x = "howdy" }) "three" XDB let _ = Stdlib.DB.set (X { x = "cheers" }) "four" XDB - Stdlib.DB.count XDB) = 4L + Stdlib.DB.count XDB) = 4I // ------------ // SqlCompiler queries @@ -1018,11 +1018,11 @@ module QueryWithKey = module QueryCount = // none (let _ = prepFriends () - Stdlib.DB.queryCount PersonDB (fun p -> p.name == "bob")) = 0L + Stdlib.DB.queryCount PersonDB (fun p -> p.name == "bob")) = 0I // one (let _ = prepFriends () - Stdlib.DB.queryCount PersonDB (fun p -> p.height > 3L)) = 4L + Stdlib.DB.queryCount PersonDB (fun p -> p.height > 3L)) = 4I ((Stdlib.DB.generateKey ()) |> Stdlib.String.length) = 36L diff --git a/packages/darklang/stdlib/db.dark b/packages/darklang/stdlib/db.dark index 0bc5b74efa..9af2b15915 100644 --- a/packages/darklang/stdlib/db.dark +++ b/packages/darklang/stdlib/db.dark @@ -49,7 +49,7 @@ let getAllWithKeys (table: 'a) : Dict<'a> = Builtin.dbGetAllWithKeys table /// Return the number of items stored in -let count (table: 'a) : Int64 = Builtin.dbCount table +let count (table: 'a) : Int = Builtin.dbCount table /// Returns a random key suitable for use as a DB key @@ -94,5 +94,5 @@ let queryOneWithKey /// Return the number of items from for which filter returns true. Note that this does not check every value in , but rather is optimized to find data with indexes. /// Errors at compile-time if Dark's compiler does not support the code in question. -let queryCount (table: 'a) (filter: ('a -> Bool)) : Int64 = +let queryCount (table: 'a) (filter: ('a -> Bool)) : Int = Builtin.dbQueryCount table filter \ No newline at end of file From 7e613ce95821ed3eb2319714731b3b2cc6c2b564 Mon Sep 17 00:00:00 2001 From: OceanOak Date: Mon, 15 Jun 2026 20:06:11 +0000 Subject: [PATCH 03/61] Migrate Blob.length and Blob.slice from Int64 to Int --- .../src/Builtins/Builtins.Pure/Libs/Blob.fs | 19 ++++++++++--------- backend/testfiles/execution/language/big.dark | 2 +- backend/testfiles/execution/stdlib/bytes.dark | 14 +++++++------- .../http-server/bad-response-just-int.test | 2 +- .../injected-icon-post-length.test | 2 +- .../http-server/response-with-500.test | 2 +- .../simple-injected-string-post.test | 2 +- .../simple-inline-string-post.test | 2 +- packages/darklang/stdlib/blob.dark | 4 ++-- packages/darklang/stdlib/cli/posix.dark | 2 +- 10 files changed, 26 insertions(+), 25 deletions(-) diff --git a/backend/src/Builtins/Builtins.Pure/Libs/Blob.fs b/backend/src/Builtins/Builtins.Pure/Libs/Blob.fs index cb315ebcfc..a869cf8520 100644 --- a/backend/src/Builtins/Builtins.Pure/Libs/Blob.fs +++ b/backend/src/Builtins/Builtins.Pure/Libs/Blob.fs @@ -17,14 +17,14 @@ let fns () : List = { name = fn "blobLength" 0 typeParams = [] parameters = [ Param.make "blob" TBlob "" ] - returnType = TInt64 + returnType = TInt description = "Returns the length of in bytes." fn = (function | state, _, _, [ DBlob ref ] -> uply { let! bs = Blob.readBytes state ref - return DInt64(int64 bs.Length) + return Dval.int (bigint bs.Length) } | _ -> incorrectArgs ()) sqlSpec = NotYetImplemented @@ -209,21 +209,22 @@ let fns () : List = typeParams = [] parameters = [ Param.make "blob" TBlob "" - Param.make "start" TInt64 "zero-based, inclusive" - Param.make "length" TInt64 "0 or more" ] + Param.make "start" TInt "zero-based, inclusive" + Param.make "length" TInt "0 or more" ] returnType = TBlob description = "Copies bytes starting at into a fresh ephemeral Blob. Out-of-range slices are clamped." fn = (function - | state, _, _, [ DBlob ref; DInt64 startL; DInt64 lenL ] -> + | state, _, _, [ DBlob ref; DInt startD; DInt lenD ] -> uply { let! bs = Blob.readBytes state ref - let len64 = int64 bs.Length - let safeStart = max 0L (min startL len64) - let safeLen = max 0L (min lenL (len64 - safeStart)) + let len = bigint bs.Length + let safeStart = max (bigint 0) (min (DarkInt.toBigInt startD) len) + let safeLen = + max (bigint 0) (min (DarkInt.toBigInt lenD) (len - safeStart)) let slice = Array.zeroCreate (int safeLen) - if safeLen > 0L then + if safeLen > bigint 0 then System.Array.Copy(bs, int safeStart, slice, 0, int safeLen) return Blob.newEphemeral slice } diff --git a/backend/testfiles/execution/language/big.dark b/backend/testfiles/execution/language/big.dark index a102414b0f..632b44c4ff 100644 --- a/backend/testfiles/execution/language/big.dark +++ b/backend/testfiles/execution/language/big.dark @@ -31,7 +31,7 @@ module BigTestCase = |> (++) "\nstring length: " |> (++) (Stdlib.Int64.toString_v0 sl) |> (++) "\nbytes length: " - |> (++) (Stdlib.Int64.toString_v0 bl) + |> (++) (Stdlib.Int.toString bl) |> (++) "\nbool: " |> (++) (Stdlib.Bool.toString_v0 r) |> (++) "\nfloat: " diff --git a/backend/testfiles/execution/stdlib/bytes.dark b/backend/testfiles/execution/stdlib/bytes.dark index fa5bdd9b10..0dbe4084a9 100644 --- a/backend/testfiles/execution/stdlib/bytes.dark +++ b/backend/testfiles/execution/stdlib/bytes.dark @@ -12,9 +12,9 @@ // length -((Stdlib.Blob.fromString "hi") |> Stdlib.Blob.length) = 2L -((Stdlib.Blob.fromString "") |> Stdlib.Blob.length) = 0L -(Stdlib.Blob.empty |> Stdlib.Blob.length) = 0L +((Stdlib.Blob.fromString "hi") |> Stdlib.Blob.length) = 2I +((Stdlib.Blob.fromString "") |> Stdlib.Blob.length) = 0I +(Stdlib.Blob.empty |> Stdlib.Blob.length) = 0I // fromString / toString roundtrip (match (Stdlib.Blob.fromString "hello") |> Stdlib.Blob.toString with @@ -25,8 +25,8 @@ // fromHex returns Result; length of decoded deadbeef = 4 bytes (match Stdlib.Blob.fromHex "deadbeef" with | Ok b -> Stdlib.Blob.length b - | Error _ -> -1L) - = 4L + | Error _ -> -1I) + = 4I // hex roundtrip via wrapper (match Stdlib.Blob.fromHex "48656c6c6f" with @@ -63,7 +63,7 @@ = "foo-bar" // slice (middle three bytes of "abcdef" = "cde") -(match (Stdlib.Blob.slice (Stdlib.Blob.fromString "abcdef") 2L 3L) +(match (Stdlib.Blob.slice (Stdlib.Blob.fromString "abcdef") 2I 3I) |> Stdlib.Blob.toString with | Ok s -> s | Error _ -> "err") @@ -71,7 +71,7 @@ // toList/fromList escape hatches ((Stdlib.Blob.fromString "abc") |> Stdlib.Blob.toList) = [ 97uy; 98uy; 99uy ] -((Stdlib.Blob.fromList [ 97uy; 98uy; 99uy ]) |> Stdlib.Blob.length) = 3L +((Stdlib.Blob.fromList [ 97uy; 98uy; 99uy ]) |> Stdlib.Blob.length) = 3I // Blob equality is identity-based: same hash (Persistent) or same // UUID (Ephemeral). Two freshly-built ephemerals with the same bytes diff --git a/backend/testfiles/http-server/bad-response-just-int.test b/backend/testfiles/http-server/bad-response-just-int.test index 08560c5d12..491df0cc44 100644 --- a/backend/testfiles/http-server/bad-response-just-int.test +++ b/backend/testfiles/http-server/bad-response-just-int.test @@ -18,7 +18,7 @@ Strict-Transport-Security: max-age=31536000; includeSubDomains; preload Content-Length: LENGTH Application error: expected a HTTP response, got: -type Int64: +type Int: 13 HTTP handlers should return results in the form: diff --git a/backend/testfiles/http-server/injected-icon-post-length.test b/backend/testfiles/http-server/injected-icon-post-length.test index cc6feeefdc..d98e6584e5 100644 --- a/backend/testfiles/http-server/injected-icon-post-length.test +++ b/backend/testfiles/http-server/injected-icon-post-length.test @@ -1,5 +1,5 @@ [http-handler POST /] -(let body = (request.body |> Darklang.Stdlib.Blob.length |> Darklang.Stdlib.Int64.toString |> Darklang.Stdlib.String.toBlob) +(let body = (request.body |> Darklang.Stdlib.Blob.length |> Darklang.Stdlib.Int.toString |> Darklang.Stdlib.String.toBlob) Darklang.Stdlib.Http.response body 200L) [request] diff --git a/backend/testfiles/http-server/response-with-500.test b/backend/testfiles/http-server/response-with-500.test index a0e158a5a9..852a00d9d1 100644 --- a/backend/testfiles/http-server/response-with-500.test +++ b/backend/testfiles/http-server/response-with-500.test @@ -1,5 +1,5 @@ [http-handler POST /] -(let body = (request.body |> Darklang.Stdlib.Blob.length |> Darklang.Stdlib.Int64.toString |> Darklang.Stdlib.String.toBlob) +(let body = (request.body |> Darklang.Stdlib.Blob.length |> Darklang.Stdlib.Int.toString |> Darklang.Stdlib.String.toBlob) Darklang.Stdlib.Http.response body 500L) [request] diff --git a/backend/testfiles/http-server/simple-injected-string-post.test b/backend/testfiles/http-server/simple-injected-string-post.test index d5f898df23..6960ab67f4 100644 --- a/backend/testfiles/http-server/simple-injected-string-post.test +++ b/backend/testfiles/http-server/simple-injected-string-post.test @@ -1,5 +1,5 @@ [http-handler POST /] -(let body = (request.body |> Darklang.Stdlib.Blob.length |> Darklang.Stdlib.Int64.toString |> Darklang.Stdlib.String.toBlob) +(let body = (request.body |> Darklang.Stdlib.Blob.length |> Darklang.Stdlib.Int.toString |> Darklang.Stdlib.String.toBlob) Darklang.Stdlib.Http.response body 200L) [request] diff --git a/backend/testfiles/http-server/simple-inline-string-post.test b/backend/testfiles/http-server/simple-inline-string-post.test index 98fa0990bd..cd73ce0239 100644 --- a/backend/testfiles/http-server/simple-inline-string-post.test +++ b/backend/testfiles/http-server/simple-inline-string-post.test @@ -1,5 +1,5 @@ [http-handler POST /] -(let body = (request.body |> Darklang.Stdlib.Blob.length |> Darklang.Stdlib.Int64.toString |> Darklang.Stdlib.String.toBlob) +(let body = (request.body |> Darklang.Stdlib.Blob.length |> Darklang.Stdlib.Int.toString |> Darklang.Stdlib.String.toBlob) Darklang.Stdlib.Http.response body 200L) [request] diff --git a/packages/darklang/stdlib/blob.dark b/packages/darklang/stdlib/blob.dark index 6a0d29d294..c0fc04401a 100644 --- a/packages/darklang/stdlib/blob.dark +++ b/packages/darklang/stdlib/blob.dark @@ -12,7 +12,7 @@ let empty = Builtin.blobEmpty /// Returns the length of in bytes. -let length (blob: Blob) : Int64 = Builtin.blobLength blob +let length (blob: Blob) : Int = Builtin.blobLength blob /// Concatenates a list of Blobs into a single Blob. @@ -21,7 +21,7 @@ let concat (blobs: List) : Blob = Builtin.blobConcat blobs /// Copies bytes starting at into a new /// Blob. Out-of-range slices are clamped. -let slice (blob: Blob) (start: Int64) (length: Int64) : Blob = +let slice (blob: Blob) (start: Int) (length: Int) : Blob = Builtin.blobSlice blob start length diff --git a/packages/darklang/stdlib/cli/posix.dark b/packages/darklang/stdlib/cli/posix.dark index 7525e9bbf0..f2709b92a3 100644 --- a/packages/darklang/stdlib/cli/posix.dark +++ b/packages/darklang/stdlib/cli/posix.dark @@ -45,7 +45,7 @@ let fdReadAll : Result.Result = (Builtin.posixFdRead fd 4096L) |> Stdlib.Result.andThen (fun chunk -> - if Stdlib.Blob.length chunk == 0L then + if Stdlib.Blob.length chunk == 0I then Stdlib.Result.Result.Ok(Stdlib.Blob.concat acc) else fdReadAll fd (Stdlib.List.append acc [ chunk ])) From bfcee226e17bb62bb5fe6fd7846193aedca02067 Mon Sep 17 00:00:00 2001 From: OceanOak Date: Tue, 16 Jun 2026 11:04:20 +0000 Subject: [PATCH 04/61] Migrate Float rounding fns (and JsonRPC RequestID.Int) from Int64 to Int --- .../src/Builtins/Builtins.Pure/Libs/Float.fs | 28 +++--- backend/testfiles/execution/stdlib/float.dark | 86 +++++++++---------- backend/testfiles/execution/stdlib/tuple.dark | 4 +- .../darklang/cli/ui/components/forms.dark | 2 + packages/darklang/json-rpc.dark | 4 +- .../lsp-server/handleIncomingMessage.dark | 2 +- packages/darklang/stdlib/alt-json.dark | 4 +- packages/darklang/stdlib/float.dark | 14 +-- packages/darklang/stdlib/uint64.dark | 2 +- 9 files changed, 74 insertions(+), 72 deletions(-) diff --git a/backend/src/Builtins/Builtins.Pure/Libs/Float.fs b/backend/src/Builtins/Builtins.Pure/Libs/Float.fs index 143d271dd0..46630e6edf 100644 --- a/backend/src/Builtins/Builtins.Pure/Libs/Float.fs +++ b/backend/src/Builtins/Builtins.Pure/Libs/Float.fs @@ -25,11 +25,11 @@ let fns () : List = [ { name = fn "floatCeiling" 0 typeParams = [] parameters = [ Param.make "a" TFloat "" ] - returnType = TInt64 + returnType = TInt description = "Round up to an integer value" fn = (function - | _, _, _, [ DFloat a ] -> a |> System.Math.Ceiling |> int64 |> DInt64 |> Ply + | _, _, _, [ DFloat a ] -> a |> System.Math.Ceiling |> bigint |> Dval.int |> Ply | _ -> incorrectArgs ()) sqlSpec = NotYetImplemented previewable = Pure @@ -40,11 +40,11 @@ let fns () : List = { name = fn "floatRoundUp" 0 typeParams = [] parameters = [ Param.make "a" TFloat "" ] - returnType = TInt64 + returnType = TInt description = "Round up to an integer value" fn = (function - | _, _, _, [ DFloat a ] -> a |> System.Math.Ceiling |> int64 |> DInt64 |> Ply + | _, _, _, [ DFloat a ] -> a |> System.Math.Ceiling |> bigint |> Dval.int |> Ply | _ -> incorrectArgs ()) sqlSpec = NotYetImplemented previewable = Pure @@ -55,7 +55,7 @@ let fns () : List = { name = fn "floatFloor" 0 typeParams = [] parameters = [ Param.make "a" TFloat "" ] - returnType = TInt64 + returnType = TInt description = "Round down to an integer value. @@ -64,7 +64,7 @@ let fns () : List = but {{Float.truncate -1.9 == -1.0}}" fn = (function - | _, _, _, [ DFloat a ] -> a |> System.Math.Floor |> int64 |> DInt64 |> Ply + | _, _, _, [ DFloat a ] -> a |> System.Math.Floor |> bigint |> Dval.int |> Ply | _ -> incorrectArgs ()) sqlSpec = NotYetImplemented previewable = Pure @@ -75,7 +75,7 @@ let fns () : List = { name = fn "floatRoundDown" 0 typeParams = [] parameters = [ Param.make "a" TFloat "" ] - returnType = TInt64 + returnType = TInt description = "Round down to an integer value. @@ -85,7 +85,7 @@ let fns () : List = fn = (function - | _, _, _, [ DFloat a ] -> a |> System.Math.Floor |> int64 |> DInt64 |> Ply + | _, _, _, [ DFloat a ] -> a |> System.Math.Floor |> bigint |> Dval.int |> Ply | _ -> incorrectArgs ()) sqlSpec = NotYetImplemented previewable = Pure @@ -96,11 +96,11 @@ let fns () : List = { name = fn "floatRound" 0 typeParams = [] parameters = [ Param.make "a" TFloat "" ] - returnType = TInt64 + returnType = TInt description = "Round to the nearest integer value" fn = (function - | _, _, _, [ DFloat a ] -> a |> System.Math.Round |> int64 |> DInt64 |> Ply + | _, _, _, [ DFloat a ] -> a |> System.Math.Round |> bigint |> Dval.int |> Ply | _ -> incorrectArgs ()) sqlSpec = NotYetImplemented previewable = Pure @@ -111,13 +111,13 @@ let fns () : List = { name = fn "floatTruncate" 0 typeParams = [] parameters = [ Param.make "a" TFloat "" ] - returnType = TInt64 + returnType = TInt description = "Discard the fractional portion of the float, rounding towards zero" fn = (function | _, _, _, [ DFloat a ] -> - a |> System.Math.Truncate |> int64 |> DInt64 |> Ply + a |> System.Math.Truncate |> bigint |> Dval.int |> Ply | _ -> incorrectArgs ()) sqlSpec = NotYetImplemented previewable = Pure @@ -278,13 +278,13 @@ let fns () : List = { name = fn "floatRoundTowardsZero" 0 typeParams = [] parameters = [ Param.make "a" TFloat "" ] - returnType = TInt64 + returnType = TInt description = "Discard the fractional portion of , rounding towards zero." fn = (function | _, _, _, [ DFloat a ] -> - a |> System.Math.Truncate |> int64 |> DInt64 |> Ply + a |> System.Math.Truncate |> bigint |> Dval.int |> Ply | _ -> incorrectArgs ()) sqlSpec = NotYetImplemented previewable = Pure diff --git a/backend/testfiles/execution/stdlib/float.dark b/backend/testfiles/execution/stdlib/float.dark index dac14ce2b0..9d291b95d6 100644 --- a/backend/testfiles/execution/stdlib/float.dark +++ b/backend/testfiles/execution/stdlib/float.dark @@ -1,43 +1,43 @@ Stdlib.Float.add_v0 1.2 1.3 = 2.5 -Stdlib.Float.ceiling_v0 1.3 = 2L -Stdlib.Float.ceiling_v0 1.0000001 = 2L -Stdlib.Float.ceiling_v0 -2147483647.8 = -2147483647L -Stdlib.Float.ceiling_v0 2147483647.0 = 2147483647L -Stdlib.Float.ceiling_v0 0000000.1 = 1L -Stdlib.Float.ceiling_v0 0.0 = 0L -Stdlib.Float.ceiling_v0 17.55042081 = 18L - -Stdlib.Float.roundUp_v0 1.3 = 2L -Stdlib.Float.roundUp_v0 1.0000001 = 2L -Stdlib.Float.roundUp_v0 -2147483647.8 = -2147483647L -Stdlib.Float.roundUp_v0 2147483647.0 = 2147483647L -Stdlib.Float.roundUp_v0 0000000.1 = 1L -Stdlib.Float.roundUp_v0 0.0 = 0L - -Stdlib.Float.floor_v0 1.8 = 1L -Stdlib.Float.floor_v0 -1.0000001 = -2L -Stdlib.Float.floor_v0 -2147483647.8 = -2147483648L -Stdlib.Float.floor_v0 2147483647.0 = 2147483647L -Stdlib.Float.floor_v0 0000000.1 = 0L -Stdlib.Float.floor_v0 0.0 = 0L - -Stdlib.Float.roundDown_v0 1.8 = 1L -Stdlib.Float.roundDown_v0 -1.0000001 = -2L -Stdlib.Float.roundDown_v0 -2147483647.8 = -2147483648L -Stdlib.Float.roundDown_v0 2147483647.0 = 2147483647L -Stdlib.Float.roundDown_v0 0000000.1 = 0L -Stdlib.Float.roundDown_v0 0.0 = 0L - -Stdlib.Float.round_v0 -2147483647.8 = -2147483648L -Stdlib.Float.round_v0 0000000.1 = 0L -Stdlib.Float.round_v0 2147483647.000009 = 2147483647L - -Stdlib.Float.truncate_v0 -2367.9267 = -2367L -Stdlib.Float.truncate_v0 000000.9 = 0L -Stdlib.Float.truncate_v0 -000000.9 = 0L -Stdlib.Float.truncate_v0 0.0 = 0L -Stdlib.Float.truncate_v0 2147483647.000009 = 2147483647L +Stdlib.Float.ceiling_v0 1.3 = 2I +Stdlib.Float.ceiling_v0 1.0000001 = 2I +Stdlib.Float.ceiling_v0 -2147483647.8 = -2147483647I +Stdlib.Float.ceiling_v0 2147483647.0 = 2147483647I +Stdlib.Float.ceiling_v0 0000000.1 = 1I +Stdlib.Float.ceiling_v0 0.0 = 0I +Stdlib.Float.ceiling_v0 17.55042081 = 18I + +Stdlib.Float.roundUp_v0 1.3 = 2I +Stdlib.Float.roundUp_v0 1.0000001 = 2I +Stdlib.Float.roundUp_v0 -2147483647.8 = -2147483647I +Stdlib.Float.roundUp_v0 2147483647.0 = 2147483647I +Stdlib.Float.roundUp_v0 0000000.1 = 1I +Stdlib.Float.roundUp_v0 0.0 = 0I + +Stdlib.Float.floor_v0 1.8 = 1I +Stdlib.Float.floor_v0 -1.0000001 = -2I +Stdlib.Float.floor_v0 -2147483647.8 = -2147483648I +Stdlib.Float.floor_v0 2147483647.0 = 2147483647I +Stdlib.Float.floor_v0 0000000.1 = 0I +Stdlib.Float.floor_v0 0.0 = 0I + +Stdlib.Float.roundDown_v0 1.8 = 1I +Stdlib.Float.roundDown_v0 -1.0000001 = -2I +Stdlib.Float.roundDown_v0 -2147483647.8 = -2147483648I +Stdlib.Float.roundDown_v0 2147483647.0 = 2147483647I +Stdlib.Float.roundDown_v0 0000000.1 = 0I +Stdlib.Float.roundDown_v0 0.0 = 0I + +Stdlib.Float.round_v0 -2147483647.8 = -2147483648I +Stdlib.Float.round_v0 0000000.1 = 0I +Stdlib.Float.round_v0 2147483647.000009 = 2147483647I + +Stdlib.Float.truncate_v0 -2367.9267 = -2367I +Stdlib.Float.truncate_v0 000000.9 = 0I +Stdlib.Float.truncate_v0 -000000.9 = 0I +Stdlib.Float.truncate_v0 0.0 = 0I +Stdlib.Float.truncate_v0 2147483647.000009 = 2147483647I Stdlib.Float.absoluteValue_v0 Builtin.testNegativeInfinity_v0 = Builtin.testInfinity_v0 Stdlib.Float.absoluteValue_v0 Builtin.testNan_v0 = Builtin.testNan_v0 @@ -165,11 +165,11 @@ Stdlib.Float.parse_v0 "1.8E+308" = Stdlib.Result.Result.Ok Builtin.testInfinity_ Stdlib.Float.power_v0 4.0 -0.5 = 0.5 Stdlib.Float.power_v0 4.0 0.5 = 2.0 -Stdlib.Float.roundTowardsZero -2367.9267 = -2367L -Stdlib.Float.roundTowardsZero 000000.9 = 0L -Stdlib.Float.roundTowardsZero -000000.9 = 0L -Stdlib.Float.roundTowardsZero 0.0 = 0L -Stdlib.Float.roundTowardsZero 2147483647.000009 = 2147483647L +Stdlib.Float.roundTowardsZero -2367.9267 = -2367I +Stdlib.Float.roundTowardsZero 000000.9 = 0I +Stdlib.Float.roundTowardsZero -000000.9 = 0I +Stdlib.Float.roundTowardsZero 0.0 = 0I +Stdlib.Float.roundTowardsZero 2147483647.000009 = 2147483647I Stdlib.Float.sqrt_v0 25.0 = 5.0 Stdlib.Float.sqrt_v0 0.0 = 0.0 diff --git a/backend/testfiles/execution/stdlib/tuple.dark b/backend/testfiles/execution/stdlib/tuple.dark index 77ab16f0fa..081eb59100 100644 --- a/backend/testfiles/execution/stdlib/tuple.dark +++ b/backend/testfiles/execution/stdlib/tuple.dark @@ -39,7 +39,7 @@ module Tuple3 = Stdlib.Tuple3.mapSecond (fun x -> Stdlib.String.toUppercase x) (1L, "two", 3.14) = (1L, "TWO", 3.14) Stdlib.Tuple3.mapThird (fun x -> Stdlib.String.toUppercase x) ("one", 2L, "pi") = ("one", 2L, "PI") - Stdlib.Tuple3.mapThird (fun x -> Stdlib.Float.roundDown_v0 x) (1L, "two", 3.14) = (1L, "two", 3L) + Stdlib.Tuple3.mapThird (fun x -> Stdlib.Float.roundDown_v0 x) (1L, "two", 3.14) = (1L, "two", 3I) Stdlib.Tuple3.mapAllThree @@ -52,4 +52,4 @@ module Tuple3 = (fun x -> x - 2L) (fun x -> Stdlib.String.toUppercase x) (fun x -> Stdlib.Float.roundDown_v0 x) - (1L, "two", 3.14) = (-1L, "TWO", 3L) \ No newline at end of file + (1L, "two", 3.14) = (-1L, "TWO", 3I) \ No newline at end of file diff --git a/packages/darklang/cli/ui/components/forms.dark b/packages/darklang/cli/ui/components/forms.dark index b2450d95df..890746db70 100644 --- a/packages/darklang/cli/ui/components/forms.dark +++ b/packages/darklang/cli/ui/components/forms.dark @@ -258,6 +258,8 @@ let renderSlider (component: Core.Types.Component) (context: Core.T let filledWidth = (Stdlib.Float.multiply (Stdlib.Int64.toFloat model.width) percentage) |> Stdlib.Float.round + |> Stdlib.Int.toInt64 + |> Builtin.unwrap let emptyWidth = Stdlib.Int64.subtract model.width filledWidth let track = Stdlib.String.repeat "═" filledWidth ++ Stdlib.String.repeat "─" emptyWidth diff --git a/packages/darklang/json-rpc.dark b/packages/darklang/json-rpc.dark index 2af45e3397..8bdf7d6652 100644 --- a/packages/darklang/json-rpc.dark +++ b/packages/darklang/json-rpc.dark @@ -15,13 +15,13 @@ let expectedJsonRpcVersion = "2.0" type RequestID = | Null - | Int of Int64 + | Int of Int | String of String let requestIdToJson (id: RequestID) : Json = match id with | Null -> Json.Null - | Int i -> Json.Number(Stdlib.Int64.toFloat i) + | Int i -> Json.Number(Stdlib.Int.toFloat i) | String s -> Json.String s diff --git a/packages/darklang/languageTools/lsp-server/handleIncomingMessage.dark b/packages/darklang/languageTools/lsp-server/handleIncomingMessage.dark index e54891aebe..cb08f6ec5d 100644 --- a/packages/darklang/languageTools/lsp-server/handleIncomingMessage.dark +++ b/packages/darklang/languageTools/lsp-server/handleIncomingMessage.dark @@ -307,7 +307,7 @@ let handleIncomingMessage Scm.handleGetWipSummaryRequest state requestId | ("dark/scm/getCommits", Some requestId, Some(Object [ ("limit", Number n) ])) -> - Scm.handleGetCommitsRequest state requestId (Stdlib.Float.truncate n) + Scm.handleGetCommitsRequest state requestId (Stdlib.Int64.fromFloat n) | ("dark/scm/getCommits", Some requestId, _) -> Scm.handleGetCommitsRequest state requestId 10L diff --git a/packages/darklang/stdlib/alt-json.dark b/packages/darklang/stdlib/alt-json.dark index 24f5c1ab96..494cc71e43 100644 --- a/packages/darklang/stdlib/alt-json.dark +++ b/packages/darklang/stdlib/alt-json.dark @@ -80,7 +80,7 @@ module Helpers = match found with | Some pair -> match Tuple2.second pair with - | Number n -> Float.truncate n + | Number n -> Int64.fromFloat n | _ -> 0L | None -> 0L @@ -95,7 +95,7 @@ module Helpers = match found with | Some pair -> match Tuple2.second pair with - | Number n -> Option.Option.Some(Float.truncate n) + | Number n -> Option.Option.Some(Int64.fromFloat n) | _ -> Option.Option.None | None -> Option.Option.None diff --git a/packages/darklang/stdlib/float.dark b/packages/darklang/stdlib/float.dark index 36fcf43dcd..b080269415 100644 --- a/packages/darklang/stdlib/float.dark +++ b/packages/darklang/stdlib/float.dark @@ -4,36 +4,36 @@ module Darklang.Stdlib.Float type ParseError = | BadFormat /// Round up to an integer value -let ceiling (a: Float) : Int64 = Builtin.floatCeiling a +let ceiling (a: Float) : Int = Builtin.floatCeiling a /// Round up to an integer value -let roundUp (a: Float) : Int64 = Builtin.floatRoundUp a +let roundUp (a: Float) : Int = Builtin.floatRoundUp a /// Round down to an integer value. /// Consider if your goal /// is to discard the fractional part of a number: {{Float.floor -1.9 == -2.0}} /// but {{Float.truncate -1.9 == -1.0}} -let floor (a: Float) : Int64 = Builtin.floatFloor a +let floor (a: Float) : Int = Builtin.floatFloor a /// Round down to an integer value. /// Consider if your goal is to discard the fractional part /// of a number: {{Float.floor -1.9 == -2.0}} but {{Float.truncate -1.9 == /// -1.0}} -let roundDown (a: Float) : Int64 = Builtin.floatRoundDown a +let roundDown (a: Float) : Int = Builtin.floatRoundDown a /// Round to the nearest integer value -let round (a: Float) : Int64 = Builtin.floatRound a +let round (a: Float) : Int = Builtin.floatRound a /// Returns the value wrapped in a {{Result}} of the -let roundTowardsZero (a: Float) : Int64 = Builtin.floatRoundTowardsZero a +let roundTowardsZero (a: Float) : Int = Builtin.floatRoundTowardsZero a /// Discard the fractional portion of the float, rounding towards zero -let truncate (a: Float) : Int64 = Builtin.floatTruncate a +let truncate (a: Float) : Int = Builtin.floatTruncate a /// Returns the absolute value of (turning negative inputs into positive outputs) diff --git a/packages/darklang/stdlib/uint64.dark b/packages/darklang/stdlib/uint64.dark index 6e48356c1c..fc1d25ceac 100644 --- a/packages/darklang/stdlib/uint64.dark +++ b/packages/darklang/stdlib/uint64.dark @@ -68,7 +68,7 @@ let toFloat (a: UInt64) : Float = Builtin.uint64ToFloat a /// Converts a to an let fromFloat (a: Float) : Stdlib.Option.Option = - a |> Float.round |> fromInt64 + a |> Float.round |> Stdlib.Int.toUInt64 /// Returns the sum of all the ints in the list From 8c2a053ee37745a9d4c1968382e329cd7031faee Mon Sep 17 00:00:00 2001 From: OceanOak Date: Tue, 16 Jun 2026 11:18:26 +0000 Subject: [PATCH 05/61] Add Int.remainder/mod tests --- .../src/Builtins/Builtins.Pure/Libs/Float.fs | 15 +++++++---- .../src/Builtins/Builtins.Pure/Libs/Int.fs | 5 ++-- .../testfiles/execution/stdlib/ints/int.dark | 26 +++++++++++++++++++ 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/backend/src/Builtins/Builtins.Pure/Libs/Float.fs b/backend/src/Builtins/Builtins.Pure/Libs/Float.fs index 46630e6edf..0531d2bebf 100644 --- a/backend/src/Builtins/Builtins.Pure/Libs/Float.fs +++ b/backend/src/Builtins/Builtins.Pure/Libs/Float.fs @@ -29,7 +29,8 @@ let fns () : List = description = "Round up to an integer value" fn = (function - | _, _, _, [ DFloat a ] -> a |> System.Math.Ceiling |> bigint |> Dval.int |> Ply + | _, _, _, [ DFloat a ] -> + a |> System.Math.Ceiling |> bigint |> Dval.int |> Ply | _ -> incorrectArgs ()) sqlSpec = NotYetImplemented previewable = Pure @@ -44,7 +45,8 @@ let fns () : List = description = "Round up to an integer value" fn = (function - | _, _, _, [ DFloat a ] -> a |> System.Math.Ceiling |> bigint |> Dval.int |> Ply + | _, _, _, [ DFloat a ] -> + a |> System.Math.Ceiling |> bigint |> Dval.int |> Ply | _ -> incorrectArgs ()) sqlSpec = NotYetImplemented previewable = Pure @@ -64,7 +66,8 @@ let fns () : List = but {{Float.truncate -1.9 == -1.0}}" fn = (function - | _, _, _, [ DFloat a ] -> a |> System.Math.Floor |> bigint |> Dval.int |> Ply + | _, _, _, [ DFloat a ] -> + a |> System.Math.Floor |> bigint |> Dval.int |> Ply | _ -> incorrectArgs ()) sqlSpec = NotYetImplemented previewable = Pure @@ -85,7 +88,8 @@ let fns () : List = fn = (function - | _, _, _, [ DFloat a ] -> a |> System.Math.Floor |> bigint |> Dval.int |> Ply + | _, _, _, [ DFloat a ] -> + a |> System.Math.Floor |> bigint |> Dval.int |> Ply | _ -> incorrectArgs ()) sqlSpec = NotYetImplemented previewable = Pure @@ -100,7 +104,8 @@ let fns () : List = description = "Round to the nearest integer value" fn = (function - | _, _, _, [ DFloat a ] -> a |> System.Math.Round |> bigint |> Dval.int |> Ply + | _, _, _, [ DFloat a ] -> + a |> System.Math.Round |> bigint |> Dval.int |> Ply | _ -> incorrectArgs ()) sqlSpec = NotYetImplemented previewable = Pure diff --git a/backend/src/Builtins/Builtins.Pure/Libs/Int.fs b/backend/src/Builtins/Builtins.Pure/Libs/Int.fs index 1ff8cf71ec..b6b64b5f16 100644 --- a/backend/src/Builtins/Builtins.Pure/Libs/Int.fs +++ b/backend/src/Builtins/Builtins.Pure/Libs/Int.fs @@ -95,12 +95,11 @@ let fns () : List = outcome. Returns an {{Error}} if is {{0}}." fn = let resultOk = Dval.resultOk KTInt KTString - let resultError = Dval.resultError KTInt KTString (function - | _, _, _, [ DInt value; DInt divisor ] -> + | _, vm, _, [ DInt value; DInt divisor ] -> let d = DarkInt.toBigInt divisor if d = bigZero then - DString "`divisor` must be non-zero" |> resultError |> Ply + divideByZero vm else DarkInt.toBigInt value % d |> Dval.int |> resultOk |> Ply | _ -> incorrectArgs ()) diff --git a/backend/testfiles/execution/stdlib/ints/int.dark b/backend/testfiles/execution/stdlib/ints/int.dark index 4566568bb1..7347851dee 100644 --- a/backend/testfiles/execution/stdlib/ints/int.dark +++ b/backend/testfiles/execution/stdlib/ints/int.dark @@ -64,3 +64,29 @@ Stdlib.Int.toInt128 (2I ^ 100I) = Stdlib.Option.Option.Some 1267650600228229401496703205376Q Stdlib.Int.toInt128 (2I ^ 200I) = Stdlib.Option.Option.None Stdlib.Int.toUInt128 (2I ^ 200I) = Stdlib.Option.Option.None + + +// --- remainder: Result; sign follows the dividend; Error only if divisor is 0 --- +Stdlib.Int.remainder 15I 6I = Stdlib.Result.Result.Ok 3I +Stdlib.Int.remainder 20I 8I = Stdlib.Result.Result.Ok 4I +Stdlib.Int.remainder -20I 8I = Stdlib.Result.Result.Ok -4I +Stdlib.Int.remainder -20I -8I = Stdlib.Result.Result.Ok -4I +Stdlib.Int.remainder -15I 6I = Stdlib.Result.Result.Ok -3I +Stdlib.Int.remainder 5I 0I = error="Cannot divide by 0" +// arbitrary precision: 2^100 mod 7 == 2, with a dividend well past Int64 +Stdlib.Int.remainder (2I ^ 100I) 7I = Stdlib.Result.Result.Ok 2I + +// --- mod: wraps into [0, b); RTE if b <= 0 --- +Stdlib.Int.mod_v0 15I 5I = 0I +Stdlib.Int.mod_v0 15I 6I = 3I +Stdlib.Int.mod_v0 0I 15I = 0I +Stdlib.Int.mod_v0 -1I 2I = 1I +Stdlib.Int.mod_v0 -754I 53I = 41I +Stdlib.Int.mod_v0 (2I ^ 100I) 7I = 2I +Stdlib.Int.mod_v0 5I 0I = error="Cannot evaluate modulus against 0" +Stdlib.Int.mod_v0 5I -5I = error="Cannot evaluate modulus against a negative number" + +// the % operator dispatches to mod +15I % 5I = 0I +5I % 0I = error="Cannot evaluate modulus against 0" +5I % -5I = error="Cannot evaluate modulus against a negative number" From 319166debec8cd8976329f940938d91cd2dcd65d Mon Sep 17 00:00:00 2001 From: OceanOak Date: Tue, 16 Jun 2026 11:36:36 +0000 Subject: [PATCH 06/61] Migrate Int.parse error from String to ParseError --- .../src/Builtins/Builtins.Pure/Libs/Int.fs | 27 ++++++++++++++++--- backend/src/LibExecution/PackageRefs.fs | 1 + .../testfiles/execution/stdlib/ints/int.dark | 1 + packages/darklang/stdlib/int.dark | 7 ++++- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/backend/src/Builtins/Builtins.Pure/Libs/Int.fs b/backend/src/Builtins/Builtins.Pure/Libs/Int.fs index b6b64b5f16..dabd438f2f 100644 --- a/backend/src/Builtins/Builtins.Pure/Libs/Int.fs +++ b/backend/src/Builtins/Builtins.Pure/Libs/Int.fs @@ -10,7 +10,21 @@ open LibExecution.Builtin.Shortcuts module VT = LibExecution.ValueType module Dval = LibExecution.Dval +module PackageRefs = LibExecution.PackageRefs module RTE = RuntimeError +module NR = LibExecution.RuntimeTypes.NameResolution + +module ParseError = + type ParseError = | BadFormat + + let toDT (e : ParseError) : Dval = + let (caseName, fields) = + match e with + | BadFormat -> "BadFormat", [] + + let typeName = FQTypeName.fqPackage (PackageRefs.Type.Stdlib.intParseError ()) + DEnum(typeName, typeName, [], caseName, fields) + let private bigZero = System.Numerics.BigInteger.Zero let private bigOne = System.Numerics.BigInteger.One @@ -319,18 +333,23 @@ let fns () : List = { name = fn "intParse" 0 typeParams = [] parameters = [ Param.make "s" TString "" ] - returnType = TypeReference.result TInt TString + returnType = + let errorType = + FQTypeName.fqPackage (PackageRefs.Type.Stdlib.intParseError ()) + TypeReference.result TInt (TCustomType(NR.ok errorType, [])) description = "Returns the value of a . Arbitrary precision, so the only failure is a badly-formatted string." fn = - let resultOk = Dval.resultOk KTInt KTString - let resultError = Dval.resultError KTInt KTString + let typeName = + FQTypeName.fqPackage (PackageRefs.Type.Stdlib.intParseError ()) + let resultOk = Dval.resultOk KTInt (KTCustomType(typeName, [])) + let resultError = Dval.resultError KTInt (KTCustomType(typeName, [])) (function | _, _, _, [ DString s ] -> match System.Numerics.BigInteger.TryParse(s) with | true, i -> i |> Dval.int |> resultOk |> Ply - | false, _ -> DString "Invalid Int" |> resultError |> Ply + | false, _ -> ParseError.BadFormat |> ParseError.toDT |> resultError |> Ply | _ -> incorrectArgs ()) sqlSpec = NotQueryable previewable = Pure diff --git a/backend/src/LibExecution/PackageRefs.fs b/backend/src/LibExecution/PackageRefs.fs index 46239c5f72..2dd2a3b17c 100644 --- a/backend/src/LibExecution/PackageRefs.fs +++ b/backend/src/LibExecution/PackageRefs.fs @@ -101,6 +101,7 @@ module Type = let result = p [ "Result" ] "Result" let option = p [ "Option" ] "Option" + let intParseError = p [ "Int" ] "ParseError" let int8ParseError = p [ "Int8" ] "ParseError" let uint8ParseError = p [ "UInt8" ] "ParseError" let int16ParseError = p [ "Int16" ] "ParseError" diff --git a/backend/testfiles/execution/stdlib/ints/int.dark b/backend/testfiles/execution/stdlib/ints/int.dark index 7347851dee..0a47b89a5c 100644 --- a/backend/testfiles/execution/stdlib/ints/int.dark +++ b/backend/testfiles/execution/stdlib/ints/int.dark @@ -38,6 +38,7 @@ Stdlib.Int.toString 5I = "5" Stdlib.Int.toString 9223372036854775808I = "9223372036854775808" Stdlib.Int.parse "9223372036854775808" = Stdlib.Result.Result.Ok 9223372036854775808I Stdlib.Int.parse "5" = Stdlib.Result.Result.Ok 5I +Stdlib.Int.parse "not a number" = Stdlib.Result.Result.Error Stdlib.Int.ParseError.BadFormat Stdlib.Int.fromInt64 5L = 5I // toInt64 relies on the invariant: a small Int always fits, a big Int never does diff --git a/packages/darklang/stdlib/int.dark b/packages/darklang/stdlib/int.dark index 34b39d90e5..d10f5ba20e 100644 --- a/packages/darklang/stdlib/int.dark +++ b/packages/darklang/stdlib/int.dark @@ -8,6 +8,8 @@ module Darklang.Stdlib.Int // Note: because this file is parsed by the F# host parser, every `Int` literal // below needs the `I` suffix (a bare `1` would be an `Int32` here). +type ParseError = | BadFormat + /// Returns the result of wrapping around so that {{0 <= res < b}}. /// The modulus must be greater than 0. @@ -110,7 +112,10 @@ let clamp (value: Int) (limitA: Int) (limitB: Int) : Int = /// Returns the value of a . Because is /// arbitrary-precision, the only failure is a badly-formatted string. -let parse (s: String) : Stdlib.Result.Result = Builtin.intParse s +let parse + (s: String) + : Stdlib.Result.Result = + Builtin.intParse s /// Stringify From 80460e0d3f03bf0db6262886e52d787b1f0c68db Mon Sep 17 00:00:00 2001 From: OceanOak Date: Tue, 16 Jun 2026 11:51:52 +0000 Subject: [PATCH 07/61] Migrate Char.toAsciiCode and Char.fromCodepoint from Int64 to Int --- .../src/Builtins/Builtins.Pure/Libs/Char.fs | 17 ++++++--- backend/testfiles/execution/stdlib/char.dark | 38 +++++++++---------- .../darklang/languageTools/parser/core.dark | 14 +++---- packages/darklang/prettyPrinter/common.dark | 3 ++ packages/darklang/stdlib/char.dark | 6 +-- 5 files changed, 43 insertions(+), 35 deletions(-) diff --git a/backend/src/Builtins/Builtins.Pure/Libs/Char.fs b/backend/src/Builtins/Builtins.Pure/Libs/Char.fs index 99bf3ab225..86e3c1698b 100644 --- a/backend/src/Builtins/Builtins.Pure/Libs/Char.fs +++ b/backend/src/Builtins/Builtins.Pure/Libs/Char.fs @@ -46,7 +46,7 @@ let fns () : List = { name = fn "charToAsciiCode" 0 typeParams = [] parameters = [ Param.make "c" TChar "" ] - returnType = TypeReference.option TInt64 + returnType = TypeReference.option TInt description = "Return {{Some }} if is a valid ASCII character, otherwise {{None}}" fn = @@ -54,9 +54,9 @@ let fns () : List = | _, _, _, [ DChar c ] -> let charValue = int c[0] if charValue >= 0 && charValue < 256 then - Dval.optionSome KTInt64 (DInt64 charValue) |> Ply + Dval.optionSome KTInt (Dval.int (bigint charValue)) |> Ply else - Dval.optionNone KTInt64 |> Ply + Dval.optionNone KTInt |> Ply | _ -> incorrectArgs () sqlSpec = NotYetImplemented previewable = Pure @@ -141,7 +141,7 @@ let fns () : List = { name = fn "charFromCodepoint" 0 typeParams = [] - parameters = [ Param.make "codepoint" TInt64 "" ] + parameters = [ Param.make "codepoint" TInt "" ] returnType = TypeReference.option TChar description = "Return {{Some }} for the Unicode codepoint , @@ -149,8 +149,13 @@ let fns () : List = (i.e. negative, greater than 0x10FFFF, or a surrogate)." fn = function - | _, _, _, [ DInt64 cp ] -> - if cp < 0L || cp > 0x10FFFFL || (cp >= 0xD800L && cp <= 0xDFFFL) then + | _, _, _, [ DInt cp ] -> + let cp = DarkInt.toBigInt cp + if + cp < bigint 0 + || cp > bigint 0x10FFFF + || (cp >= bigint 0xD800 && cp <= bigint 0xDFFF) + then Dval.optionNone KTChar |> Ply else let s = System.Char.ConvertFromUtf32(int cp) diff --git a/backend/testfiles/execution/stdlib/char.dark b/backend/testfiles/execution/stdlib/char.dark index 41bb35633a..140c35d265 100644 --- a/backend/testfiles/execution/stdlib/char.dark +++ b/backend/testfiles/execution/stdlib/char.dark @@ -134,23 +134,23 @@ Stdlib.Char.isASCII_v0 ' ' = true Stdlib.Char.isASCII_v0 '\t' = true -Stdlib.Char.toAsciiCode 'a' = Stdlib.Option.Option.Some 97L -Stdlib.Char.toAsciiCode 'A' = Stdlib.Option.Option.Some 65L -Stdlib.Char.toAsciiCode 'á' = Stdlib.Option.Option.Some 225L -Stdlib.Char.toAsciiCode 'Á' = Stdlib.Option.Option.Some 193L -Stdlib.Char.toAsciiCode '3' = Stdlib.Option.Option.Some 51L +Stdlib.Char.toAsciiCode 'a' = Stdlib.Option.Option.Some 97I +Stdlib.Char.toAsciiCode 'A' = Stdlib.Option.Option.Some 65I +Stdlib.Char.toAsciiCode 'á' = Stdlib.Option.Option.Some 225I +Stdlib.Char.toAsciiCode 'Á' = Stdlib.Option.Option.Some 193I +Stdlib.Char.toAsciiCode '3' = Stdlib.Option.Option.Some 51I Stdlib.Char.toAsciiCode (smiley ()) = Stdlib.Option.Option.None Stdlib.Char.toAsciiCode 'ż' = Stdlib.Option.Option.None Stdlib.Char.toAsciiCode 'Ż' = Stdlib.Option.Option.None -Stdlib.Char.toAsciiCode 'ó' = Stdlib.Option.Option.Some 243L -Stdlib.Char.toAsciiCode 'Ó' = Stdlib.Option.Option.Some 211L +Stdlib.Char.toAsciiCode 'ó' = Stdlib.Option.Option.Some 243I +Stdlib.Char.toAsciiCode 'Ó' = Stdlib.Option.Option.Some 211I Stdlib.Char.toAsciiCode 'ł' = Stdlib.Option.Option.None Stdlib.Char.toAsciiCode 'Ł' = Stdlib.Option.Option.None Stdlib.Char.toAsciiCode (hand ()) = Stdlib.Option.Option.None Stdlib.Char.toAsciiCode 'ჾ' = Stdlib.Option.Option.None Stdlib.Char.toAsciiCode 'Ჾ' = Stdlib.Option.Option.None -Stdlib.Char.toAsciiCode ' ' = Stdlib.Option.Option.Some 32L -Stdlib.Char.toAsciiCode '\t' = Stdlib.Option.Option.Some 9L +Stdlib.Char.toAsciiCode ' ' = Stdlib.Option.Option.Some 32I +Stdlib.Char.toAsciiCode '\t' = Stdlib.Option.Option.Some 9I Stdlib.Char.isLessThan_v0 'a' 'b' = true @@ -205,20 +205,20 @@ Stdlib.Char.toString 'ჾ' = "ჾ" // Valid codepoints -Stdlib.Char.fromCodepoint 65L = Stdlib.Option.Option.Some 'A' -Stdlib.Char.fromCodepoint 233L = Stdlib.Option.Option.Some 'é' +Stdlib.Char.fromCodepoint 65I = Stdlib.Option.Option.Some 'A' +Stdlib.Char.fromCodepoint 233I = Stdlib.Option.Option.Some 'é' // Non-BMP: pins the surrogate-pair path through ConvertFromUtf32. 0x1F602 = 😂 -Stdlib.Char.fromCodepoint 128514L = Stdlib.Option.Option.Some (smiley ()) +Stdlib.Char.fromCodepoint 128514I = Stdlib.Option.Option.Some (smiley ()) // Invalid: surrogate range (D800..DFFF) — reserved for UTF-16 surrogate pairs -Stdlib.Char.fromCodepoint 55296L = Stdlib.Option.Option.None -Stdlib.Char.fromCodepoint 56319L = Stdlib.Option.Option.None -Stdlib.Char.fromCodepoint 57343L = Stdlib.Option.Option.None +Stdlib.Char.fromCodepoint 55296I = Stdlib.Option.Option.None +Stdlib.Char.fromCodepoint 56319I = Stdlib.Option.Option.None +Stdlib.Char.fromCodepoint 57343I = Stdlib.Option.Option.None // Invalid: above Unicode max (0x10FFFF) -Stdlib.Char.fromCodepoint 1114112L = Stdlib.Option.Option.None -Stdlib.Char.fromCodepoint 2147483647L = Stdlib.Option.Option.None +Stdlib.Char.fromCodepoint 1114112I = Stdlib.Option.Option.None +Stdlib.Char.fromCodepoint 2147483647I = Stdlib.Option.Option.None // Invalid: negative — the F# test parser rejects `-NL`, so build via `0L - N`. -Stdlib.Char.fromCodepoint (0L - 1L) = Stdlib.Option.Option.None -Stdlib.Char.fromCodepoint (0L - 1000L) = Stdlib.Option.Option.None \ No newline at end of file +Stdlib.Char.fromCodepoint (0I - 1I) = Stdlib.Option.Option.None +Stdlib.Char.fromCodepoint (0I - 1000I) = Stdlib.Option.Option.None \ No newline at end of file diff --git a/packages/darklang/languageTools/parser/core.dark b/packages/darklang/languageTools/parser/core.dark index 46e31c2f3b..cbbce324bc 100644 --- a/packages/darklang/languageTools/parser/core.dark +++ b/packages/darklang/languageTools/parser/core.dark @@ -95,21 +95,21 @@ let createUnparseableErrorMsg // is guaranteed to start with `\` and be one of the documented shapes. // Anything else means the grammar and decoder have drifted. -let hexDigitValue (c: Char) : Stdlib.Option.Option = +let hexDigitValue (c: Char) : Stdlib.Option.Option = if (Stdlib.Char.isGreaterThanOrEqualTo c '0') && (Stdlib.Char.isLessThanOrEqualTo c '9') then - Stdlib.Option.map (Stdlib.Char.toAsciiCode c) (fun code -> code - 48L) + Stdlib.Option.map (Stdlib.Char.toAsciiCode c) (fun code -> code - 48I) else if (Stdlib.Char.isGreaterThanOrEqualTo c 'a') && (Stdlib.Char.isLessThanOrEqualTo c 'f') then - Stdlib.Option.map (Stdlib.Char.toAsciiCode c) (fun code -> code - 87L) + Stdlib.Option.map (Stdlib.Char.toAsciiCode c) (fun code -> code - 87I) else if (Stdlib.Char.isGreaterThanOrEqualTo c 'A') && (Stdlib.Char.isLessThanOrEqualTo c 'F') then - Stdlib.Option.map (Stdlib.Char.toAsciiCode c) (fun code -> code - 55L) + Stdlib.Option.map (Stdlib.Char.toAsciiCode c) (fun code -> code - 55I) else Stdlib.Option.Option.None -let hexDigitsValue (digits: List) : Stdlib.Option.Option = - Stdlib.List.fold digits (Stdlib.Option.Option.Some 0L) (fun acc d -> +let hexDigitsValue (digits: List) : Stdlib.Option.Option = + Stdlib.List.fold digits (Stdlib.Option.Option.Some 0I) (fun acc d -> match acc, hexDigitValue d with - | Some acc, Some v -> Stdlib.Option.Option.Some ((acc * 16L) + v) + | Some acc, Some v -> Stdlib.Option.Option.Some ((acc * 16I) + v) | _ -> Stdlib.Option.Option.None) diff --git a/packages/darklang/prettyPrinter/common.dark b/packages/darklang/prettyPrinter/common.dark index 25aefa2a5f..f87306160b 100644 --- a/packages/darklang/prettyPrinter/common.dark +++ b/packages/darklang/prettyPrinter/common.dark @@ -41,6 +41,9 @@ let encodeChar (c: Char) : String = match Stdlib.Char.toAsciiCode c with | None -> Stdlib.Char.toString c | Some code -> + // CLEANUP drop this bridge once String.slice / hexDigitChar move to Int + let code = Builtin.unwrap (Stdlib.Int.toInt64 code) + if code == 92L then "\\\\" else if code == 7L then "\\a" else if code == 8L then "\\b" diff --git a/packages/darklang/stdlib/char.dark b/packages/darklang/stdlib/char.dark index ba1e735912..24c2b9bfce 100644 --- a/packages/darklang/stdlib/char.dark +++ b/packages/darklang/stdlib/char.dark @@ -38,12 +38,12 @@ let isASCII (c: Char) : Bool = let asciiCode = Stdlib.Char.toAsciiCode c match asciiCode with - | Some ascii -> (ascii >= 0L) && (ascii <= 127L) + | Some ascii -> (ascii >= 0I) && (ascii <= 127I) | None -> false /// Return {{Some }} if is a valid ASCII character, otherwise {{None}}" -let toAsciiCode (c: Char) : Stdlib.Option.Option = +let toAsciiCode (c: Char) : Stdlib.Option.Option = Builtin.charToAsciiCode c @@ -72,5 +72,5 @@ let toString (c: Char) : String = Builtin.charToString c /// Return {{Some }} for the Unicode codepoint , /// or {{None}} if the value is not a valid scalar (negative, > 0x10FFFF, or a surrogate). -let fromCodepoint (codepoint: Int64) : Stdlib.Option.Option = +let fromCodepoint (codepoint: Int) : Stdlib.Option.Option = Builtin.charFromCodepoint codepoint \ No newline at end of file From 2aebd248468526852a38b9dfb2d6fccd0dac681d Mon Sep 17 00:00:00 2001 From: OceanOak Date: Tue, 16 Jun 2026 12:45:15 +0000 Subject: [PATCH 08/61] Migrate Duration.parse from Int64 to Int and add tests --- .../testfiles/execution/stdlib/duration.dark | 23 +++++++++++++++++++ packages/darklang/cli/tracing.dark | 6 +++-- packages/darklang/stdlib/duration.dark | 10 ++++---- 3 files changed, 32 insertions(+), 7 deletions(-) create mode 100644 backend/testfiles/execution/stdlib/duration.dark diff --git a/backend/testfiles/execution/stdlib/duration.dark b/backend/testfiles/execution/stdlib/duration.dark new file mode 100644 index 0000000000..dfcfa8ca8d --- /dev/null +++ b/backend/testfiles/execution/stdlib/duration.dark @@ -0,0 +1,23 @@ +// Duration.parse: suffix-based short-duration parsing ("30s"/"5m"/"1h"/"2d") +// into a number of seconds (arbitrary-precision Int). + +// --- units --- +Stdlib.Duration.parse "30s" = Stdlib.Result.Result.Ok 30I +Stdlib.Duration.parse "5m" = Stdlib.Result.Result.Ok 300I +Stdlib.Duration.parse "1h" = Stdlib.Result.Result.Ok 3600I +Stdlib.Duration.parse "2d" = Stdlib.Result.Result.Ok 172800I +Stdlib.Duration.parse "0s" = Stdlib.Result.Result.Ok 0I + +// --- arbitrary precision: a value past Int64 range now parses (Int64.parse +// would have rejected it as out-of-range) --- +Stdlib.Duration.parse "9223372036854775808s" = + Stdlib.Result.Result.Ok 9223372036854775808I + +// --- errors --- +// too short (no unit) +Stdlib.Duration.parse "5" = Stdlib.Result.Result.Error "Duration too short: '5'; need a number + unit (s/m/h/d), e.g. 5m" +Stdlib.Duration.parse "s" = Stdlib.Result.Result.Error "Duration too short: 's'; need a number + unit (s/m/h/d), e.g. 5m" +// non-numeric number part +Stdlib.Duration.parse "xm" = Stdlib.Result.Result.Error "Invalid duration 'xm'; need a number + unit (s/m/h/d), e.g. 5m" +// unknown unit +Stdlib.Duration.parse "5x" = Stdlib.Result.Result.Error "Unknown unit 'x' in '5x'; use s, m, h, or d" diff --git a/packages/darklang/cli/tracing.dark b/packages/darklang/cli/tracing.dark index 44c7426e33..48c6dd0485 100644 --- a/packages/darklang/cli/tracing.dark +++ b/packages/darklang/cli/tracing.dark @@ -1139,7 +1139,7 @@ let executeClear (state: Cli.AppState) : Cli.AppState = /// Parse a CLI duration arg. `-`-prefixed inputs are reported as /// "Unknown flag" rather than "Invalid duration" — same logic as /// `parsePositionalErr`. Otherwise delegates to `Stdlib.Duration.parse`. -let parseDuration (s: String) : Stdlib.Result.Result = +let parseDuration (s: String) : Stdlib.Result.Result = if Stdlib.String.startsWith s "-" then Stdlib.Result.Result.Error $"Unknown flag: {s}" else @@ -1158,7 +1158,9 @@ let executeClearBefore state | Ok seconds -> let now = Stdlib.DateTime.now () - let cutoffDt = Stdlib.DateTime.subtractSeconds now seconds + // cleanup + let cutoffDt = + Stdlib.DateTime.subtractSeconds now (Builtin.unwrap (Stdlib.Int.toInt64 seconds)) let cutoff = Stdlib.DateTime.toString cutoffDt let count = Builtin.tracesClearBefore cutoff match count with diff --git a/packages/darklang/stdlib/duration.dark b/packages/darklang/stdlib/duration.dark index cbeacd26d7..90b74cc504 100644 --- a/packages/darklang/stdlib/duration.dark +++ b/packages/darklang/stdlib/duration.dark @@ -5,7 +5,7 @@ module Darklang.Stdlib.Duration /// Parse a short duration string ("30s", "5m", "1h", "2d") into seconds. /// Bare numbers are rejected — every duration must end with a unit. -let parse (s: String) : Stdlib.Result.Result = +let parse (s: String) : Stdlib.Result.Result = let len = Stdlib.String.length s if len < 2L then Stdlib.Result.Result.Error @@ -13,16 +13,16 @@ let parse (s: String) : Stdlib.Result.Result = else let unit = Stdlib.String.last s 1L let numPart = Stdlib.String.dropLast s 1L - match Stdlib.Int64.parse numPart with + match Stdlib.Int.parse numPart with | Error _ -> Stdlib.Result.Result.Error $"Invalid duration '{s}'; need a number + unit (s/m/h/d), e.g. 5m" | Ok n -> match unit with | "s" -> Stdlib.Result.Result.Ok n - | "m" -> Stdlib.Result.Result.Ok(n * 60L) - | "h" -> Stdlib.Result.Result.Ok(n * 3600L) - | "d" -> Stdlib.Result.Result.Ok(n * 86400L) + | "m" -> Stdlib.Result.Result.Ok(n * 60I) + | "h" -> Stdlib.Result.Result.Ok(n * 3600I) + | "d" -> Stdlib.Result.Result.Ok(n * 86400I) | _ -> Stdlib.Result.Result.Error $"Unknown unit '{unit}' in '{s}'; use s, m, h, or d" From 8337929b7bf71fcf750579e6e998911a8b3b88db Mon Sep 17 00:00:00 2001 From: OceanOak Date: Tue, 16 Jun 2026 12:56:56 +0000 Subject: [PATCH 09/61] Migrate File.size and Dir.size from Int64 to Int --- packages/darklang/stdlib/cli/dir.dark | 4 ++-- packages/darklang/stdlib/cli/file.dark | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/darklang/stdlib/cli/dir.dark b/packages/darklang/stdlib/cli/dir.dark index ceceee65de..0d84a93236 100644 --- a/packages/darklang/stdlib/cli/dir.dark +++ b/packages/darklang/stdlib/cli/dir.dark @@ -148,11 +148,11 @@ let walk (path: String) : Result.Result, Posix.Error> = /// Get the total size of a directory and its contents in bytes. -let size (path: String) : Result.Result = +let size (path: String) : Result.Result = match listRecursive path with | Ok files -> files - |> Stdlib.List.fold (Stdlib.Result.Result.Ok 0L) (fun acc filePath -> + |> Stdlib.List.fold (Stdlib.Result.Result.Ok 0I) (fun acc filePath -> match acc with | Ok total -> match Cli.File.size filePath with diff --git a/packages/darklang/stdlib/cli/file.dark b/packages/darklang/stdlib/cli/file.dark index 4c16ca9587..f27068ebd7 100644 --- a/packages/darklang/stdlib/cli/file.dark +++ b/packages/darklang/stdlib/cli/file.dark @@ -14,9 +14,10 @@ let exists (path: String) : Bool = /// Get the size of a file in bytes. -let size (path: String) : Result.Result = +let size (path: String) : Result.Result = match Posix.stat path with - | Ok result -> Stdlib.Result.Result.Ok result.size + // Cleanup? + | Ok result -> Stdlib.Result.Result.Ok(Stdlib.Int.fromInt64 result.size) | Error e -> Stdlib.Result.Result.Error e From 2e7c5cd2fcf62699ab90c0bb45a1f079debaadd8 Mon Sep 17 00:00:00 2001 From: OceanOak Date: Tue, 16 Jun 2026 18:13:22 +0000 Subject: [PATCH 10/61] Migrate the List index/count cluster andString repeat/charAt/random from Int64 to Int --- .../src/Builtins/Builtins.Pure/Libs/List.fs | 4 +- backend/testfiles/execution/cloud/db.dark | 6 +- .../language/builtin-introspection.dark | 2 +- .../execution/language/custom-data/enums.dark | 2 +- .../language/flow-control/ematch.dark | 2 +- .../language/flow-control/epipe.dark | 2 +- .../execution/language/interpreter.dark | 8 +- .../execution/stdlib/ints/int16.dark | 12 +- .../execution/stdlib/ints/int32.dark | 12 +- .../execution/stdlib/ints/int64.dark | 48 +++---- .../testfiles/execution/stdlib/ints/int8.dark | 12 +- .../execution/stdlib/ints/uint16.dark | 12 +- .../execution/stdlib/ints/uint32.dark | 12 +- .../execution/stdlib/ints/uint64.dark | 12 +- .../execution/stdlib/ints/uint8.dark | 12 +- backend/testfiles/execution/stdlib/json.dark | 4 +- backend/testfiles/execution/stdlib/list.dark | 124 +++++++++--------- .../testfiles/execution/stdlib/stream.dark | 2 +- .../testfiles/execution/stdlib/string.dark | 32 ++--- packages/darklang/cli/apps/command.dark | 6 +- packages/darklang/cli/apps/editor.dark | 8 +- .../darklang/cli/apps/views/ai-chats.dark | 8 +- packages/darklang/cli/apps/views/app.dark | 12 +- .../cli/apps/views/package-stats.dark | 16 +-- packages/darklang/cli/builtins.dark | 6 +- packages/darklang/cli/caps/accessEditor.dark | 6 +- .../darklang/cli/caps/httpRuleEditor.dark | 6 +- packages/darklang/cli/caps/main.dark | 22 ++-- packages/darklang/cli/completionPicker.dark | 32 ++--- packages/darklang/cli/core.dark | 8 +- packages/darklang/cli/deps.dark | 6 +- .../darklang/cli/docs/for-ai-internal.dark | 4 +- packages/darklang/cli/docs/syntax.dark | 2 +- packages/darklang/cli/outliner/core.dark | 10 +- .../darklang/cli/outliner/list-picker.dark | 12 +- packages/darklang/cli/outliner/main.dark | 20 +-- packages/darklang/cli/outliner/markdown.dark | 4 +- .../darklang/cli/outliner/outline-editor.dark | 33 ++--- packages/darklang/cli/outliner/tests.dark | 36 ++--- packages/darklang/cli/packages/db.dark | 8 +- packages/darklang/cli/packages/delete.dark | 6 +- packages/darklang/cli/packages/deprecate.dark | 4 +- .../darklang/cli/packages/navInteractive.dark | 46 +++---- packages/darklang/cli/packages/propagate.dark | 2 +- packages/darklang/cli/packages/query.dark | 2 +- packages/darklang/cli/packages/search.dark | 12 +- .../darklang/cli/packages/signatures.dark | 8 +- packages/darklang/cli/packages/traversal.dark | 2 +- packages/darklang/cli/packages/tree.dark | 2 +- packages/darklang/cli/packages/undo.dark | 2 +- packages/darklang/cli/packages/view.dark | 2 +- packages/darklang/cli/prompt.dark | 6 +- packages/darklang/cli/scm/branch.dark | 6 +- packages/darklang/cli/scm/review/app.dark | 42 +++--- packages/darklang/cli/scm/review/core.dark | 6 +- packages/darklang/cli/tracing.dark | 10 +- .../darklang/cli/ui/components/button.dark | 6 +- packages/darklang/cli/ui/components/card.dark | 36 ++--- .../darklang/cli/ui/components/divider.dark | 2 +- .../darklang/cli/ui/components/dropdown.dark | 44 +++---- .../darklang/cli/ui/components/forms.dark | 28 ++-- .../darklang/cli/ui/components/layout.dark | 14 +- .../darklang/cli/ui/components/listview.dark | 16 +-- .../darklang/cli/ui/components/message.dark | 12 +- .../darklang/cli/ui/components/modal.dark | 28 ++-- .../cli/ui/components/navigation.dark | 28 ++-- .../cli/ui/components/pagination.dark | 38 +++--- .../darklang/cli/ui/components/panel.dark | 44 +++---- .../darklang/cli/ui/components/progress.dark | 4 +- .../darklang/cli/ui/components/scrollbar.dark | 12 +- .../darklang/cli/ui/components/spinner.dark | 6 +- .../darklang/cli/ui/components/statusbar.dark | 6 +- .../darklang/cli/ui/components/table.dark | 12 +- .../darklang/cli/ui/components/textblock.dark | 4 +- packages/darklang/cli/ui/core/rendering.dark | 16 +-- packages/darklang/cli/ui/demo.dark | 2 +- packages/darklang/cli/ui/layout.dark | 9 +- packages/darklang/cli/utils/logo.dark | 6 +- .../cli/utils/syntaxHighlighting.dark | 2 +- packages/darklang/github.dark | 2 +- .../internal/dark-packages/dark-packages.dark | 8 +- .../darklang-internal-mcp-server/tools.dark | 4 +- .../languageTools/lsp-server/branches.dark | 2 +- .../lsp-server/cursorPosition.dark | 2 +- .../languageTools/lsp-server/hover.dark | 2 +- .../languageTools/lsp-server/logging.dark | 2 +- .../lsp-server/semanticTokens.dark | 10 +- packages/darklang/languageTools/lsp.dark | 3 +- .../darklang/languageTools/parser/core.dark | 10 +- .../darklang/languageTools/parser/expr.dark | 6 +- .../parser/functionDeclaration.dark | 2 +- .../languageTools/parser/identifiers.dark | 2 +- .../languageTools/parser/matchPattern.dark | 4 +- .../languageTools/parser/typeDeclaration.dark | 4 +- .../languageTools/parser/typeReference.dark | 4 +- .../writtenTypesToProgramTypes.dark | 3 +- packages/darklang/llm/tools/file-system.dark | 2 +- .../serverBuilder/main.dark | 2 +- packages/darklang/opml/opml.dark | 2 +- .../darklang/prettyPrinter/capabilities.dark | 2 +- packages/darklang/prettyPrinter/common.dark | 2 +- .../darklang/prettyPrinter/programTypes.dark | 7 +- .../darklang/prettyPrinter/runtimeError.dark | 2 +- .../darklang/prettyPrinter/runtimeTypes.dark | 2 +- packages/darklang/scm/partialCommit.dark | 10 +- packages/darklang/stdlib/cli/daemon.dark | 4 +- packages/darklang/stdlib/cli/path.dark | 2 +- packages/darklang/stdlib/cli/process.dark | 2 +- packages/darklang/stdlib/cli/ui/progress.dark | 4 +- packages/darklang/stdlib/cli/ui/prompt.dark | 6 +- packages/darklang/stdlib/cli/ui/table.dark | 4 +- packages/darklang/stdlib/diff.dark | 38 +++--- packages/darklang/stdlib/httpserver.dark | 2 +- packages/darklang/stdlib/list.dark | 68 +++++----- packages/darklang/stdlib/string.dark | 18 +-- packages/darklang/stdlib/valueSearch.dark | 2 +- .../wip/ai/anthropic/integration-tests.dark | 6 +- packages/stachu/darklangParser.dark | 12 +- packages/stachu/parser.dark | 8 +- 119 files changed, 703 insertions(+), 692 deletions(-) diff --git a/backend/src/Builtins/Builtins.Pure/Libs/List.fs b/backend/src/Builtins/Builtins.Pure/Libs/List.fs index 3aeccd0bb4..d2775ada5b 100644 --- a/backend/src/Builtins/Builtins.Pure/Libs/List.fs +++ b/backend/src/Builtins/Builtins.Pure/Libs/List.fs @@ -289,11 +289,11 @@ let fns () : List = [ { name = fn "listLength" 0 typeParams = [] parameters = [ Param.make "list" (TList varA) "" ] - returnType = TInt64 + returnType = TInt description = "Returns the number of values in " fn = (function - | _, _, _, [ DList(_, l) ] -> Ply(Dval.int64 (l.Length)) + | _, _, _, [ DList(_, l) ] -> Ply(Dval.int (bigint l.Length)) | _ -> incorrectArgs ()) sqlSpec = NotQueryable previewable = Pure diff --git a/backend/testfiles/execution/cloud/db.dark b/backend/testfiles/execution/cloud/db.dark index ad9a1edbb7..b7c368476c 100644 --- a/backend/testfiles/execution/cloud/db.dark +++ b/backend/testfiles/execution/cloud/db.dark @@ -129,7 +129,7 @@ module NestedRecordFieldAccess = let shouldBeJustJoe = Stdlib.DB.query TestNestedRecord (fun p -> p.details.numbers.age == 41L) - Stdlib.List.length shouldBeJustJoe) = 1L + Stdlib.List.length shouldBeJustJoe) = 1I // same as above, but with aliases (Stdlib.DB.set @@ -145,7 +145,7 @@ module NestedRecordFieldAccess = let shouldBeJustJeremy = Stdlib.DB.query TestNestedAliasRecord (fun p -> p.details.numbers.age == 38L) - Stdlib.List.length shouldBeJustJeremy) = 1L + Stdlib.List.length shouldBeJustJeremy) = 1I @@ -981,7 +981,7 @@ module PartialEvaluation = (friends (fun p -> let x = YL { y = ZL { z = AL { a = [ 1L; 2L; 3L; 4L; 5L ] } } } - (Stdlib.List.length x.y.z.a) < p.height)) = [ " Chandler "; "GrumpyCat"; "Rachel"; "Ross" ] + (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length x.y.z.a))) < p.height)) = [ " Chandler "; "GrumpyCat"; "Rachel"; "Ross" ] // tuple destructuring inside query - requires tuple pattern support (friends (fun p -> diff --git a/backend/testfiles/execution/language/builtin-introspection.dark b/backend/testfiles/execution/language/builtin-introspection.dark index 66f6a247af..76379ac99b 100644 --- a/backend/testfiles/execution/language/builtin-introspection.dark +++ b/backend/testfiles/execution/language/builtin-introspection.dark @@ -6,7 +6,7 @@ module Documentation = // shipping empty (the actual count is well over 100; the threshold // is intentionally loose so adding/removing one fn doesn't churn this // test). - ((Builtin.getAllBuiltinFns ()) |> Stdlib.List.length) > 100L = true + ((Builtin.getAllBuiltinFns ()) |> Stdlib.List.length) > 100I = true // Builtin metadata round-trips: the registry exposes `int64Add` with // the parameter shape the type-checker uses at call sites. diff --git a/backend/testfiles/execution/language/custom-data/enums.dark b/backend/testfiles/execution/language/custom-data/enums.dark index e47ea730ff..a752748f0b 100644 --- a/backend/testfiles/execution/language/custom-data/enums.dark +++ b/backend/testfiles/execution/language/custom-data/enums.dark @@ -76,7 +76,7 @@ module MixedCases = EnumOfMixedCases.X "testX" EnumOfMixedCases.Y(5L) EnumOfMixedCases.Z("testZ", 2L) ] - match Stdlib.List.getAt values 3L with + match Stdlib.List.getAt values 3I with | Some z -> Stdlib.Result.Result.Ok z | None -> Stdlib.Result.Result.Error "Failure") = Darklang.Stdlib.Result.Result.Ok(EnumOfMixedCases.Z("testZ", 2L)) diff --git a/backend/testfiles/execution/language/flow-control/ematch.dark b/backend/testfiles/execution/language/flow-control/ematch.dark index a15fe12b87..3a4c07bf37 100644 --- a/backend/testfiles/execution/language/flow-control/ematch.dark +++ b/backend/testfiles/execution/language/flow-control/ematch.dark @@ -348,7 +348,7 @@ module List = (match [ 1L; 2L; 3L ] with | var -> - let length = (Stdlib.List.length var) |> Stdlib.Int64.toString + let length = (Stdlib.List.length var) |> Stdlib.Int.toString $"pass with length: {length}" | [ 1L; 2L; 3L ] -> "fail" diff --git a/backend/testfiles/execution/language/flow-control/epipe.dark b/backend/testfiles/execution/language/flow-control/epipe.dark index a920432bf2..b4c787158b 100644 --- a/backend/testfiles/execution/language/flow-control/epipe.dark +++ b/backend/testfiles/execution/language/flow-control/epipe.dark @@ -36,7 +36,7 @@ type Y = { z: Z } type X = { y: Y } (let x = X { y = Y { z = Z { a = [ 1L; 2L; 3L; 4L; 5L ] } } } - (x.y.z.a |> Stdlib.List.length_v0)) = 5L + (x.y.z.a |> Stdlib.List.length_v0)) = 5I type MyEnum = A of Int64 * Int64 * Int64 (33L |> MyEnum.A 21L 42L) = MyEnum.A 33L 21L 42L diff --git a/backend/testfiles/execution/language/interpreter.dark b/backend/testfiles/execution/language/interpreter.dark index 6379ff6e2f..6f22191db7 100644 --- a/backend/testfiles/execution/language/interpreter.dark +++ b/backend/testfiles/execution/language/interpreter.dark @@ -4,14 +4,14 @@ // This test used to cause a stack overflow, but now passes everywhere. // Let's keep this around to ensure we never regress. -((Stdlib.List.repeat_v0 348L 1L) +((Stdlib.List.repeat_v0 348I 1L) |> Builtin.unwrap |> Stdlib.List.map (fun _f -> 1) - |> Stdlib.List.length) = 348L + |> Stdlib.List.length) = 348I // Heavier variant of the stack-overflow regression check. // This is slower, but intentionally kept to protect against perf/stack regressions. -((Stdlib.List.repeat_v0 3480L 1L) +((Stdlib.List.repeat_v0 3480I 1L) |> Builtin.unwrap |> Stdlib.List.map (fun _f -> 1) - |> Stdlib.List.length) = 3480L + |> Stdlib.List.length) = 3480I diff --git a/backend/testfiles/execution/stdlib/ints/int16.dark b/backend/testfiles/execution/stdlib/ints/int16.dark index 9753cdf24e..09c9ac1a27 100644 --- a/backend/testfiles/execution/stdlib/ints/int16.dark +++ b/backend/testfiles/execution/stdlib/ints/int16.dark @@ -105,35 +105,35 @@ Stdlib.Int16.toString 32767s = "32767" // Int16 upper limit Stdlib.Int16.toFloat_v0 2s = 2.0 Stdlib.Int16.toFloat_v0 -10s = -10.0 -(Stdlib.List.range_v0 1L 5L) +(Stdlib.List.range_v0 1I 5I) |> Stdlib.List.map_v0 (fun x -> Stdlib.Int16.random 1s 2s) |> Stdlib.List.map_v0 (fun x -> (Stdlib.Int16.greaterThanOrEqualTo x 1s) && (Stdlib.Int16.lessThanOrEqualTo x 2s)) = [ true; true; true; true; true ] -(Stdlib.List.range_v0 1L 5L) +(Stdlib.List.range_v0 1I 5I) |> Stdlib.List.map_v0 (fun x -> Stdlib.Int16.random 10s 20s) |> Stdlib.List.map_v0 (fun x -> (Stdlib.Int16.greaterThanOrEqualTo x 10s) && (Stdlib.Int16.lessThanOrEqualTo x 20s)) = [ true; true; true; true; true ] -(Stdlib.List.range_v0 1L 5L) +(Stdlib.List.range_v0 1I 5I) |> Stdlib.List.map_v0 (fun x -> Stdlib.Int16.random 2s 1s) |> Stdlib.List.map_v0 (fun x -> (Stdlib.Int16.greaterThanOrEqualTo x 1s) && (Stdlib.Int16.lessThanOrEqualTo x 2s)) = [ true; true; true; true; true ] -(Stdlib.List.range_v0 1L 5L) +(Stdlib.List.range_v0 1I 5I) |> Stdlib.List.map_v0 (fun x -> Stdlib.Int16.random 20s 10s) |> Stdlib.List.map_v0 (fun x -> (Stdlib.Int16.greaterThanOrEqualTo x 10s) && (Stdlib.Int16.lessThanOrEqualTo x 20s)) = [ true; true; true; true; true ] -((Stdlib.List.range_v0 1L 100L) +((Stdlib.List.range_v0 1I 100I) |> Stdlib.List.map_v0 (fun x -> Stdlib.Int16.random 0s 1s) |> Stdlib.List.unique_v0) = [ 0s; 1s ] -((Stdlib.List.range_v0 1L 100L) +((Stdlib.List.range_v0 1I 100I) |> Stdlib.List.map_v0 (fun x -> Stdlib.Int16.random 0s 2s) |> Stdlib.List.unique_v0) = [ 0s; 1s; 2s ] diff --git a/backend/testfiles/execution/stdlib/ints/int32.dark b/backend/testfiles/execution/stdlib/ints/int32.dark index 4d570b39e2..3c3b07e00b 100644 --- a/backend/testfiles/execution/stdlib/ints/int32.dark +++ b/backend/testfiles/execution/stdlib/ints/int32.dark @@ -124,36 +124,36 @@ Stdlib.Int32.divide_v0 0l 1l = 0l Stdlib.Int32.divide_v0 1l 0l = error="Cannot divide by 0" Stdlib.Int32.divide_v0 (-2147483648l) -1l = error="Encountered out-of-range value for type of Int" -(Stdlib.List.range_v0 1L 5L) +(Stdlib.List.range_v0 1I 5I) |> Stdlib.List.map_v0 (fun x -> Stdlib.Int32.random 1l 2l) |> Stdlib.List.map_v0 (fun x -> (Stdlib.Int32.greaterThanOrEqualTo x 1l) && (Stdlib.Int32.lessThanOrEqualTo x 2l)) = [ true; true; true; true; true ] -(Stdlib.List.range_v0 1L 5L) +(Stdlib.List.range_v0 1I 5I) |> Stdlib.List.map_v0 (fun x -> Stdlib.Int32.random 10l 20l) |> Stdlib.List.map_v0 (fun x -> (Stdlib.Int32.greaterThanOrEqualTo x 10l) && (Stdlib.Int32.lessThanOrEqualTo x 20l)) = [ true; true; true; true; true ] -(Stdlib.List.range_v0 1L 5L) +(Stdlib.List.range_v0 1I 5I) |> Stdlib.List.map_v0 (fun x -> Stdlib.Int32.random 2l 1l) |> Stdlib.List.map_v0 (fun x -> (Stdlib.Int32.greaterThanOrEqualTo x 1l) && (Stdlib.Int32.lessThanOrEqualTo x 2l)) = [ true; true; true; true; true ] -(Stdlib.List.range_v0 1L 5L) +(Stdlib.List.range_v0 1I 5I) |> Stdlib.List.map_v0 (fun x -> Stdlib.Int32.random 20l 10l) |> Stdlib.List.map_v0 (fun x -> (Stdlib.Int32.greaterThanOrEqualTo x 10l) && (Stdlib.Int32.lessThanOrEqualTo x 20l)) = [ true; true; true; true; true ] -((Stdlib.List.range_v0 1L 100L) +((Stdlib.List.range_v0 1I 100I) |> Stdlib.List.map_v0 (fun x -> Stdlib.Int32.random 0l 1l) |> Stdlib.List.unique_v0) = [ 0l; 1l ] -((Stdlib.List.range_v0 1L 100L) +((Stdlib.List.range_v0 1I 100I) |> Stdlib.List.map_v0 (fun x -> Stdlib.Int32.random 0l 2l) |> Stdlib.List.unique_v0) = [ 0l; 1l; 2l ] diff --git a/backend/testfiles/execution/stdlib/ints/int64.dark b/backend/testfiles/execution/stdlib/ints/int64.dark index 05dcc4d869..463c8afbb3 100644 --- a/backend/testfiles/execution/stdlib/ints/int64.dark +++ b/backend/testfiles/execution/stdlib/ints/int64.dark @@ -43,8 +43,8 @@ Stdlib.Int64.remainder_v0 -20L -8L = Stdlib.Result.Result.Ok -4L Stdlib.Int64.remainder_v0 -15L 6L = Stdlib.Result.Result.Ok -3L Stdlib.Int64.remainder_v0 5L 0L = error="Cannot divide by 0" (Stdlib.List.map_v0 - (Stdlib.List.range_v0 -5L 5L) - (fun v -> Stdlib.Int64.remainder_v0 v -4L) + (Stdlib.List.range_v0 -5I 5I) + (fun v -> Stdlib.Int64.remainder_v0 (Builtin.unwrap (Stdlib.Int.toInt64 v)) -4L) ) = [ Stdlib.Result.Result.Ok -1L Stdlib.Result.Result.Ok 0L Stdlib.Result.Result.Ok -3L @@ -57,18 +57,20 @@ Stdlib.Int64.remainder_v0 5L 0L = error="Cannot divide by 0" Stdlib.Result.Result.Ok 0L Stdlib.Result.Result.Ok 1L ] -Stdlib.List.map_v0 (Stdlib.List.range_v0 -5L 5L) (fun v -> - Stdlib.Int64.remainder_v0 v 4L) = [ Stdlib.Result.Result.Ok -1L - Stdlib.Result.Result.Ok 0L - Stdlib.Result.Result.Ok -3L - Stdlib.Result.Result.Ok -2L - Stdlib.Result.Result.Ok -1L - Stdlib.Result.Result.Ok 0L - Stdlib.Result.Result.Ok 1L - Stdlib.Result.Result.Ok 2L - Stdlib.Result.Result.Ok 3L - Stdlib.Result.Result.Ok 0L - Stdlib.Result.Result.Ok 1L ] +(Stdlib.List.map_v0 + (Stdlib.List.range_v0 -5I 5I) + (fun v -> Stdlib.Int64.remainder_v0 (Builtin.unwrap (Stdlib.Int.toInt64 v)) 4L) + ) = [ Stdlib.Result.Result.Ok -1L + Stdlib.Result.Result.Ok 0L + Stdlib.Result.Result.Ok -3L + Stdlib.Result.Result.Ok -2L + Stdlib.Result.Result.Ok -1L + Stdlib.Result.Result.Ok 0L + Stdlib.Result.Result.Ok 1L + Stdlib.Result.Result.Ok 2L + Stdlib.Result.Result.Ok 3L + Stdlib.Result.Result.Ok 0L + Stdlib.Result.Result.Ok 1L ] Stdlib.Int64.mod_v0 15L 5L = 0L Stdlib.Int64.mod_v0 15L 6L = 3L @@ -79,13 +81,13 @@ Stdlib.Int64.mod_v0 9999999999998L 3L = 2L Stdlib.Int64.mod_v0 5L 0L = error="Cannot evaluate modulus against 0" Stdlib.Int64.mod_v0 5L -5L = error="Cannot evaluate modulus against a negative number" -Stdlib.List.map_v0 (Stdlib.List.range_v0 -5L 5L) (fun v -> - Stdlib.Int64.mod_v0 v 4L) = [ 3L; 0L; 1L; 2L; 3L; 0L; 1L; 2L; 3L; 0L; 1L ] +Stdlib.List.map_v0 (Stdlib.List.range_v0 -5I 5I) (fun v -> + Stdlib.Int64.mod_v0 (Builtin.unwrap (Stdlib.Int.toInt64 v)) 4L) = [ 3L; 0L; 1L; 2L; 3L; 0L; 1L; 2L; 3L; 0L; 1L ] 15L % 5L = 0L 5L % 0L = error="Cannot evaluate modulus against 0" 5L % -5L = error="Cannot evaluate modulus against a negative number" -Stdlib.List.map_v0 (Stdlib.List.range_v0 -5L 5L) (fun v -> v % 4L) = +Stdlib.List.map_v0 (Stdlib.List.range_v0 -5I 5I) (fun v -> (Builtin.unwrap (Stdlib.Int.toInt64 v)) % 4L) = [ 3L; 0L; 1L; 2L; 3L; 0L; 1L; 2L; 3L; 0L; 1L ] Stdlib.Int64.power_v0 8L 5L = 32768L @@ -206,27 +208,27 @@ Stdlib.Int64.divide_v0 0L 1L = 0L Stdlib.Int64.divide_v0 1L 0L = error="Cannot divide by 0" Stdlib.Int64.divide_v0 (-9223372036854775808L) -1L = error="Encountered out-of-range value for type of Int" -(Stdlib.List.range_v0 1L 5L) +(Stdlib.List.range_v0 1I 5I) |> Stdlib.List.map_v0 (fun x -> Stdlib.Int64.random 1L 2L) |> Stdlib.List.map_v0 (fun x -> (x >= 1L) && (x <= 2L)) = [ true; true; true; true; true ] -(Stdlib.List.range_v0 1L 5L) +(Stdlib.List.range_v0 1I 5I) |> Stdlib.List.map_v0 (fun x -> Stdlib.Int64.random 10L 20L) |> Stdlib.List.map_v0 (fun x -> (x >= 10L) && (x <= 20L)) = [ true; true; true; true; true ] -(Stdlib.List.range_v0 1L 5L) +(Stdlib.List.range_v0 1I 5I) |> Stdlib.List.map_v0 (fun x -> Stdlib.Int64.random 2L 1L) |> Stdlib.List.map_v0 (fun x -> (x >= 1L) && (x <= 2L)) = [ true; true; true; true; true ] -(Stdlib.List.range_v0 1L 5L) +(Stdlib.List.range_v0 1I 5I) |> Stdlib.List.map_v0 (fun x -> Stdlib.Int64.random 20L 10L) |> Stdlib.List.map_v0 (fun x -> (x >= 10L) && (x <= 20L)) = [ true; true; true; true; true ] -((Stdlib.List.range_v0 1L 100L) +((Stdlib.List.range_v0 1I 100I) |> Stdlib.List.map_v0 (fun x -> Stdlib.Int64.random 0L 1L) |> Stdlib.List.unique_v0) = [ 0L; 1L ] -((Stdlib.List.range_v0 1L 100L) +((Stdlib.List.range_v0 1I 100I) |> Stdlib.List.map_v0 (fun x -> Stdlib.Int64.random 0L 2L) |> Stdlib.List.unique_v0) = [ 0L; 1L; 2L ] diff --git a/backend/testfiles/execution/stdlib/ints/int8.dark b/backend/testfiles/execution/stdlib/ints/int8.dark index fd2ef226a2..ed2c898e55 100644 --- a/backend/testfiles/execution/stdlib/ints/int8.dark +++ b/backend/testfiles/execution/stdlib/ints/int8.dark @@ -124,34 +124,34 @@ Stdlib.Int8.mod_v0 -128y 53y = 31y Stdlib.Int8.mod_v0 127y 3y = 1y Stdlib.Int8.mod_v0 5y 0y = error="Cannot evaluate modulus against 0" Stdlib.Int8.mod_v0 5y -5y = error="Cannot evaluate modulus against a negative number" -(Stdlib.List.range_v0 1L 5L) +(Stdlib.List.range_v0 1I 5I) |> Stdlib.List.map_v0 (fun x -> Stdlib.Int8.random 1y 2y) |> Stdlib.List.map_v0 (fun x -> (Stdlib.Int8.greaterThanOrEqualTo x 1y) && (Stdlib.Int8.lessThanOrEqualTo x 2y)) = [ true; true; true; true; true ] -(Stdlib.List.range_v0 1L 5L) +(Stdlib.List.range_v0 1I 5I) |> Stdlib.List.map_v0 (fun x -> Stdlib.Int8.random 10y 20y) |> Stdlib.List.map_v0 (fun x -> (Stdlib.Int8.greaterThanOrEqualTo x 10y) && (Stdlib.Int8.lessThanOrEqualTo x 20y)) = [ true; true; true; true; true ] -(Stdlib.List.range_v0 1L 5L) +(Stdlib.List.range_v0 1I 5I) |> Stdlib.List.map_v0 (fun x -> Stdlib.Int8.random 2y 1y) |> Stdlib.List.map_v0 (fun x -> (Stdlib.Int8.greaterThanOrEqualTo x 1y) && (Stdlib.Int8.lessThanOrEqualTo x 2y)) = [ true; true; true; true; true ] -(Stdlib.List.range_v0 1L 5L) +(Stdlib.List.range_v0 1I 5I) |> Stdlib.List.map_v0 (fun x -> Stdlib.Int8.random 20y 10y) |> Stdlib.List.map_v0 (fun x -> (Stdlib.Int8.greaterThanOrEqualTo x 10y) && (Stdlib.Int8.lessThanOrEqualTo x 20y)) = [ true; true; true; true; true ] -((Stdlib.List.range_v0 1L 100L) +((Stdlib.List.range_v0 1I 100I) |> Stdlib.List.map_v0 (fun x -> Stdlib.Int8.random 0y 1y) |> Stdlib.List.unique_v0) = [ 0y; 1y ] -((Stdlib.List.range_v0 1L 100L) +((Stdlib.List.range_v0 1I 100I) |> Stdlib.List.map_v0 (fun x -> Stdlib.Int8.random 0y 2y) |> Stdlib.List.unique_v0) = [ 0y; 1y; 2y ] diff --git a/backend/testfiles/execution/stdlib/ints/uint16.dark b/backend/testfiles/execution/stdlib/ints/uint16.dark index ea57f603b4..53270da701 100644 --- a/backend/testfiles/execution/stdlib/ints/uint16.dark +++ b/backend/testfiles/execution/stdlib/ints/uint16.dark @@ -91,35 +91,35 @@ Stdlib.UInt16.mod_v0 32768us 53us = 14us Stdlib.UInt16.mod_v0 65535us 3us = 0us Stdlib.UInt16.mod_v0 5us 0us = error="Cannot evaluate modulus against 0" -(Stdlib.List.range_v0 1L 5L) +(Stdlib.List.range_v0 1I 5I) |> Stdlib.List.map_v0 (fun x -> Stdlib.UInt16.random 1us 2us) |> Stdlib.List.map_v0 (fun x -> (Stdlib.UInt16.greaterThanOrEqualTo x 1us) && (Stdlib.UInt16.lessThanOrEqualTo x 2us)) = [ true; true; true; true; true ] -(Stdlib.List.range_v0 1L 5L) +(Stdlib.List.range_v0 1I 5I) |> Stdlib.List.map_v0 (fun x -> Stdlib.UInt16.random 10us 20us) |> Stdlib.List.map_v0 (fun x -> (Stdlib.UInt16.greaterThanOrEqualTo x 10us) && (Stdlib.UInt16.lessThanOrEqualTo x 20us)) = [ true; true; true; true; true ] -(Stdlib.List.range_v0 1L 5L) +(Stdlib.List.range_v0 1I 5I) |> Stdlib.List.map_v0 (fun x -> Stdlib.UInt16.random 2us 1us) |> Stdlib.List.map_v0 (fun x -> (Stdlib.UInt16.greaterThanOrEqualTo x 1us) && (Stdlib.UInt16.lessThanOrEqualTo x 2us)) = [ true; true; true; true; true ] -(Stdlib.List.range_v0 1L 5L) +(Stdlib.List.range_v0 1I 5I) |> Stdlib.List.map_v0 (fun x -> Stdlib.UInt16.random 20us 10us) |> Stdlib.List.map_v0 (fun x -> (Stdlib.UInt16.greaterThanOrEqualTo x 10us) && (Stdlib.UInt16.lessThanOrEqualTo x 20us)) = [ true; true; true; true; true ] -((Stdlib.List.range_v0 1L 100L) +((Stdlib.List.range_v0 1I 100I) |> Stdlib.List.map_v0 (fun x -> Stdlib.UInt16.random 0us 1us) |> Stdlib.List.unique_v0) = [ 0us; 1us ] -((Stdlib.List.range_v0 1L 100L) +((Stdlib.List.range_v0 1I 100I) |> Stdlib.List.map_v0 (fun x -> Stdlib.UInt16.random 0us 2us) |> Stdlib.List.unique_v0) = [ 0us; 1us; 2us ] diff --git a/backend/testfiles/execution/stdlib/ints/uint32.dark b/backend/testfiles/execution/stdlib/ints/uint32.dark index 90a69e8129..436ed36f16 100644 --- a/backend/testfiles/execution/stdlib/ints/uint32.dark +++ b/backend/testfiles/execution/stdlib/ints/uint32.dark @@ -90,35 +90,35 @@ Stdlib.UInt32.mod_v0 32768ul 53ul = 14ul Stdlib.UInt32.mod_v0 4294967295ul 3ul = 0ul Stdlib.UInt32.mod_v0 5ul 0ul = error="Cannot evaluate modulus against 0" -(Stdlib.List.range_v0 1L 5L) +(Stdlib.List.range_v0 1I 5I) |> Stdlib.List.map_v0 (fun x -> Stdlib.UInt32.random 1ul 2ul) |> Stdlib.List.map_v0 (fun x -> (Stdlib.UInt32.greaterThanOrEqualTo x 1ul) && (Stdlib.UInt32.lessThanOrEqualTo x 2ul)) = [ true; true; true; true; true ] -(Stdlib.List.range_v0 1L 5L) +(Stdlib.List.range_v0 1I 5I) |> Stdlib.List.map_v0 (fun x -> Stdlib.UInt32.random 10ul 20ul) |> Stdlib.List.map_v0 (fun x -> (Stdlib.UInt32.greaterThanOrEqualTo x 10ul) && (Stdlib.UInt32.lessThanOrEqualTo x 20ul)) = [ true; true; true; true; true ] -(Stdlib.List.range_v0 1L 5L) +(Stdlib.List.range_v0 1I 5I) |> Stdlib.List.map_v0 (fun x -> Stdlib.UInt32.random 2ul 1ul) |> Stdlib.List.map_v0 (fun x -> (Stdlib.UInt32.greaterThanOrEqualTo x 1ul) && (Stdlib.UInt32.lessThanOrEqualTo x 2ul)) = [ true; true; true; true; true ] -(Stdlib.List.range_v0 1L 5L) +(Stdlib.List.range_v0 1I 5I) |> Stdlib.List.map_v0 (fun x -> Stdlib.UInt32.random 20ul 10ul) |> Stdlib.List.map_v0 (fun x -> (Stdlib.UInt32.greaterThanOrEqualTo x 10ul) && (Stdlib.UInt32.lessThanOrEqualTo x 20ul)) = [ true; true; true; true; true ] -((Stdlib.List.range_v0 1L 100L) +((Stdlib.List.range_v0 1I 100I) |> Stdlib.List.map_v0 (fun x -> Stdlib.UInt32.random 0ul 1ul) |> Stdlib.List.unique_v0) = [ 0ul; 1ul ] -((Stdlib.List.range_v0 1L 100L) +((Stdlib.List.range_v0 1I 100I) |> Stdlib.List.map_v0 (fun x -> Stdlib.UInt32.random 0ul 2ul) |> Stdlib.List.unique_v0) = [ 0ul; 1ul; 2ul ] diff --git a/backend/testfiles/execution/stdlib/ints/uint64.dark b/backend/testfiles/execution/stdlib/ints/uint64.dark index 0965c170d4..3613391a24 100644 --- a/backend/testfiles/execution/stdlib/ints/uint64.dark +++ b/backend/testfiles/execution/stdlib/ints/uint64.dark @@ -79,35 +79,35 @@ Stdlib.UInt64.divide_v0 17UL 3UL = 5UL Stdlib.UInt64.divide_v0 0UL 1UL = 0UL Stdlib.UInt64.divide_v0 1UL 0UL = error="Cannot divide by 0" -(Stdlib.List.range_v0 1L 5L) +(Stdlib.List.range_v0 1I 5I) |> Stdlib.List.map_v0 (fun x -> Stdlib.UInt64.random 1UL 2UL) |> Stdlib.List.map_v0 (fun x -> (Builtin.uint64GreaterThanOrEqualTo x 1UL) && (Builtin.uint64LessThanOrEqualTo x 2UL)) = [ true; true; true; true; true ] -(Stdlib.List.range_v0 1L 5L) +(Stdlib.List.range_v0 1I 5I) |> Stdlib.List.map_v0 (fun x -> Stdlib.UInt64.random 10UL 20UL) |> Stdlib.List.map_v0 (fun x -> (Builtin.uint64GreaterThanOrEqualTo x 10UL) && (Builtin.uint64LessThanOrEqualTo x 20UL)) = [ true; true; true; true; true ] -(Stdlib.List.range_v0 1L 5L) +(Stdlib.List.range_v0 1I 5I) |> Stdlib.List.map_v0 (fun x -> Stdlib.UInt64.random 2UL 1UL) |> Stdlib.List.map_v0 (fun x -> (Builtin.uint64GreaterThanOrEqualTo x 1UL) && (Builtin.uint64LessThanOrEqualTo x 2UL)) = [ true; true; true; true; true ] -(Stdlib.List.range_v0 1L 5L) +(Stdlib.List.range_v0 1I 5I) |> Stdlib.List.map_v0 (fun x -> Stdlib.UInt64.random 20UL 10UL) |> Stdlib.List.map_v0 (fun x -> (Builtin.uint64GreaterThanOrEqualTo x 10UL) && (Builtin.uint64LessThanOrEqualTo x 20UL)) = [ true; true; true; true; true ] -((Stdlib.List.range_v0 1L 100L) +((Stdlib.List.range_v0 1I 100I) |> Stdlib.List.map_v0 (fun x -> Stdlib.UInt64.random 0UL 1UL) |> Stdlib.List.unique_v0) = [ 0UL; 1UL ] -((Stdlib.List.range_v0 1L 100L) +((Stdlib.List.range_v0 1I 100I) |> Stdlib.List.map_v0 (fun x -> Stdlib.UInt64.random 0UL 2UL) |> Stdlib.List.unique_v0) = [ 0UL; 1UL; 2UL ] diff --git a/backend/testfiles/execution/stdlib/ints/uint8.dark b/backend/testfiles/execution/stdlib/ints/uint8.dark index dda3a33be2..f32f5b7a74 100644 --- a/backend/testfiles/execution/stdlib/ints/uint8.dark +++ b/backend/testfiles/execution/stdlib/ints/uint8.dark @@ -91,35 +91,35 @@ Stdlib.UInt8.mod_v0 128uy 53uy = 22uy Stdlib.UInt8.mod_v0 255uy 3uy = 0uy Stdlib.UInt8.mod_v0 5uy 0uy = error="Cannot evaluate modulus against 0" -(Stdlib.List.range_v0 1L 5L) +(Stdlib.List.range_v0 1I 5I) |> Stdlib.List.map_v0 (fun x -> Stdlib.UInt8.random 1uy 2uy) |> Stdlib.List.map_v0 (fun x -> (Stdlib.UInt8.greaterThanOrEqualTo x 1uy) && (Stdlib.UInt8.lessThanOrEqualTo x 2uy)) = [ true; true; true; true; true ] -(Stdlib.List.range_v0 1L 5L) +(Stdlib.List.range_v0 1I 5I) |> Stdlib.List.map_v0 (fun x -> Stdlib.UInt8.random 10uy 20uy) |> Stdlib.List.map_v0 (fun x -> (Stdlib.UInt8.greaterThanOrEqualTo x 10uy) && (Stdlib.UInt8.lessThanOrEqualTo x 20uy)) = [ true; true; true; true; true ] -(Stdlib.List.range_v0 1L 5L) +(Stdlib.List.range_v0 1I 5I) |> Stdlib.List.map_v0 (fun x -> Stdlib.UInt8.random 2uy 1uy) |> Stdlib.List.map_v0 (fun x -> (Stdlib.UInt8.greaterThanOrEqualTo x 1uy) && (Stdlib.UInt8.lessThanOrEqualTo x 2uy)) = [ true; true; true; true; true ] -(Stdlib.List.range_v0 1L 5L) +(Stdlib.List.range_v0 1I 5I) |> Stdlib.List.map_v0 (fun x -> Stdlib.UInt8.random 20uy 10uy) |> Stdlib.List.map_v0 (fun x -> (Stdlib.UInt8.greaterThanOrEqualTo x 10uy) && (Stdlib.UInt8.lessThanOrEqualTo x 20uy)) = [ true; true; true; true; true ] -((Stdlib.List.range_v0 1L 100L) +((Stdlib.List.range_v0 1I 100I) |> Stdlib.List.map_v0 (fun x -> Stdlib.UInt8.random 0uy 1uy) |> Stdlib.List.unique_v0) = [ 0uy; 1uy ] -((Stdlib.List.range_v0 1L 100L) +((Stdlib.List.range_v0 1I 100I) |> Stdlib.List.map_v0 (fun x -> Stdlib.UInt8.random 0uy 2uy) |> Stdlib.List.unique_v0) = [ 0uy; 1uy; 2uy ] diff --git a/backend/testfiles/execution/stdlib/json.dark b/backend/testfiles/execution/stdlib/json.dark index 130cbf43b4..19e2be0f70 100644 --- a/backend/testfiles/execution/stdlib/json.dark +++ b/backend/testfiles/execution/stdlib/json.dark @@ -787,11 +787,11 @@ module String = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor." - Stdlib.Json.serialize (Stdlib.String.repeat_v0 "a" 100L) = "\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"" + Stdlib.Json.serialize (Stdlib.String.repeat_v0 "a" 100I) = "\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"" Stdlib.Json.parse "\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"" = Result - .Ok(Stdlib.String.repeat_v0 "a" 100L) + .Ok(Stdlib.String.repeat_v0 "a" 100I) module DateTime = diff --git a/backend/testfiles/execution/stdlib/list.dark b/backend/testfiles/execution/stdlib/list.dark index 707a68eb7b..22d5f010e9 100644 --- a/backend/testfiles/execution/stdlib/list.dark +++ b/backend/testfiles/execution/stdlib/list.dark @@ -2,8 +2,8 @@ Stdlib.List.empty_v0 = [] Stdlib.List.singleton_v0 1L = [ 1L ] -Stdlib.List.length_v0 [ 1L; 2L; 3L ] = 3L -Stdlib.List.length_v0 [] = 0L +Stdlib.List.length_v0 [ 1L; 2L; 3L ] = 3I +Stdlib.List.length_v0 [] = 0I Stdlib.List.isEmpty_v0 [ 1L ] = false Stdlib.List.isEmpty_v0 [] = true @@ -36,19 +36,19 @@ Stdlib.List.any_v0 [ 4L; 5L ] (fun item -> item < 3L) = false Stdlib.List.any_v0 [ 4L; 1L ] (fun item -> item < 3L) = true -Stdlib.List.drop_v0 [ "a"; "b"; "c"; "d" ] -3L = [ "a"; "b"; "c"; "d" ] -Stdlib.List.drop_v0 [ "a"; "b"; "c"; "d" ] 3L = [ "d" ] -Stdlib.List.drop_v0 [ 1L; 2L; 3L; 4L ] -1L = [ 1L; 2L; 3L; 4L ] -Stdlib.List.drop_v0 [ 1L; 2L; 3L; 4L ] 0L = [ 1L; 2L; 3L; 4L ] -Stdlib.List.drop_v0 [ 1L; 2L; 3L; 4L ] 440737095L = [] -Stdlib.List.drop_v0 [ 1L; 2L; 3L; 4L ] 1184467440737095L = [] -Stdlib.List.drop_v0 [ 1L; 2L; 3L; 4L ] 2L = [ 3L; 4L ] -Stdlib.List.drop_v0 [ 1L; 2L; 3L; 4L ] 4L = [] -Stdlib.List.drop_v0 [ 1L; 2L; 3L; 4L ] 5L = [] -Stdlib.List.drop_v0 [ 3L; 3L; 3L ] 0L = [ 3L; 3L; 3L ] -Stdlib.List.drop_v0 [ 5L; 4L; 3L; 2L; 1L ] 5L = [] -Stdlib.List.drop_v0 [ 5L ] 4L = [] -Stdlib.List.drop_v0 [] 4L = [] +Stdlib.List.drop_v0 [ "a"; "b"; "c"; "d" ] -3I = [ "a"; "b"; "c"; "d" ] +Stdlib.List.drop_v0 [ "a"; "b"; "c"; "d" ] 3I = [ "d" ] +Stdlib.List.drop_v0 [ 1L; 2L; 3L; 4L ] -1I = [ 1L; 2L; 3L; 4L ] +Stdlib.List.drop_v0 [ 1L; 2L; 3L; 4L ] 0I = [ 1L; 2L; 3L; 4L ] +Stdlib.List.drop_v0 [ 1L; 2L; 3L; 4L ] 440737095I = [] +Stdlib.List.drop_v0 [ 1L; 2L; 3L; 4L ] 1184467440737095I = [] +Stdlib.List.drop_v0 [ 1L; 2L; 3L; 4L ] 2I = [ 3L; 4L ] +Stdlib.List.drop_v0 [ 1L; 2L; 3L; 4L ] 4I = [] +Stdlib.List.drop_v0 [ 1L; 2L; 3L; 4L ] 5I = [] +Stdlib.List.drop_v0 [ 3L; 3L; 3L ] 0I = [ 3L; 3L; 3L ] +Stdlib.List.drop_v0 [ 5L; 4L; 3L; 2L; 1L ] 5I = [] +Stdlib.List.drop_v0 [ 5L ] 4I = [] +Stdlib.List.drop_v0 [] 4I = [] Stdlib.List.dropWhile_v0 [ 1L; 2L; 3L; 4L ] (fun item -> 0L - 1L) = error="Encountered a condition that must be a Bool, but got an Int64 (-1)" Stdlib.List.dropWhile_v0 [ 1L; 2L; 3L; 4L ] (fun item -> item < 3L) = [ 3L; 4L ] @@ -116,12 +116,12 @@ Stdlib.List.findFirst [ 0L; 5L; -6L; -10L ] (fun x -> x < 0L) = Stdlib.Option.Op Stdlib.List.findFirst [ 1L; -33L; 3L; -2L; 12L ] (fun x -> (x < 0L && x % 2L == 0L)) = Stdlib.Option.Option.Some -2L module FindFirstIndex = - Stdlib.List.findFirstIndex [1L; 2L; 3L] (fun x -> x == 2L) = Stdlib.Option.Option.Some 1L + Stdlib.List.findFirstIndex [1L; 2L; 3L] (fun x -> x == 2L) = Stdlib.Option.Option.Some 1I Stdlib.List.findFirstIndex [1L; 2L; 3L] (fun x -> x > 5L) = Stdlib.Option.Option.None Stdlib.List.findFirstIndex [] (fun _x -> true) = Stdlib.Option.Option.None - Stdlib.List.findFirstIndex [10L; 20L; 30L; 20L] (fun x -> x == 20L) = Stdlib.Option.Option.Some 1L - Stdlib.List.findFirstIndex ["a"; "b"; "c"] (fun x -> x == "c") = Stdlib.Option.Option.Some 2L - Stdlib.List.findFirstIndex [1L; 2L; 3L] (fun x -> x == 1L) = Stdlib.Option.Option.Some 0L + Stdlib.List.findFirstIndex [10L; 20L; 30L; 20L] (fun x -> x == 20L) = Stdlib.Option.Option.Some 1I + Stdlib.List.findFirstIndex ["a"; "b"; "c"] (fun x -> x == "c") = Stdlib.Option.Option.Some 2I + Stdlib.List.findFirstIndex [1L; 2L; 3L] (fun x -> x == 1L) = Stdlib.Option.Option.Some 0I module Flatten = Stdlib.List.flatten_v0 [ [ 1L ]; [ 2L ]; [ 3L ] ] = [ 1L; 2L; 3L ] @@ -141,15 +141,15 @@ module Fold = Stdlib.List.pushBack_v0 accum (curr + 1L)) = [ 2L; 3L; 4L; 5L; 6L ] module GetAt = - Stdlib.List.getAt [ "a"; "b"; "c"; "d" ] -1L = Stdlib.Option.Option.None - Stdlib.List.getAt [ 0L ] 1L = Stdlib.Option.Option.None - Stdlib.List.getAt [] 1L = Stdlib.Option.Option.None - Stdlib.List.getAt [ 1L; 2L; 3L; 4L ] 6018427387902L = Stdlib.Option.Option.None + Stdlib.List.getAt [ "a"; "b"; "c"; "d" ] -1I = Stdlib.Option.Option.None + Stdlib.List.getAt [ 0L ] 1I = Stdlib.Option.Option.None + Stdlib.List.getAt [] 1I = Stdlib.Option.Option.None + Stdlib.List.getAt [ 1L; 2L; 3L; 4L ] 6018427387902I = Stdlib.Option.Option.None - Stdlib.List.getAt [ 1L; 2L; 3L; 4L ] 0L = Stdlib.Option.Option.Some 1L + Stdlib.List.getAt [ 1L; 2L; 3L; 4L ] 0I = Stdlib.Option.Option.Some 1L - Stdlib.List.getAt [ 3L; 3L; 3L ] -5L = Stdlib.Option.Option.None - Stdlib.List.getAt [ 3L; 3L; 3L ] 2147483648L = Stdlib.Option.Option.None + Stdlib.List.getAt [ 3L; 3L; 3L ] -5I = Stdlib.Option.Option.None + Stdlib.List.getAt [ 3L; 3L; 3L ] 2147483648I = Stdlib.Option.Option.None module Head = Stdlib.List.head [ 1L; 2L; 3L ] = Stdlib.Option.Option.Some 1L @@ -158,9 +158,9 @@ module Head = Stdlib.List.head [] = Stdlib.Option.Option.None module IndexedMap = - Stdlib.List.indexedMap_v0 [ 3L; 2L; 1L ] (fun i v -> v - i) = [ 3L; 1L; -1L ] - Stdlib.List.indexedMap_v0 [] (fun i v -> v - i) = [] - Stdlib.List.indexedMap_v0 [ 3L; 2L; 1L ] (fun i v -> i) = [ 0L; 1L; 2L ] + Stdlib.List.indexedMap_v0 [ 3L; 2L; 1L ] (fun i v -> v - (Builtin.unwrap (Stdlib.Int.toInt64 i))) = [ 3L; 1L; -1L ] + Stdlib.List.indexedMap_v0 [] (fun i v -> v - (Builtin.unwrap (Stdlib.Int.toInt64 i))) = [] + Stdlib.List.indexedMap_v0 [ 3L; 2L; 1L ] (fun i v -> i) = [ 0I; 1I; 2I ] module Interleave = Stdlib.List.interleave_v0 [ 1L; 2L; 3L ] [ 4L; 5L; 6L ] = [ 1L; 4L; 2L; 5L; 3L; 6L ] @@ -185,7 +185,7 @@ module Last = Stdlib.List.last [] = Stdlib.Option.Option.None module Map = - Stdlib.List.map_v0 (Stdlib.List.range_v0 1L 5L) (fun x -> x + 1L) = [ 2L; 3L; 4L; 5L; 6L ] + Stdlib.List.map_v0 (Stdlib.List.range_v0 1I 5I) (fun x -> x + 1I) = [ 2I; 3I; 4I; 5I; 6I ] Stdlib.List.map_v0 [ 1L; 2L; 3L ] (fun x -> Stdlib.Bool.and_v0 @@ -236,18 +236,18 @@ Stdlib.List.randomElement_v0 [ 1L ] = Stdlib.Option.Option.Some 1L Stdlib.List.randomElement_v0 [] = Stdlib.Option.Option.None Stdlib.List.randomElement_v0 [ Builtin.testRuntimeError "test" ] = error="Uncaught exception: test" -Stdlib.List.range_v0 -1L 0L = [ -1L; 0L ] -Stdlib.List.range_v0 -5L 5L = [ -5L; -4L; -3L; -2L; -1L; 0L; 1L; 2L; 3L; 4L; 5L ] -Stdlib.List.range_v0 5L 0L = [] -Stdlib.List.repeat_v0 0L 1L = Stdlib.Result.Result.Ok [] -Stdlib.List.repeat_v0 1L "a" = Stdlib.Result.Result.Ok [ "a" ] -Stdlib.List.repeat_v0 1L 1L = Stdlib.Result.Result.Ok [ 1L ] -Stdlib.List.repeat_v0 3L 1L = Stdlib.Result.Result.Ok [ 1L; 1L; 1L ] -Stdlib.List.repeat_v0 3L 3L = Stdlib.Result.Result.Ok [ 3L; 3L; 3L ] -Stdlib.List.repeat_v0 5L "a" = Stdlib.Result.Result.Ok [ "a"; "a"; "a"; "a"; "a" ] -Stdlib.List.repeat_v0 -4L "a" = Stdlib.Result.Result.Error "Expected `times` to be positive, but it was `-4`" -Stdlib.List.repeat_v0 3L [ 1L; 2L; 3L ] = Stdlib.Result.Result.Ok [ [ 1L; 2L; 3L ]; [ 1L; 2L; 3L ]; [ 1L; 2L; 3L ] ] -Stdlib.List.repeat_v0 3L [] = Stdlib.Result.Result.Ok [ []; []; [] ] +Stdlib.List.range_v0 -1I 0I = [ -1I; 0I ] +Stdlib.List.range_v0 -5I 5I = [ -5I; -4I; -3I; -2I; -1I; 0I; 1I; 2I; 3I; 4I; 5I ] +Stdlib.List.range_v0 5I 0I = [] +Stdlib.List.repeat_v0 0I 1L = Stdlib.Result.Result.Ok [] +Stdlib.List.repeat_v0 1I "a" = Stdlib.Result.Result.Ok [ "a" ] +Stdlib.List.repeat_v0 1I 1L = Stdlib.Result.Result.Ok [ 1L ] +Stdlib.List.repeat_v0 3I 1L = Stdlib.Result.Result.Ok [ 1L; 1L; 1L ] +Stdlib.List.repeat_v0 3I 3L = Stdlib.Result.Result.Ok [ 3L; 3L; 3L ] +Stdlib.List.repeat_v0 5I "a" = Stdlib.Result.Result.Ok [ "a"; "a"; "a"; "a"; "a" ] +Stdlib.List.repeat_v0 -4I "a" = Stdlib.Result.Result.Error "Expected `times` to be positive, but it was `-4`" +Stdlib.List.repeat_v0 3I [ 1L; 2L; 3L ] = Stdlib.Result.Result.Ok [ [ 1L; 2L; 3L ]; [ 1L; 2L; 3L ]; [ 1L; 2L; 3L ] ] +Stdlib.List.repeat_v0 3I [] = Stdlib.Result.Result.Ok [ []; []; [] ] Stdlib.List.reverse_v0 [ "a"; "b"; "c"; "d" ] = [ "d"; "c"; "b"; "a" ] Stdlib.List.reverse_v0 [ 5L; 4L; 3L; 2L; 1L ] = [ 1L; 2L; 3L; 4L; 5L ] @@ -261,22 +261,22 @@ Stdlib.List.sort_v0 [ 6L; 2L; 8L; 3L ] = [ 2L; 3L; 6L; 8L ] Stdlib.List.sort_v0 [] = [] // CLEANUP: it should be a type error on the function not returning an Int64 -Stdlib.List.sortByComparator_v0 [ 3L; 1L; 2L ] (fun a b -> 0.1) = error="Cannot perform equality check on Float and Int64" -Stdlib.List.sortByComparator_v0 [ 3L; 1L; 2L ] (fun a b -> 3L) = +Stdlib.List.sortByComparator_v0 [ 3L; 1L; 2L ] (fun a b -> 0.1) = error="Cannot perform equality check on Float and Int" +Stdlib.List.sortByComparator_v0 [ 3L; 1L; 2L ] (fun a b -> 3I) = Stdlib.Result.Result.Error "Expected comparator function to return -1, 0, or 1, but it returned 3" // CLEANUP: it should be a type error on the function not returning an Int64 -Stdlib.List.sortByComparator_v0 [ 1L; 2L; 3L ] (fun a b -> "㧑༷釺") = error="Cannot perform equality check on String and Int64" +Stdlib.List.sortByComparator_v0 [ 1L; 2L; 3L ] (fun a b -> "㧑༷釺") = error="Cannot perform equality check on String and Int" Stdlib.List.sortByComparator_v0 [ 3L; 1L; 2L ] (fun a b -> - if Stdlib.Int64.lessThan_v0 a b then -1L else 1L) = Stdlib.Result.Result.Ok + if Stdlib.Int64.lessThan_v0 a b then -1I else 1I) = Stdlib.Result.Result.Ok [ 1L; 2L; 3L ] Stdlib.List.sortByComparator_v0 [] (fun a b -> - if Stdlib.Int64.lessThan_v0 a b then -1L else 1L) = Stdlib.Result.Result.Ok [] + if Stdlib.Int64.lessThan_v0 a b then -1I else 1I) = Stdlib.Result.Result.Ok [] Stdlib.List.sortByComparator_v0 [ 3L; 1L; 2L; 67L; 3L; -1L; 6L; 3L; 5L; 6L; 2L; 5L; 63L; 2L; 3L; 5L; -1L; -1L; -1L ] - (fun a b -> if Stdlib.Int64.lessThan_v0 a b then -1L else 1L) = + (fun a b -> if Stdlib.Int64.lessThan_v0 a b then -1I else 1I) = Stdlib.Result.Result.Ok [ -1L; -1L; -1L; -1L; 1L; 2L; 2L; 2L; 3L; 3L; 3L; 3L; 5L; 5L; 5L; 6L; 6L; 63L; 67L ] // CLEANUP this error message is not ideal in 2 ways: @@ -290,13 +290,13 @@ Stdlib.List.sortByComparator_v0 Stdlib.List.tail_v0 [ 10L; 20L; 30L; 40L ] = Stdlib.Option.Option.Some[ 20L; 30L; 40L ] Stdlib.List.tail_v0 [] = Stdlib.Option.Option.None -Stdlib.List.take_v0 [ "a"; "b"; "c"; "d" ] -1L = [] -Stdlib.List.take_v0 [ "a"; "b"; "c"; "d" ] 2147483648L = [ "a"; "b"; "c"; "d" ] -Stdlib.List.take_v0 [ "a"; "b"; "c"; "d" ] 3L = [ "a"; "b"; "c" ] -Stdlib.List.take_v0 [ 3L; 3L; 3L ] 0L = [] -Stdlib.List.take_v0 [ 5L; 4L; 3L; 2L; 1L ] 5L = [ 5L; 4L; 3L; 2L; 1L ] -Stdlib.List.take_v0 [ 5L ] 4L = [ 5L ] -Stdlib.List.take_v0 [] 4L = [] +Stdlib.List.take_v0 [ "a"; "b"; "c"; "d" ] -1I = [] +Stdlib.List.take_v0 [ "a"; "b"; "c"; "d" ] 2147483648I = [ "a"; "b"; "c"; "d" ] +Stdlib.List.take_v0 [ "a"; "b"; "c"; "d" ] 3I = [ "a"; "b"; "c" ] +Stdlib.List.take_v0 [ 3L; 3L; 3L ] 0I = [] +Stdlib.List.take_v0 [ 5L; 4L; 3L; 2L; 1L ] 5I = [ 5L; 4L; 3L; 2L; 1L ] +Stdlib.List.take_v0 [ 5L ] 4I = [ 5L ] +Stdlib.List.take_v0 [] 4I = [] //TODO: better error message Stdlib.List.takeWhile_v0 [ 1L; 2L; 3L; 4L ] (fun item -> 0L - 1L) = error="Encountered a condition that must be a Bool, but got an Int64 (-1)" @@ -365,13 +365,13 @@ Stdlib.List.dropLast [ 1L; 2L; 3L; 4L; 5L ] = [ 1L; 2L; 3L; 4L ] Stdlib.List.dropLast [ 1L ] = [] Stdlib.List.dropLast [] = [] -Stdlib.List.chunkBySize_v0 [ 1L; 2L; 3L; 4L; 5L ] 2L = Stdlib.Result.Result.Ok [ [ 1L; 2L ]; [ 3L; 4L ]; [ 5L ] ] -Stdlib.List.chunkBySize_v0 [ 1L; 2L; 3L; 4L; 5L; 6L ] 3L = Stdlib.Result.Result.Ok [ [ 1L; 2L; 3L ]; [ 4L; 5L; 6L ] ] -Stdlib.List.chunkBySize_v0 [ 1L; 2L; 3L ] 1L = Stdlib.Result.Result.Ok [ [ 1L ]; [ 2L ]; [ 3L ] ] -Stdlib.List.chunkBySize_v0 [ 1L; 2L ] 3L = Stdlib.Result.Result.Ok [ [ 1L; 2L ] ] -Stdlib.List.chunkBySize_v0 [] 4L = Stdlib.Result.Result.Ok [] -Stdlib.List.chunkBySize_v0 [ 1L; 2L; 3L; 4L ] 0L = Stdlib.Result.Result.Error Stdlib.List.ChunkBySizeError.SizeMustBeGreaterThanZero -Stdlib.List.chunkBySize_v0 [ 1L; 2L; 3L; 4L ] -1L = Stdlib.Result.Result.Error Stdlib.List.ChunkBySizeError.SizeMustBeGreaterThanZero +Stdlib.List.chunkBySize_v0 [ 1L; 2L; 3L; 4L; 5L ] 2I = Stdlib.Result.Result.Ok [ [ 1L; 2L ]; [ 3L; 4L ]; [ 5L ] ] +Stdlib.List.chunkBySize_v0 [ 1L; 2L; 3L; 4L; 5L; 6L ] 3I = Stdlib.Result.Result.Ok [ [ 1L; 2L; 3L ]; [ 4L; 5L; 6L ] ] +Stdlib.List.chunkBySize_v0 [ 1L; 2L; 3L ] 1I = Stdlib.Result.Result.Ok [ [ 1L ]; [ 2L ]; [ 3L ] ] +Stdlib.List.chunkBySize_v0 [ 1L; 2L ] 3I = Stdlib.Result.Result.Ok [ [ 1L; 2L ] ] +Stdlib.List.chunkBySize_v0 [] 4I = Stdlib.Result.Result.Ok [] +Stdlib.List.chunkBySize_v0 [ 1L; 2L; 3L; 4L ] 0I = Stdlib.Result.Result.Error Stdlib.List.ChunkBySizeError.SizeMustBeGreaterThanZero +Stdlib.List.chunkBySize_v0 [ 1L; 2L; 3L; 4L ] -1I = Stdlib.Result.Result.Error Stdlib.List.ChunkBySizeError.SizeMustBeGreaterThanZero Stdlib.List.splitLast [] = Stdlib.Option.Option.None Stdlib.List.splitLast [ 1L ] = Stdlib.Option.Option.Some(([], 1L)) diff --git a/backend/testfiles/execution/stdlib/stream.dark b/backend/testfiles/execution/stdlib/stream.dark index ca66123a42..9a483413fb 100644 --- a/backend/testfiles/execution/stdlib/stream.dark +++ b/backend/testfiles/execution/stdlib/stream.dark @@ -145,4 +145,4 @@ let b2 = Stdlib.Blob.fromString "there" let s = Stdlib.Stream.fromList [ b1; b2 ] let result = Stdlib.Stream.toList s - Stdlib.List.length result) = 2L + Stdlib.List.length result) = 2I diff --git a/backend/testfiles/execution/stdlib/string.dark b/backend/testfiles/execution/stdlib/string.dark index 1c5ddac209..7c5ada33b9 100644 --- a/backend/testfiles/execution/stdlib/string.dark +++ b/backend/testfiles/execution/stdlib/string.dark @@ -40,17 +40,17 @@ module Join = Stdlib.String.join_v0 [ "🧑🏽‍🦰‍"; "🧑🏼‍💻‍‍" ] "" = "🧑🏽‍🦰‍🧑🏼‍💻‍‍" module ToBytes = - Stdlib.List.length (Stdlib.String.toBytes_v0 "🧑🏽‍🦰🧑🏼‍💻🧑🏻‍🍼✋✋🏻✋🏿") = 62L - Stdlib.List.length (Stdlib.String.toBytes_v0 "😄APPLE🍏") = 13L - Stdlib.List.length (Stdlib.String.toBytes_v0 "Είναι προικισμένοι με λογική") = 53L - Stdlib.List.length (Stdlib.String.toBytes_v0 "") = 0L - Stdlib.List.length (Stdlib.String.toBytes_v0 "🧑🏽‍🦰🧑🏼‍💻🧑🏻‍🍼✋✋🏻✋🏿") = 62L - Stdlib.List.length (Stdlib.String.toBytes_v0 "﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽") = 48L - Stdlib.List.length (Stdlib.String.toBytes_v0 "👱👱🏻👱🏼👱🏽👱🏾👱🏿") = 44L - Stdlib.List.length (Stdlib.String.toBytes_v0 "🧟‍♀️🧟‍♂️") = 26L - Stdlib.List.length (Stdlib.String.toBytes_v0 "👨‍❤️‍💋‍👨👩‍👩‍👧‍👦🏳️‍⚧️‍️🇵🇷") = 82L - Stdlib.List.length (Stdlib.String.toBytes_v0 "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇") = 49L - Stdlib.List.length (Stdlib.String.toBytes_v0 "") = 0L + Stdlib.List.length (Stdlib.String.toBytes_v0 "🧑🏽‍🦰🧑🏼‍💻🧑🏻‍🍼✋✋🏻✋🏿") = 62I + Stdlib.List.length (Stdlib.String.toBytes_v0 "😄APPLE🍏") = 13I + Stdlib.List.length (Stdlib.String.toBytes_v0 "Είναι προικισμένοι με λογική") = 53I + Stdlib.List.length (Stdlib.String.toBytes_v0 "") = 0I + Stdlib.List.length (Stdlib.String.toBytes_v0 "🧑🏽‍🦰🧑🏼‍💻🧑🏻‍🍼✋✋🏻✋🏿") = 62I + Stdlib.List.length (Stdlib.String.toBytes_v0 "﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽") = 48I + Stdlib.List.length (Stdlib.String.toBytes_v0 "👱👱🏻👱🏼👱🏽👱🏾👱🏿") = 44I + Stdlib.List.length (Stdlib.String.toBytes_v0 "🧟‍♀️🧟‍♂️") = 26I + Stdlib.List.length (Stdlib.String.toBytes_v0 "👨‍❤️‍💋‍👨👩‍👩‍👧‍👦🏳️‍⚧️‍️🇵🇷") = 82I + Stdlib.List.length (Stdlib.String.toBytes_v0 "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇") = 49I + Stdlib.List.length (Stdlib.String.toBytes_v0 "") = 0I // `Stdlib.String.{fromBytes, fromBytesWithReplacement, toBytes}` still @@ -290,13 +290,13 @@ module Digest = module Random = - (Stdlib.String.random 5L) == (Stdlib.String.random 5L) = false + (Stdlib.String.random 5I) == (Stdlib.String.random 5I) = false - Stdlib.String.length ((Stdlib.String.random 10L) |> Builtin.unwrap) = 10L - Stdlib.String.length ((Stdlib.String.random 5L) |> Builtin.unwrap) = 5L - Stdlib.String.length ((Stdlib.String.random 0L) |> Builtin.unwrap) = 0L + Stdlib.String.length ((Stdlib.String.random 10I) |> Builtin.unwrap) = 10L + Stdlib.String.length ((Stdlib.String.random 5I) |> Builtin.unwrap) = 5L + Stdlib.String.length ((Stdlib.String.random 0I) |> Builtin.unwrap) = 0L - Stdlib.String.random -1L = Stdlib.Result.Result.Error "Expected `length` to be positive, but it was `-1`" + Stdlib.String.random -1I = Stdlib.Result.Result.Error "Expected `length` to be positive, but it was `-1`" module HtmlEscape = diff --git a/packages/darklang/cli/apps/command.dark b/packages/darklang/cli/apps/command.dark index f6685e8277..1ce383b597 100644 --- a/packages/darklang/cli/apps/command.dark +++ b/packages/darklang/cli/apps/command.dark @@ -12,7 +12,7 @@ module Darklang.Cli.Apps.Command // TODO: Log text isn't a reliable source of truth; store structured daemon metadata instead. let daemonPort (slug: String) : Stdlib.Option.Option = let portLines = - (Stdlib.Cli.Daemon.tailLog slug 25L) + (Stdlib.Cli.Daemon.tailLog slug 25I) |> Stdlib.List.filter (fun l -> Stdlib.String.contains l "localhost:") match Stdlib.List.last portLines with @@ -97,7 +97,7 @@ let inspect (state: Cli.AppState) (slug: String) : Cli.AppState = match app.target with | Daemon _ -> Stdlib.printLine $" status: {Stdlib.Cli.Daemon.statusLine slug}" - let logs = Stdlib.Cli.Daemon.tailLog slug 5L + let logs = Stdlib.Cli.Daemon.tailLog slug 5I if Stdlib.List.isEmpty logs then () else @@ -203,7 +203,7 @@ let execute (state: Cli.AppState) (args: List) : Cli.AppState = state | [ "logs"; slug ] -> - let lines = Stdlib.Cli.Daemon.tailLog slug 20L + let lines = Stdlib.Cli.Daemon.tailLog slug 20I if Stdlib.List.isEmpty lines then Stdlib.printLine (Colors.dimText $"no logs for '{slug}' (has it run?)") diff --git a/packages/darklang/cli/apps/editor.dark b/packages/darklang/cli/apps/editor.dark index f8e04ec968..8727ca7385 100644 --- a/packages/darklang/cli/apps/editor.dark +++ b/packages/darklang/cli/apps/editor.dark @@ -21,7 +21,7 @@ type Action = let selectedApp (state: State) : Stdlib.Option.Option = - Stdlib.List.getAt state.apps state.selected + Stdlib.List.getAt state.apps (Stdlib.Int.fromInt64 state.selected) // ── rendering ── @@ -100,7 +100,7 @@ let render (state: State) : Unit = if Stdlib.List.isEmpty state.apps then Stdlib.printLine (Colors.dimText " No apps in the catalog.") else - let indexed = state.apps |> Stdlib.List.indexedMap (fun i a -> (i, a)) + let indexed = state.apps |> Stdlib.List.indexedMap (fun i a -> (Builtin.unwrap (Stdlib.Int.toInt64 i), a)) let daemons = indexed @@ -129,7 +129,7 @@ let render (state: State) : Unit = match app.target with | Daemon _ -> - let logs = Stdlib.Cli.Daemon.tailLog app.slug 5L + let logs = Stdlib.Cli.Daemon.tailLog app.slug 5I if Stdlib.List.isEmpty logs then () else @@ -225,7 +225,7 @@ let handleKey (_modifiers: Stdlib.Cli.Stdin.Modifiers.Modifiers) (keyChar: Stdlib.Option.Option) : Action = - let count = Stdlib.List.length state.apps + let count = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length state.apps))) match key with | Escape -> Action.Exit state | UpArrow -> diff --git a/packages/darklang/cli/apps/views/ai-chats.dark b/packages/darklang/cli/apps/views/ai-chats.dark index ff285d2b2b..0729f2e1bc 100644 --- a/packages/darklang/cli/apps/views/ai-chats.dark +++ b/packages/darklang/cli/apps/views/ai-chats.dark @@ -80,18 +80,18 @@ let statusBadge (status: String) : String = let hr () : String = let cols = Darklang.Cli.Terminal.getWidth () - Darklang.Cli.Colors.dimText (Stdlib.String.repeat "─" cols) + Darklang.Cli.Colors.dimText (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 cols)) let thinHr () : String = let cols = Darklang.Cli.Terminal.getWidth () - Darklang.Cli.Colors.dimText (Stdlib.String.repeat "╌" cols) + Darklang.Cli.Colors.dimText (Stdlib.String.repeat "╌" (Stdlib.Int.fromInt64 cols)) let padRight (s: String) (width: Int64) : String = let len = Stdlib.String.length s if len >= width then Stdlib.String.slice s 0L width else - s ++ (Stdlib.String.repeat " " (width - len)) + s ++ (Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (width - len))) let renderThread (thread: Thread) : Unit = let idStr = Darklang.Cli.Colors.colorize (Darklang.Cli.Colors.bold ++ Darklang.Cli.Colors.cyan) ("#" ++ Stdlib.Int64.toString thread.id) @@ -141,7 +141,7 @@ let render () : Unit = (" " ++ Darklang.Cli.Colors.boldText "dark ai chats" ++ " " - ++ Darklang.Cli.Colors.dimText ("— " ++ Stdlib.Int64.toString threadCount ++ " threads • " ++ Stdlib.Int64.toString runningCount ++ " running • " ++ Stdlib.Int64.toString reviewCount ++ " awaiting review")) + ++ Darklang.Cli.Colors.dimText ("— " ++ Stdlib.Int.toString threadCount ++ " threads • " ++ Stdlib.Int.toString runningCount ++ " running • " ++ Stdlib.Int.toString reviewCount ++ " awaiting review")) Stdlib.printLine "" Stdlib.printLine (hr ()) diff --git a/packages/darklang/cli/apps/views/app.dark b/packages/darklang/cli/apps/views/app.dark index cc259db1eb..7d80c7540a 100644 --- a/packages/darklang/cli/apps/views/app.dark +++ b/packages/darklang/cli/apps/views/app.dark @@ -20,14 +20,14 @@ let renderViewList (state: State) (selected: Int64) : Unit = ++ " " ++ Darklang.Cli.Colors.boldText "Views" ++ " " - ++ Darklang.Cli.Colors.dimText ("— " ++ Stdlib.Int64.toString (Stdlib.List.length state.views) ++ " available") + ++ Darklang.Cli.Colors.dimText ("— " ++ Stdlib.Int.toString (Stdlib.List.length state.views) ++ " available") ++ "\n\n" - ++ Darklang.Cli.Colors.dimText (Stdlib.String.repeat "─" termWidth) + ++ Darklang.Cli.Colors.dimText (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 termWidth)) ++ "\n\n" let viewLines = state.views - |> Stdlib.List.indexedMap (fun idx view -> (idx, view)) + |> Stdlib.List.indexedMap (fun idx view -> (Builtin.unwrap (Stdlib.Int.toInt64 idx), view)) |> Stdlib.List.map (fun pair -> let (idx, view) = pair let isSelected = idx == selected @@ -48,7 +48,7 @@ let renderViewList (state: State) (selected: Int64) : Unit = let footer = "\n" - ++ Darklang.Cli.Colors.dimText (Stdlib.String.repeat "─" termWidth) + ++ Darklang.Cli.Colors.dimText (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 termWidth)) ++ "\n\n" ++ " " ++ Darklang.Cli.Colors.dimText "↑↓" @@ -67,7 +67,7 @@ let renderViewDisplay (state: State) (viewIndex: Int64) : Unit = // Hide cursor + clear in one shot, then render view Stdlib.print ("\u001b[?25l" ++ Darklang.Cli.Terminal.Display.clearScreen) - match Stdlib.List.getAt state.views viewIndex with + match Stdlib.List.getAt state.views (Stdlib.Int.fromInt64 viewIndex) with | Some view -> view.render () | None -> Stdlib.printLine (Darklang.Cli.Colors.error "View not found") @@ -99,7 +99,7 @@ let handleKey : Action = match state.screen with | ViewList selected -> - let viewCount = Stdlib.List.length state.views + let viewCount = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length state.views))) match key with | Escape -> Action.Exit state | UpArrow -> diff --git a/packages/darklang/cli/apps/views/package-stats.dark b/packages/darklang/cli/apps/views/package-stats.dark index fb8b193007..948a1b0ce3 100644 --- a/packages/darklang/cli/apps/views/package-stats.dark +++ b/packages/darklang/cli/apps/views/package-stats.dark @@ -23,21 +23,21 @@ let padRight (s: String) (width: Int64) : String = if len >= width then Stdlib.String.slice s 0L width else - s ++ (Stdlib.String.repeat " " (width - len)) + s ++ (Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (width - len))) let padLeft (s: String) (width: Int64) : String = let len = Stdlib.String.length s if len >= width then Stdlib.String.slice s 0L width else - (Stdlib.String.repeat " " (width - len)) ++ s + (Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (width - len))) ++ s let bar (value: Int64) (maxVal: Int64) (width: Int64) (color: String) : String = let barLen = if maxVal == 0L then 0L else Stdlib.Int64.divide (value * width) maxVal - let filled = Stdlib.String.repeat "█" barLen - let empty = Stdlib.String.repeat "░" (width - barLen) + let filled = Stdlib.String.repeat "█" (Stdlib.Int.fromInt64 barLen) + let empty = Stdlib.String.repeat "░" (Stdlib.Int.fromInt64 (width - barLen)) (Darklang.Cli.Colors.colorize color filled) ++ (Darklang.Cli.Colors.dimText empty) @@ -55,7 +55,7 @@ let render () : Unit = (" " ++ Darklang.Cli.Colors.boldText "Package Statistics" ++ " " - ++ Darklang.Cli.Colors.dimText ("— " ++ Stdlib.Int64.toString (Stdlib.List.length stats) ++ " top-level modules")) + ++ Darklang.Cli.Colors.dimText ("— " ++ Stdlib.Int.toString (Stdlib.List.length stats) ++ " top-level modules")) Stdlib.printLine "" // Summary cards @@ -73,7 +73,7 @@ let render () : Unit = // Table header let termCols = Darklang.Cli.Terminal.getWidth () - Stdlib.printLine (Darklang.Cli.Colors.dimText (Stdlib.String.repeat "─" termCols)) + Stdlib.printLine (Darklang.Cli.Colors.dimText (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 termCols))) let boldDim = Darklang.Cli.Colors.bold ++ Darklang.Cli.Colors.dim let headerLine = @@ -90,7 +90,7 @@ let render () : Unit = ++ " " ++ Darklang.Cli.Colors.colorize boldDim "FUNCTIONS" Stdlib.printLine headerLine - Stdlib.printLine (Darklang.Cli.Colors.dimText (Stdlib.String.repeat "─" termCols)) + Stdlib.printLine (Darklang.Cli.Colors.dimText (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 termCols))) let maxFns = stats @@ -114,7 +114,7 @@ let render () : Unit = Stdlib.printLine (" " ++ nameStr ++ " " ++ fnStr ++ " " ++ typeStr ++ " " ++ valStr ++ " " ++ modStr ++ " " ++ barStr)) - Stdlib.printLine (Darklang.Cli.Colors.dimText (Stdlib.String.repeat "─" termCols)) + Stdlib.printLine (Darklang.Cli.Colors.dimText (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 termCols))) Stdlib.printLine "" // Footer diff --git a/packages/darklang/cli/builtins.dark b/packages/darklang/cli/builtins.dark index 34ae75ebac..4356ca984f 100644 --- a/packages/darklang/cli/builtins.dark +++ b/packages/darklang/cli/builtins.dark @@ -202,13 +202,13 @@ let execute (state: AppState) (args: List): AppState = let totalCount = filteredGroups |> Stdlib.List.map (fun pair -> Stdlib.List.length (Stdlib.Tuple2.second pair)) - |> Stdlib.List.fold 0L (fun acc n -> acc + n) + |> Stdlib.List.fold 0I (fun acc n -> acc + n) let summary = match filter with - | None -> $"Total: {Stdlib.Int64.toString totalCount} builtin functions" + | None -> $"Total: {Stdlib.Int.toString totalCount} builtin functions" | Some pattern -> - $"Showing {Stdlib.Int64.toString totalCount} functions matching '{pattern}'" + $"Showing {Stdlib.Int.toString totalCount} functions matching '{pattern}'" [ "" Colors.hint summary ] diff --git a/packages/darklang/cli/caps/accessEditor.dark b/packages/darklang/cli/caps/accessEditor.dark index ef8fa4a91b..b4d3d9ad10 100644 --- a/packages/darklang/cli/caps/accessEditor.dark +++ b/packages/darklang/cli/caps/accessEditor.dark @@ -29,7 +29,7 @@ let forDomain (domain: String) : State = field = Field.AccessField } let indexOfAccess (a: String) : Int64 = - let indexed = Stdlib.List.indexedMap accesses (fun i x -> (i, x)) + let indexed = Stdlib.List.indexedMap accesses (fun i x -> (Builtin.unwrap (Stdlib.Int.toInt64 i), x)) Stdlib.List.fold indexed 0L (fun acc pair -> let (i, x) = pair if x == a then i else acc) @@ -51,7 +51,7 @@ let fromSpec (spec: String) : State = | _ -> forDomain "file" let currentAccess (state: State) : String = - accesses |> Stdlib.List.getAt state.accessIdx |> Stdlib.Option.withDefault "read" + accesses |> Stdlib.List.getAt (Stdlib.Int.fromInt64 state.accessIdx) |> Stdlib.Option.withDefault "read" let toSpec (state: State) : String = let access = currentAccess state @@ -61,7 +61,7 @@ let toSpec (state: State) : String = else $"{state.domain} {access} {scope}" let cycleAccess (state: State) (delta: Int64) : State = - let count = Stdlib.List.length accesses + let count = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length accesses))) let raw = state.accessIdx + delta let next = if raw < 0L then count - 1L diff --git a/packages/darklang/cli/caps/httpRuleEditor.dark b/packages/darklang/cli/caps/httpRuleEditor.dark index b03356fb65..2f7af3a25b 100644 --- a/packages/darklang/cli/caps/httpRuleEditor.dark +++ b/packages/darklang/cli/caps/httpRuleEditor.dark @@ -29,7 +29,7 @@ let empty : State = // find a method's index (default 0 = `*`) let indexOfMethod (m: String) : Int64 = - let indexed = Stdlib.List.indexedMap methods (fun i x -> (i, x)) + let indexed = Stdlib.List.indexedMap methods (fun i x -> (Builtin.unwrap (Stdlib.Int.toInt64 i), x)) Stdlib.List.fold indexed 0L (fun acc pair -> let (i, x) = pair if x == m then i else acc) @@ -52,7 +52,7 @@ let fromSpec (spec: String) : State = | _ -> empty let currentMethod (state: State) : String = - methods |> Stdlib.List.getAt state.methodIdx |> Stdlib.Option.withDefault "*" + methods |> Stdlib.List.getAt (Stdlib.Int.fromInt64 state.methodIdx) |> Stdlib.Option.withDefault "*" let toSpec (state: State) : String = let m = currentMethod state @@ -61,7 +61,7 @@ let toSpec (state: State) : String = if u == "" then $"http-client {m}" else $"http-client {m} {u}" let cycleMethod (state: State) (delta: Int64) : State = - let count = Stdlib.List.length methods + let count = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length methods))) let raw = state.methodIdx + delta let next = if raw < 0L then count - 1L diff --git a/packages/darklang/cli/caps/main.dark b/packages/darklang/cli/caps/main.dark index 9e36449ca4..56d3e6fe9f 100644 --- a/packages/darklang/cli/caps/main.dark +++ b/packages/darklang/cli/caps/main.dark @@ -66,7 +66,7 @@ let rows (state: State) : List = |> Stdlib.List.map (fun s -> Row.RuleRow s) Stdlib.List.append flagRows (Stdlib.List.append ruleRows [ Row.AddRuleRow ]) -let rowCount (state: State) : Int64 = Stdlib.List.length (rows state) +let rowCount (state: State) : Int64 = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length (rows state)))) let toggleFlag (state: State) (domain: String) : State = if Stdlib.List.member_v0 state.specs domain then @@ -144,11 +144,11 @@ let handleBrowsing let c = if state.cursor < maxIdx then state.cursor + 1L else maxIdx KeyResult.Continue ({ state with cursor = c }) | Spacebar -> - match Stdlib.List.getAt (rows state) state.cursor with + match Stdlib.List.getAt (rows state) (Stdlib.Int.fromInt64 state.cursor) with | Some(FlagRow(d, _)) -> KeyResult.Continue (toggleFlag state d) | _ -> KeyResult.Continue state | Enter -> - match Stdlib.List.getAt (rows state) state.cursor with + match Stdlib.List.getAt (rows state) (Stdlib.Int.fromInt64 state.cursor) with | Some(FlagRow(d, _)) -> KeyResult.Continue (toggleFlag state d) | Some(RuleRow spec) -> KeyResult.Continue (editSpec state spec) | Some AddRuleRow -> @@ -159,7 +159,7 @@ let handleBrowsing | Some "a" -> KeyResult.Continue ({ state with screen = Screen.AddPickDomain 0L }) | Some "p" -> KeyResult.Continue ({ state with screen = Screen.PickProfile 0L }) | Some "d" -> - match Stdlib.List.getAt (rows state) state.cursor with + match Stdlib.List.getAt (rows state) (Stdlib.Int.fromInt64 state.cursor) with | Some(RuleRow spec) -> KeyResult.Continue (clampCursor (removeSpec state spec)) | _ -> KeyResult.Continue state | Some "w" -> @@ -194,18 +194,18 @@ let handleKey match key with | Escape -> KeyResult.Continue ({ state with screen = Screen.Browsing }) | Enter -> - match Stdlib.List.getAt ruleDomains cursor with + match Stdlib.List.getAt ruleDomains (Stdlib.Int.fromInt64 cursor) with | Some d -> KeyResult.Continue (editNew state d) | None -> KeyResult.Continue ({ state with screen = Screen.Browsing }) | _ -> - match handleMenu cursor (Stdlib.List.length ruleDomains) key with + match handleMenu cursor (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length ruleDomains))) key with | Some c -> KeyResult.Continue ({ state with screen = Screen.AddPickDomain c }) | None -> KeyResult.Continue state | PickProfile cursor -> match key with | Escape -> KeyResult.Continue ({ state with screen = Screen.Browsing }) | Enter -> - match Stdlib.List.getAt Command.profiles cursor with + match Stdlib.List.getAt Command.profiles (Stdlib.Int.fromInt64 cursor) with | Some((_, specs)) -> // a profile can have fewer rows than the current grant — clamp the cursor back in range KeyResult.Continue @@ -213,7 +213,7 @@ let handleKey ({ state with specs = specs; dirty = true; screen = Screen.Browsing })) | None -> KeyResult.Continue ({ state with screen = Screen.Browsing }) | _ -> - match handleMenu cursor (Stdlib.List.length Command.profiles) key with + match handleMenu cursor (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length Command.profiles))) key with | Some c -> KeyResult.Continue ({ state with screen = Screen.PickProfile c }) | None -> KeyResult.Continue state | EditHttp(orig, editor) -> @@ -258,8 +258,8 @@ let private printOneRow (state: State) (pair: (Int64 * Row)) : Unit = // flag checklist on top, then a labelled "Scoped rules" section (existing rules + the "+ Add rule…" // affordance). The cursor index maps into `rows`; the section label is printed between, not selectable. let private printRows (state: State) : Unit = - let flagCount = Stdlib.List.length flagDomains - let indexed = Stdlib.List.indexedMap (rows state) (fun i r -> (i, r)) + let flagCount = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length flagDomains))) + let indexed = Stdlib.List.indexedMap (rows state) (fun i r -> (Builtin.unwrap (Stdlib.Int.toInt64 i), r)) indexed |> Stdlib.List.filter (fun pair -> Stdlib.Tuple2.first pair < flagCount) |> Stdlib.List.iter (fun pair -> printOneRow state pair) @@ -272,7 +272,7 @@ let private printRows (state: State) : Unit = let private printMenu (title: String) (items: List) (cursor: Int64) : Unit = Stdlib.printLine title Stdlib.printLine "" - let indexed = Stdlib.List.indexedMap items (fun i x -> (i, x)) + let indexed = Stdlib.List.indexedMap items (fun i x -> (Builtin.unwrap (Stdlib.Int.toInt64 i), x)) Stdlib.List.iter indexed (fun pair -> let (i, x) = pair let selected = i == cursor diff --git a/packages/darklang/cli/completionPicker.dark b/packages/darklang/cli/completionPicker.dark index e384f0b271..c80084b07c 100644 --- a/packages/darklang/cli/completionPicker.dark +++ b/packages/darklang/cli/completionPicker.dark @@ -2,12 +2,12 @@ module Darklang.Cli.CompletionPicker type State = { items: List - selectedIndex: Int64 - scrollOffset: Int64 + selectedIndex: Int + scrollOffset: Int commandPrefix: String hasBeenDisplayed: Bool } -let maxVisibleItems: Int64 = 10L +let maxVisibleItems: Int = 10I /// Create picker state from completions let create (promptText: String) (items: List) : State = @@ -21,8 +21,8 @@ let create (promptText: String) (items: List) : State State { items = items - selectedIndex = 0L - scrollOffset = 0L + selectedIndex = 0I + scrollOffset = 0I commandPrefix = commandPrefix hasBeenDisplayed = false } @@ -35,13 +35,13 @@ let getSelectedValue (state: State) : Stdlib.Option.Option = /// Display the completion picker UI let display (state: State) : Unit = let itemCount = Stdlib.List.length state.items - let visibleCount = Stdlib.Int64.min maxVisibleItems itemCount + let visibleCount = Stdlib.Int.min maxVisibleItems itemCount let hasScrollIndicator = itemCount > maxVisibleItems // Move cursor up to overwrite previous display (only after first render) if state.hasBeenDisplayed then - let lineCount = visibleCount + (if hasScrollIndicator then 1L else 0L) + 1L - Stdlib.print $"\u001b[{Stdlib.Int64.toString lineCount}A\u001b[J" + let lineCount = visibleCount + (if hasScrollIndicator then 1I else 0I) + 1I + Stdlib.print $"\u001b[{Stdlib.Int.toString lineCount}A\u001b[J" let visibleItems = state.items @@ -61,17 +61,17 @@ let display (state: State) : Unit = // Show scroll indicator if needed if hasScrollIndicator then - let start = Stdlib.Int64.toString (state.scrollOffset + 1L) - let endIdx = Stdlib.Int64.toString (state.scrollOffset + visibleCount) - let total = Stdlib.Int64.toString itemCount + let start = Stdlib.Int.toString (state.scrollOffset + 1I) + let endIdx = Stdlib.Int.toString (state.scrollOffset + visibleCount) + let total = Stdlib.Int.toString itemCount Stdlib.printLine (Colors.dimText $"({start}-{endIdx} of {total})") Stdlib.printLine (Colors.dimText "↑/↓: navigate Enter: select Esc: cancel") /// Move selection up let moveUp (state: State) : State = - if state.selectedIndex > 0L then - let newIndex = state.selectedIndex - 1L + if state.selectedIndex > 0I then + let newIndex = state.selectedIndex - 1I // Adjust scroll if needed let newOffset = @@ -87,13 +87,13 @@ let moveUp (state: State) : State = let moveDown (state: State) : State = let itemCount = Stdlib.List.length state.items - if state.selectedIndex < (itemCount - 1L) then - let newIndex = state.selectedIndex + 1L + if state.selectedIndex < (itemCount - 1I) then + let newIndex = state.selectedIndex + 1I // Adjust scroll if needed let newOffset = if newIndex >= (state.scrollOffset + maxVisibleItems) then - state.scrollOffset + 1L + state.scrollOffset + 1I else state.scrollOffset diff --git a/packages/darklang/cli/core.dark b/packages/darklang/cli/core.dark index 5e941fb4f5..b5307da11f 100644 --- a/packages/darklang/cli/core.dark +++ b/packages/darklang/cli/core.dark @@ -189,7 +189,7 @@ module StatusBar = let padding = if paddingLen > 0L then - Colors.colorize Colors.grayBg (Stdlib.String.repeat " " paddingLen) + Colors.colorize Colors.grayBg (Stdlib.String.repeat " " (Stdlib.Int.fromInt64 paddingLen)) else "" @@ -571,7 +571,7 @@ let handleKeyInput (state: AppState) (key: Stdlib.Cli.Stdin.Key.Key) (modifiers: // Handle tab completion let tTab = Telemetry.now () let completions = Registry.getCompletions state state.prompt.text - Telemetry.logWithContext "tabComplete" tTab [("resultCount", Stdlib.Int64.toString (Stdlib.List.length completions)); ("input", state.prompt.text)] + Telemetry.logWithContext "tabComplete" tTab [("resultCount", Stdlib.Int.toString (Stdlib.List.length completions)); ("input", state.prompt.text)] // CLEANUP: When there are multiple completions with a common prefix (e.g. "filter" and "filterMap"), // Tab should complete up to the common part ("filter") rather than just showing options @@ -841,7 +841,7 @@ let parseBranchFlag (args: List) : (Stdlib.Option.Option * List name | None -> "" @@ -854,7 +854,7 @@ let parseBranchFlag (args: List) : (Stdlib.Option.Option * List Stdlib.List.filter (fun pair -> let (i, _a) = pair - i != idx && i != (idx + 1L)) + i != idx && i != (idx + 1I)) |> Stdlib.List.map (fun pair -> let (_i, a) = pair a) diff --git a/packages/darklang/cli/deps.dark b/packages/darklang/cli/deps.dark index 2d4ab5db4b..c74a43b412 100644 --- a/packages/darklang/cli/deps.dark +++ b/packages/darklang/cli/deps.dark @@ -38,7 +38,7 @@ let showDependents Stdlib.printLine $"No dependents found for {entityName}" | deps -> let count = Stdlib.List.length deps - Stdlib.printLine $"Found {Stdlib.Int64.toString count} dependents of {entityName}:" + Stdlib.printLine $"Found {Stdlib.Int.toString count} dependents of {entityName}:" Stdlib.printLine "" deps @@ -121,7 +121,7 @@ let showTransitiveDependents Stdlib.printLine $"Nothing depends on {entityName}" | deps -> let count = Stdlib.List.length deps - Stdlib.printLine $"Found {Stdlib.Int64.toString count} items that could break if {entityName} changes:" + Stdlib.printLine $"Found {Stdlib.Int.toString count} items that could break if {entityName} changes:" Stdlib.printLine "" deps @@ -144,7 +144,7 @@ let showDependencies Stdlib.printLine $"No dependencies found for {entityName}" | deps -> let count = Stdlib.List.length deps - Stdlib.printLine $"Found {Stdlib.Int64.toString count} dependencies of {entityName}:" + Stdlib.printLine $"Found {Stdlib.Int.toString count} dependencies of {entityName}:" Stdlib.printLine "" let hashes = deps |> Stdlib.List.map (fun (hash, _) -> hash) diff --git a/packages/darklang/cli/docs/for-ai-internal.dark b/packages/darklang/cli/docs/for-ai-internal.dark index 780ff41f67..90b5e3331b 100644 --- a/packages/darklang/cli/docs/for-ai-internal.dark +++ b/packages/darklang/cli/docs/for-ai-internal.dark @@ -140,9 +140,9 @@ Exception to the rule: `| Case ... ->` in a match is resolved by the matched value's type, so bare `PackageFn h` is fine in a match arm. ## Cross-module pipes -Dark parses pipes greedily; `Stdlib.List.length xs |> Stdlib.Int64.toString` +Dark parses pipes greedily; `Stdlib.List.length xs |> Stdlib.Int.toString` raises "Pipe: LongIdent". Wrap the left side in parens: - (Stdlib.List.length xs) |> Stdlib.Int64.toString + (Stdlib.List.length xs) |> Stdlib.Int.toString ## Nested functions and recursion Dark supports nested function definitions only in the fully annotated form: diff --git a/packages/darklang/cli/docs/syntax.dark b/packages/darklang/cli/docs/syntax.dark index 48ee10c5a3..4a8dda1e5f 100644 --- a/packages/darklang/cli/docs/syntax.dark +++ b/packages/darklang/cli/docs/syntax.dark @@ -18,7 +18,7 @@ let content () : String = | None -> 0L ## Pipe (parens for complex LHS) - (Stdlib.List.range 0L 10L) |> Stdlib.List.map fn + (Stdlib.List.range 0I 10I) |> Stdlib.List.map fn ## Lists (semicolon separator) [1L; 2L; 3L] diff --git a/packages/darklang/cli/outliner/core.dark b/packages/darklang/cli/outliner/core.dark index 24d1a68db8..5d3e96f5bd 100644 --- a/packages/darklang/cli/outliner/core.dark +++ b/packages/darklang/cli/outliner/core.dark @@ -127,13 +127,13 @@ let insertIdAfter (ids: List) (afterId: Int64) (newId: Int64) : List) (i: Int64) (j: Int64) : List = let iVal = - (Stdlib.List.getAt ids i) |> Stdlib.Option.withDefault 0L + (Stdlib.List.getAt ids (Stdlib.Int.fromInt64 i)) |> Stdlib.Option.withDefault 0L let jVal = - (Stdlib.List.getAt ids j) |> Stdlib.Option.withDefault 0L + (Stdlib.List.getAt ids (Stdlib.Int.fromInt64 j)) |> Stdlib.Option.withDefault 0L ids |> Stdlib.List.indexedMap (fun idx id -> - if idx == i then jVal - else if idx == j then iVal + if idx == Stdlib.Int.fromInt64 i then jVal + else if idx == Stdlib.Int.fromInt64 j then iVal else id) @@ -151,7 +151,7 @@ let flattenVisibleHelper (outline: Outline) (ids: List) (depth: Int64) : text = text depth = depth hasChildren = hasChildren - childCount = Stdlib.List.length s.children + childCount = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length s.children))) isCollapsed = s.collapsed } let childNodes = if s.collapsed then diff --git a/packages/darklang/cli/outliner/list-picker.dark b/packages/darklang/cli/outliner/list-picker.dark index 2c1d64c4d0..1c601a3b0f 100644 --- a/packages/darklang/cli/outliner/list-picker.dark +++ b/packages/darklang/cli/outliner/list-picker.dark @@ -28,13 +28,13 @@ let handleKey else state.selected Result.Browsing ({ state with selected = newIdx }) | DownArrow -> - let maxIdx = itemCount - 1L + let maxIdx = (Builtin.unwrap (Stdlib.Int.toInt64 itemCount)) - 1L let newIdx = if state.selected < maxIdx then state.selected + 1L else state.selected Result.Browsing ({ state with selected = newIdx }) | Enter -> - match Stdlib.List.getAt state.items state.selected with + match Stdlib.List.getAt state.items (Stdlib.Int.fromInt64 state.selected) with | Some item -> Result.Selected item | None -> Result.Cancelled | _ -> Result.Browsing state @@ -46,14 +46,14 @@ let renderInRegion (state: State<'item>) (region: Darklang.Cli.UI.Layout.Region) if state.selected >= region.rows then Darklang.Cli.Terminal.clampScrollOffset (state.selected - region.rows + 1L) - itemCount + (Builtin.unwrap (Stdlib.Int.toInt64 itemCount)) region.rows else 0L state.items - |> Stdlib.List.indexedMap (fun idx item -> (idx, item)) - |> Stdlib.List.drop scrollOffset - |> Stdlib.List.take region.rows + |> Stdlib.List.indexedMap (fun idx item -> ((Builtin.unwrap (Stdlib.Int.toInt64 idx)), item)) + |> Stdlib.List.drop (Stdlib.Int.fromInt64 scrollOffset) + |> Stdlib.List.take (Stdlib.Int.fromInt64 region.rows) |> Stdlib.List.iter (fun pair -> let (idx, item) = pair let row = idx - scrollOffset diff --git a/packages/darklang/cli/outliner/main.dark b/packages/darklang/cli/outliner/main.dark index e19cd4a97e..694df9f1b4 100644 --- a/packages/darklang/cli/outliner/main.dark +++ b/packages/darklang/cli/outliner/main.dark @@ -52,7 +52,7 @@ let createDocument (state: State) (title: String) : State = let deleteDocument (state: State) (docId: Int64) : State = let docCount = Stdlib.List.length state.documents - if docCount <= 1L then + if docCount <= 1I then state else let remaining = Stdlib.List.filter state.documents (fun d -> d.id != docId) @@ -78,7 +78,7 @@ let renameDocument (state: State) (docId: Int64) (newTitle: String) : State = let makeDocPicker (state: State) : ListPicker.State = ListPicker.make state.documents (fun doc -> let nodeCount = Stdlib.List.length doc.outline.rootChildren - $"{doc.title} ({Stdlib.Int64.toString nodeCount} items)") + $"{doc.title} ({Stdlib.Int.toString nodeCount} items)") let exportFormats : List<(String * String)> = [ ("Markdown", ".md") @@ -110,17 +110,17 @@ let handleDocPickerKey match keyChar with | Some "n" -> KeyResult.Save (createDocument state "Untitled") | Some "d" -> - match Stdlib.List.getAt picker.items picker.selected with + match Stdlib.List.getAt picker.items (Stdlib.Int.fromInt64 picker.selected) with | Some doc -> KeyResult.Save (deleteDocument state doc.id) | None -> KeyResult.Continue state | Some "r" -> - match Stdlib.List.getAt picker.items picker.selected with + match Stdlib.List.getAt picker.items (Stdlib.Int.fromInt64 picker.selected) with | Some doc -> let te = TextEditor.fromText doc.title KeyResult.Continue ({ state with screen = Screen.DocRenaming (doc.id, picker, te) }) | None -> KeyResult.Continue state | Some "e" -> - match Stdlib.List.getAt picker.items picker.selected with + match Stdlib.List.getAt picker.items (Stdlib.Int.fromInt64 picker.selected) with | Some doc -> KeyResult.Continue ({ state with @@ -215,7 +215,7 @@ let renderTitleBar (titleText: String) (modeText: String) (modeColor: String) (r let renderHelpBar (helpText: String) (region: Darklang.Cli.UI.Layout.Region) : Unit = let helpLen = Stdlib.String.length helpText let helpPadding = - if region.cols > helpLen then Stdlib.String.repeat " " (region.cols - helpLen) + if region.cols > helpLen then Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (region.cols - helpLen)) else "" let styled = Darklang.Cli.Colors.colorize (Darklang.Cli.Colors.grayBg ++ Darklang.Cli.Colors.white) (helpText ++ helpPadding) Darklang.Cli.UI.Layout.printAt region 0L 0L styled @@ -260,7 +260,7 @@ let render (state: State) : Unit = |> Stdlib.List.indexedMap (fun idx item -> (idx, item)) |> Stdlib.List.iter (fun pair -> let (idx, item) = pair - let isSelected = idx == picker.selected + let isSelected = idx == Stdlib.Int.fromInt64 picker.selected let displayText = match Stdlib.List.getAt picker.items idx with | Some doc -> @@ -274,7 +274,7 @@ let render (state: State) : Unit = Darklang.Cli.Colors.colorize Darklang.Cli.Colors.selection line else line - Darklang.Cli.UI.Layout.printAt region idx 0L styled)) + Darklang.Cli.UI.Layout.printAt region (Builtin.unwrap (Stdlib.Int.toInt64 idx)) 0L styled)) | Editor editor -> let doc = activeDoc state @@ -344,7 +344,7 @@ module Persistence = let picker = ListPicker.make docs (fun doc -> let nodeCount = Stdlib.List.length doc.outline.rootChildren - $"{doc.title} ({Stdlib.Int64.toString nodeCount} items)") + $"{doc.title} ({Stdlib.Int.toString nodeCount} items)") State { documents = docs activeDocId = data.activeDocId @@ -399,7 +399,7 @@ let defaultState () : State = let picker = ListPicker.make docs (fun doc -> let nodeCount = Stdlib.List.length doc.outline.rootChildren - $"{doc.title} ({Stdlib.Int64.toString nodeCount} items)") + $"{doc.title} ({Stdlib.Int.toString nodeCount} items)") State { documents = docs activeDocId = 1L diff --git a/packages/darklang/cli/outliner/markdown.dark b/packages/darklang/cli/outliner/markdown.dark index 8fd58d5bf5..22529f7771 100644 --- a/packages/darklang/cli/outliner/markdown.dark +++ b/packages/darklang/cli/outliner/markdown.dark @@ -5,7 +5,7 @@ let exportHelper (outline: Outline) (ids: List) (depth: Int64) : List Stdlib.List.fold [] (fun acc id -> let text = getNodeText outline id let s = getStructure outline id - let indent = Stdlib.String.repeat " " depth + let indent = Stdlib.String.repeat " " (Stdlib.Int.fromInt64 depth) let line = $"{indent}- {text}" let childLines = exportHelper outline s.children (depth + 1L) @@ -30,7 +30,7 @@ let import (markdown: String) : Document = match Stdlib.List.head lines with | Some first -> if Stdlib.String.startsWith first "# " then - Stdlib.List.drop lines 1L + Stdlib.List.drop lines 1I else lines | None -> [] diff --git a/packages/darklang/cli/outliner/outline-editor.dark b/packages/darklang/cli/outliner/outline-editor.dark index 78c0e2e9f9..47c805f68e 100644 --- a/packages/darklang/cli/outliner/outline-editor.dark +++ b/packages/darklang/cli/outliner/outline-editor.dark @@ -18,12 +18,13 @@ let fromOutline (outline: Outline) : State = let getVisibleNodeAtCursor (state: State) : Stdlib.Option.Option = let flat = flattenVisible state.outline - Stdlib.List.getAt flat state.cursor + Stdlib.List.getAt flat (Stdlib.Int.fromInt64 state.cursor) let findCursorIndex (outline: Outline) (nodeId: Int64) (fallback: Int64) : Int64 = let flat = flattenVisible outline flat |> Stdlib.List.findFirstIndex (fun vn -> vn.id == nodeId) + |> Stdlib.Option.map (fun i -> Builtin.unwrap (Stdlib.Int.toInt64 i)) |> Stdlib.Option.withDefault fallback @@ -78,7 +79,7 @@ let deleteNode (state: State) : State = let o1 = setChildren outline parentId newSiblings let o2 = removeNodeData o1 vn.id let flat = flattenVisible o2 - let maxIdx = Stdlib.Int64.max 0L ((Stdlib.List.length flat) - 1L) + let maxIdx = Stdlib.Int64.max 0L ((Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length flat))) - 1L) let newCursor = if state.cursor > maxIdx then maxIdx else state.cursor @@ -95,10 +96,10 @@ let indentNode (state: State) : State = match idx with | None -> state | Some i -> - if i == 0L then + if i == 0I then state else - match Stdlib.List.getAt siblings (i - 1L) with + match Stdlib.List.getAt siblings (i - 1I) with | None -> state | Some prevSibId -> let newSiblings = Stdlib.List.filter siblings (fun id -> id != vn.id) @@ -140,10 +141,11 @@ let moveNodeUp (state: State) : State = match idx with | None -> state | Some i -> - if i == 0L then + if i == 0I then state else - let swapped = swapAt siblings (i - 1L) i + let i64 = Builtin.unwrap (Stdlib.Int.toInt64 i) + let swapped = swapAt siblings (i64 - 1L) i64 let o1 = setChildren outline parentId swapped { state with outline = o1; cursor = findCursorIndex o1 vn.id state.cursor } @@ -158,10 +160,11 @@ let moveNodeDown (state: State) : State = match idx with | None -> state | Some i -> - if i >= ((Stdlib.List.length siblings) - 1L) then + if i >= ((Stdlib.List.length siblings) - 1I) then state else - let swapped = swapAt siblings i (i + 1L) + let i64 = Builtin.unwrap (Stdlib.Int.toInt64 i) + let swapped = swapAt siblings i64 (i64 + 1L) let o1 = setChildren outline parentId swapped { state with outline = o1; cursor = findCursorIndex o1 vn.id state.cursor } @@ -173,7 +176,7 @@ let moveCursorUp (state: State) : State = let moveCursorDown (state: State) : State = let flat = flattenVisible state.outline - let maxIndex = (Stdlib.List.length flat) - 1L + let maxIndex = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length flat))) - 1L if state.cursor < maxIndex then { state with cursor = state.cursor + 1L } else @@ -264,23 +267,23 @@ let renderBody (state: State) (region: Darklang.Cli.UI.Layout.Region) : Unit = else if state.cursor >= region.rows then Darklang.Cli.Terminal.clampScrollOffset (state.cursor - region.rows + 1L) - totalItems + (Builtin.unwrap (Stdlib.Int.toInt64 totalItems)) region.rows else 0L let visibleItems = flat - |> Stdlib.List.drop scrollOffset - |> Stdlib.List.take region.rows + |> Stdlib.List.drop (Stdlib.Int.fromInt64 scrollOffset) + |> Stdlib.List.take (Stdlib.Int.fromInt64 region.rows) visibleItems - |> Stdlib.List.indexedMap (fun relIdx vn -> (relIdx, vn)) + |> Stdlib.List.indexedMap (fun relIdx vn -> ((Builtin.unwrap (Stdlib.Int.toInt64 relIdx)), vn)) |> Stdlib.List.iter (fun pair -> let (relIdx, vn) = pair let absoluteIdx = scrollOffset + relIdx let isSelected = absoluteIdx == state.cursor - let indent = Stdlib.String.repeat " " vn.depth + let indent = Stdlib.String.repeat " " (Stdlib.Int.fromInt64 vn.depth) let bullet = if vn.isCollapsed && vn.hasChildren then Darklang.Cli.Colors.colorize Darklang.Cli.Colors.yellow ">" @@ -324,7 +327,7 @@ let renderTitleBar (title: String) (isEditing: Bool) (region: Darklang.Cli.UI.La let renderHelpBar (helpText: String) (region: Darklang.Cli.UI.Layout.Region) : Unit = let helpLen = Stdlib.String.length helpText let helpPadding = - if region.cols > helpLen then Stdlib.String.repeat " " (region.cols - helpLen) + if region.cols > helpLen then Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (region.cols - helpLen)) else "" let styled = Darklang.Cli.Colors.colorize (Darklang.Cli.Colors.grayBg ++ Darklang.Cli.Colors.white) (helpText ++ helpPadding) Darklang.Cli.UI.Layout.printAt region 0L 0L styled diff --git a/packages/darklang/cli/outliner/tests.dark b/packages/darklang/cli/outliner/tests.dark index b29728e48a..c88d46d3fa 100644 --- a/packages/darklang/cli/outliner/tests.dark +++ b/packages/darklang/cli/outliner/tests.dark @@ -55,7 +55,7 @@ let testFlattenVisibleCountsAllNodes () : TestResult = [1L; 4L] 5L let flat = flattenVisible outline - assertInt "visible count" (Stdlib.List.length flat) 4L + assertInt "visible count" (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length flat))) 4L let testFlattenVisibleRespectsCollapse () : TestResult = let outline = @@ -66,7 +66,7 @@ let testFlattenVisibleRespectsCollapse () : TestResult = 5L let collapsed = setCollapsed outline 1L true let flat = flattenVisible collapsed - assertInt "visible count" (Stdlib.List.length flat) 2L + assertInt "visible count" (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length flat))) 2L let testBuildOutline () : TestResult = let outline = @@ -76,7 +76,7 @@ let testBuildOutline () : TestResult = [1L] 4L let flat = flattenVisible outline - if Stdlib.List.length flat == 3L then + if Stdlib.List.length flat == 3I then match Stdlib.List.head flat with | Some vn -> if vn.text == "A" && vn.hasChildren && vn.depth == 0L then @@ -85,7 +85,7 @@ let testBuildOutline () : TestResult = TestResult.Fail "First node should be A with children at depth 0" | None -> TestResult.Fail "No visible nodes" else - TestResult.Fail $"Expected 3 visible, got {Stdlib.Int64.toString (Stdlib.List.length flat)}" + TestResult.Fail $"Expected 3 visible, got {Stdlib.Int.toString (Stdlib.List.length flat)}" let testFindParentId () : TestResult = let outline = @@ -119,13 +119,13 @@ let testInsertAfterAddsNode () : TestResult = let editor = makeEditor outline let newEditor = OutlineEditor.insertAfter editor let flat = flattenVisible newEditor.outline - assertInt "visible count" (Stdlib.List.length flat) 2L + assertInt "visible count" (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length flat))) 2L let testInsertAfterEmptyTree () : TestResult = let outline = emptyOutline () let editor = makeEditor outline let newEditor = OutlineEditor.insertAfter editor - assertInt "root count" (Stdlib.List.length newEditor.outline.rootChildren) 1L + assertInt "root count" (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length newEditor.outline.rootChildren))) 1L let testDeleteEmptyNode () : TestResult = let outline = @@ -136,7 +136,7 @@ let testDeleteEmptyNode () : TestResult = 3L let editor = makeEditor outline let newEditor = OutlineEditor.deleteNode editor - assertInt "root count" (Stdlib.List.length newEditor.outline.rootChildren) 1L + assertInt "root count" (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length newEditor.outline.rootChildren))) 1L let testDeleteNonEmptyNodeDoesNothing () : TestResult = let outline = @@ -147,7 +147,7 @@ let testDeleteNonEmptyNodeDoesNothing () : TestResult = 2L let editor = makeEditor outline let newEditor = OutlineEditor.deleteNode editor - assertInt "root count" (Stdlib.List.length newEditor.outline.rootChildren) 1L + assertInt "root count" (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length newEditor.outline.rootChildren))) 1L let testToggleCollapse () : TestResult = let outline = @@ -185,11 +185,11 @@ let testIndentNode () : TestResult = let editor = { (makeEditor outline) with cursor = 1L } let newEditor = OutlineEditor.indentNode editor let rootCount = Stdlib.List.length newEditor.outline.rootChildren - if rootCount == 1L then + if rootCount == 1I then let s = getStructure newEditor.outline 1L - assertInt "child count" (Stdlib.List.length s.children) 1L + assertInt "child count" (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length s.children))) 1L else - TestResult.Fail $"Expected 1 root after indent, got {Stdlib.Int64.toString rootCount}" + TestResult.Fail $"Expected 1 root after indent, got {Stdlib.Int.toString rootCount}" let testOutdentNode () : TestResult = let outline = @@ -200,7 +200,7 @@ let testOutdentNode () : TestResult = 3L let editor = { (makeEditor outline) with cursor = 1L } let newEditor = OutlineEditor.outdentNode editor - assertInt "root count" (Stdlib.List.length newEditor.outline.rootChildren) 2L + assertInt "root count" (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length newEditor.outline.rootChildren))) 2L let testMoveNodeUp () : TestResult = let outline = @@ -326,7 +326,7 @@ let testFinishEditing () : TestResult = let testDefaultStateHasTwoDocs () : TestResult = let state = Main.defaultState () - assertInt "doc count" (Stdlib.List.length state.documents) 2L + assertInt "doc count" (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length state.documents))) 2L let testActiveDocReturnsCorrectDoc () : TestResult = let state = Main.defaultState () @@ -337,23 +337,23 @@ let testCreateDocument () : TestResult = let state = Main.defaultState () let newState = Main.createDocument state "Third Doc" let count = Stdlib.List.length newState.documents - if count == 3L && newState.activeDocId == state.nextDocId then + if count == 3I && newState.activeDocId == state.nextDocId then let doc = Main.activeDoc newState assertEq "doc title" doc.title "Third Doc" else - TestResult.Fail $"Expected 3 docs, got {Stdlib.Int64.toString count}" + TestResult.Fail $"Expected 3 docs, got {Stdlib.Int.toString count}" let testDeleteDocument () : TestResult = let state = Main.defaultState () let newState = Main.createDocument state "Third" let thirdDocId = newState.activeDocId let afterDelete = Main.deleteDocument newState thirdDocId - assertInt "doc count" (Stdlib.List.length afterDelete.documents) 2L + assertInt "doc count" (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length afterDelete.documents))) 2L let testDeleteOnlyDocDoesNothing () : TestResult = let state = makeMainState (buildOutline [(1L, "X")] [] [1L] 2L) let afterDelete = Main.deleteDocument state 1L - assertInt "doc count" (Stdlib.List.length afterDelete.documents) 1L + assertInt "doc count" (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length afterDelete.documents))) 1L let testRenameDocument () : TestResult = let state = Main.defaultState () @@ -397,7 +397,7 @@ let testImportMarkdown () : TestResult = let doc = Markdown.import md if doc.title == "My Doc" then let flat = flattenVisible doc.outline - assertInt "visible count" (Stdlib.List.length flat) 3L + assertInt "visible count" (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length flat))) 3L else TestResult.Fail $"Expected title 'My Doc', got '{doc.title}'" diff --git a/packages/darklang/cli/packages/db.dark b/packages/darklang/cli/packages/db.dark index fe2bad0494..969b42f311 100644 --- a/packages/darklang/cli/packages/db.dark +++ b/packages/darklang/cli/packages/db.dark @@ -98,7 +98,7 @@ let listDBs (state: Cli.AppState) : Cli.AppState = let typeHeader = "Type" Stdlib.printLine $"{nameHeader}{typeHeader}" - Stdlib.printLine (Stdlib.String.repeat "─" 60L) + Stdlib.printLine (Stdlib.String.repeat "─" 60I) // Print each DB dbs @@ -167,9 +167,9 @@ let viewDB (state: Cli.AppState) (dbName: String) : Cli.AppState = let totalWidth = colWidth - + (Stdlib.Int64.multiply (Stdlib.List.length fieldNames) colWidth) + + (Stdlib.Int64.multiply (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length fieldNames))) colWidth) - Stdlib.printLine (Stdlib.String.repeat "─" totalWidth) + Stdlib.printLine (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 totalWidth)) if Stdlib.String.isEmpty result then Stdlib.printLine " (empty)" @@ -193,7 +193,7 @@ let viewDB (state: Cli.AppState) (dbName: String) : Cli.AppState = Stdlib.printLine "" let rowCount = Stdlib.List.length rows - Stdlib.printLine $"{Stdlib.Int64.toString rowCount} row(s)" + Stdlib.printLine $"{Stdlib.Int.toString rowCount} row(s)" Stdlib.printLine "" state diff --git a/packages/darklang/cli/packages/delete.dark b/packages/darklang/cli/packages/delete.dark index a25f3f7275..e27e54faf3 100644 --- a/packages/darklang/cli/packages/delete.dark +++ b/packages/darklang/cli/packages/delete.dark @@ -33,8 +33,8 @@ let parseArgs (args: List) : ParsedArgs = let p = FlagParser.parse argSpec args let forced = FlagParser.hasFlag p "--force" ParsedArgs - { itemType = Stdlib.List.getAt p.positionals 0L - target = Stdlib.List.getAt p.positionals 1L + { itemType = Stdlib.List.getAt p.positionals 0I + target = Stdlib.List.getAt p.positionals 1I message = FlagParser.getOptionOr p "--message" "" autoConfirm = (FlagParser.hasFlag p "--yes") || forced ignoreDependents = (FlagParser.hasFlag p "--ignore-dependents") || forced @@ -57,6 +57,8 @@ let countLiveDependents let (depHash, _depLoc, _depKind) = entry Stdlib.Bool.not (Query.isDeprecated depSets depHash)) |> Stdlib.List.length + |> Stdlib.Int.toInt64 + |> Builtin.unwrap /// Translate delete's ParsedArgs into the equivalent `deprecate --kind obsolete` diff --git a/packages/darklang/cli/packages/deprecate.dark b/packages/darklang/cli/packages/deprecate.dark index 762ca9de11..d0118f15f4 100644 --- a/packages/darklang/cli/packages/deprecate.dark +++ b/packages/darklang/cli/packages/deprecate.dark @@ -30,8 +30,8 @@ let argSpec: FlagParser.Spec = let parseArgs (args: List) : ParsedArgs = let p = FlagParser.parse argSpec args ParsedArgs - { itemType = Stdlib.List.getAt p.positionals 0L - target = Stdlib.List.getAt p.positionals 1L + { itemType = Stdlib.List.getAt p.positionals 0I + target = Stdlib.List.getAt p.positionals 1I kind = FlagParser.getOption p "--kind" replacement = FlagParser.getOption p "--replacement" message = FlagParser.getOptionOr p "--message" "" diff --git a/packages/darklang/cli/packages/navInteractive.dark b/packages/darklang/cli/packages/navInteractive.dark index 01d539d19f..aa3ea1a51a 100644 --- a/packages/darklang/cli/packages/navInteractive.dark +++ b/packages/darklang/cli/packages/navInteractive.dark @@ -108,14 +108,14 @@ let viewEntityTruncated (branchId: Uuid) (location: PackageLocation) : Unit = let lineCount = if Stdlib.Bool.not (Stdlib.List.isEmpty directSubmodules) then Stdlib.printLine (Display.getSectionHeader "submodule") - let itemsToShow = Stdlib.List.take directSubmodules maxItemsPerCategory + let itemsToShow = Stdlib.List.take directSubmodules (Stdlib.Int.fromInt64 maxItemsPerCategory) itemsToShow |> Stdlib.List.iter (fun name -> Stdlib.printLine $" {name}/") - let remaining = (Stdlib.List.length directSubmodules) - maxItemsPerCategory + let remaining = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length directSubmodules))) - maxItemsPerCategory if remaining > 0L then Stdlib.printLine $" ... and {Stdlib.Int64.toString remaining} more modules" - lineCount + 1L + (Stdlib.List.length itemsToShow) + (if remaining > 0L then 1L else 0L) + lineCount + 1L + (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length itemsToShow))) + (if remaining > 0L then 1L else 0L) else lineCount @@ -127,10 +127,10 @@ let viewEntityTruncated (branchId: Uuid) (location: PackageLocation) : Unit = // Show types (limited) if Stdlib.Bool.not (Stdlib.List.isEmpty results.types) && itemsPerRemaining > 0L then Stdlib.printLine (Display.getSectionHeader "type") - let typesToShow = Stdlib.List.take results.types itemsPerRemaining + let typesToShow = Stdlib.List.take results.types (Stdlib.Int.fromInt64 itemsPerRemaining) typesToShow |> Stdlib.List.iter (fun t -> Stdlib.printLine $" {t.location.name}") - let remaining = (Stdlib.List.length results.types) - itemsPerRemaining + let remaining = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length results.types))) - itemsPerRemaining if remaining > 0L then Stdlib.printLine $" ... and {Stdlib.Int64.toString remaining} more types" @@ -159,16 +159,16 @@ let display (navState: State) : Unit = match navState.mode with | Nav -> Stdlib.printLine (Colors.boldText $"{headerPrefix} {locationStr}{displaySuffix}") - Stdlib.printLine (Stdlib.String.repeat "─" 60L) + Stdlib.printLine (Stdlib.String.repeat "─" 60I) | Search -> Stdlib.printLine (Colors.boldText $"{headerPrefix} {locationStr}{displaySuffix}") - Stdlib.printLine (Stdlib.String.repeat "━" 60L) + Stdlib.printLine (Stdlib.String.repeat "━" 60I) Stdlib.printLine $" {navState.searchQuery}_" - Stdlib.printLine (Stdlib.String.repeat "━" 60L) + Stdlib.printLine (Stdlib.String.repeat "━" 60I) // Calculate viewport let viewportHeight = 12L - let totalItems = Stdlib.List.length navState.items + let totalItems = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length navState.items))) if totalItems == 0L then Stdlib.printLine " (empty directory)" @@ -179,13 +179,13 @@ let display (navState: State) : Unit = let visibleItems = navState.items - |> Stdlib.List.drop startIndex - |> Stdlib.List.take (endIndex - startIndex) + |> Stdlib.List.drop (Stdlib.Int.fromInt64 startIndex) + |> Stdlib.List.take (Stdlib.Int.fromInt64 (endIndex - startIndex)) // Display items visibleItems |> Stdlib.List.indexedMap (fun relativeIndex item -> - let absoluteIndex = startIndex + relativeIndex + let absoluteIndex = startIndex + (Builtin.unwrap (Stdlib.Int.toInt64 relativeIndex)) let isSelected = absoluteIndex == navState.selectedIndex let icon = Display.getIcon item.entityType @@ -208,11 +208,11 @@ let display (navState: State) : Unit = match navState.display with | Source -> if totalItems > 0L then - match Stdlib.List.getAt navState.items navState.selectedIndex with + match Stdlib.List.getAt navState.items (Stdlib.Int.fromInt64 navState.selectedIndex) with | Some selectedItem -> - Stdlib.printLines [ ""; (Stdlib.String.repeat "─" 60L) ] + Stdlib.printLines [ ""; (Stdlib.String.repeat "─" 60I) ] viewEntityTruncated navState.branchId selectedItem.location - Stdlib.printLines [ ""; (Stdlib.String.repeat "─" 60L) ] + Stdlib.printLines [ ""; (Stdlib.String.repeat "─" 60I) ] | None -> () | JustName -> () @@ -227,7 +227,7 @@ let display (navState: State) : Unit = // Navigation helper functions let moveUp (navState: State) : State = - let totalItems = Stdlib.List.length navState.items + let totalItems = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length navState.items))) if totalItems > 0L then let newIndex = if navState.selectedIndex > 0L then @@ -248,7 +248,7 @@ let moveUp (navState: State) : State = navState let moveDown (navState: State) : State = - let totalItems = Stdlib.List.length navState.items + let totalItems = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length navState.items))) if totalItems > 0L then let newIndex = if navState.selectedIndex < totalItems - 1L then @@ -277,9 +277,9 @@ let exitToMainPrompt (state: Cli.AppState) : Cli.AppState = prompt = Prompt.Editing.clear state.prompt } let selectAndExit (state: Cli.AppState) (navState: State) : Cli.AppState = - let totalItems = Stdlib.List.length navState.items + let totalItems = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length navState.items))) if totalItems > 0L then - match Stdlib.List.getAt navState.items navState.selectedIndex with + match Stdlib.List.getAt navState.items (Stdlib.Int.fromInt64 navState.selectedIndex) with | Some selectedItem -> exitAlternateScreen () let newState = Nav.navTo state selectedItem.location @@ -294,9 +294,9 @@ let selectAndExit (state: Cli.AppState) (navState: State) : Cli.AppState = exitToMainPrompt state let navigateIntoModule (state: Cli.AppState) (navState: State) : Cli.AppState = - let totalItems = Stdlib.List.length navState.items + let totalItems = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length navState.items))) if totalItems > 0L then - match Stdlib.List.getAt navState.items navState.selectedIndex with + match Stdlib.List.getAt navState.items (Stdlib.Int.fromInt64 navState.selectedIndex) with | Some selectedItem -> match selectedItem.entityType with | Module -> @@ -455,9 +455,9 @@ let handleNavModeKeys | U -> match navState.display with | Source -> - let totalItems = Stdlib.List.length navState.items + let totalItems = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length navState.items))) if totalItems > 0L then - match Stdlib.List.getAt navState.items navState.selectedIndex with + match Stdlib.List.getAt navState.items (Stdlib.Int.fromInt64 navState.selectedIndex) with | Some selectedItem -> exitAlternateScreen () let locationStr = Packages.formatLocation selectedItem.location diff --git a/packages/darklang/cli/packages/propagate.dark b/packages/darklang/cli/packages/propagate.dark index 7e43cee301..f27f787a43 100644 --- a/packages/darklang/cli/packages/propagate.dark +++ b/packages/darklang/cli/packages/propagate.dark @@ -244,7 +244,7 @@ let propagateFromHashes | [] -> () | _ -> let count = Stdlib.List.length repoints - Stdlib.printLine $" Propagated to {Stdlib.Int64.toString count} dependents:" + Stdlib.printLine $" Propagated to {Stdlib.Int.toString count} dependents:" let ids = repoints |> Stdlib.List.map (fun r -> LanguageTools.ProgramTypes.Reference.hash r.toRef) |> Stdlib.List.unique let namesDict = Deps.resolveNames branchId ids diff --git a/packages/darklang/cli/packages/query.dark b/packages/darklang/cli/packages/query.dark index 830b55b56c..d487133289 100644 --- a/packages/darklang/cli/packages/query.dark +++ b/packages/darklang/cli/packages/query.dark @@ -39,7 +39,7 @@ let hasContent (r: LanguageTools.ProgramTypes.Search.SearchResults) : Bool = /// Extract direct submodule names from the current module path -let getDirectSubmodules (results: LanguageTools.ProgramTypes.Search.SearchResults) (currentPathLength: Int64) : List = +let getDirectSubmodules (results: LanguageTools.ProgramTypes.Search.SearchResults) (currentPathLength: Int) : List = results.submodules |> Stdlib.List.filterMap (fun modulePath -> match Stdlib.List.drop modulePath currentPathLength with diff --git a/packages/darklang/cli/packages/search.dark b/packages/darklang/cli/packages/search.dark index 7aa8a22a79..cbff120ad9 100644 --- a/packages/darklang/cli/packages/search.dark +++ b/packages/darklang/cli/packages/search.dark @@ -1,7 +1,7 @@ module Darklang.Cli.Packages.Search // Max results rendered per entity type. -let displayCap = 20L +let displayCap = 20I // Operator symbols aren't function names, so a literal search for one finds @@ -103,12 +103,12 @@ let withOptionalDoc (withDocs: Bool) (headline: String) (desc: String) : String if withDocs then (withDoc headline desc) ++ "\n" else headline -let overflowNote (total: Int64) (shown: Int64) : Unit = +let overflowNote (total: Int) (shown: Int) : Unit = let extra = total - shown - if extra > 0L then + if extra > 0I then Stdlib.printLine ( Colors.hint - $" ... and {Stdlib.Int64.toString extra} more (narrow with --exact or `nav` into a module)") + $" ... and {Stdlib.Int.toString extra} more (narrow with --exact or `nav` into a module)") else () @@ -272,7 +272,7 @@ let execute (state: Cli.AppState) (args: List) : Cli.AppState = if Stdlib.List.isEmpty parsed.entityTypes then Stdlib.List.length results.submodules else - 0L + 0I let totalResults = (Stdlib.List.length results.types) @@ -280,7 +280,7 @@ let execute (state: Cli.AppState) (args: List) : Cli.AppState = + (Stdlib.List.length results.fns) + submodulesCount - if totalResults == 0L then + if totalResults == 0I then Stdlib.printLine (Colors.dimText $"No results found for: {queryText}") Stdlib.printLine "" else diff --git a/packages/darklang/cli/packages/signatures.dark b/packages/darklang/cli/packages/signatures.dark index a64f74b789..22d3d7fb42 100644 --- a/packages/darklang/cli/packages/signatures.dark +++ b/packages/darklang/cli/packages/signatures.dark @@ -245,12 +245,12 @@ let executeFiltered let totalFns = (Stdlib.Dict.values fnsBy) |> Stdlib.List.map (fun xs -> Stdlib.List.length xs) - |> Stdlib.List.fold 0L (fun a b -> a + b) + |> Stdlib.List.fold 0I (fun a b -> a + b) let totalTypes = (Stdlib.Dict.values typesBy) |> Stdlib.List.map (fun xs -> Stdlib.List.length xs) - |> Stdlib.List.fold 0L (fun a b -> a + b) + |> Stdlib.List.fold 0I (fun a b -> a + b) let title = match filterText with @@ -263,10 +263,10 @@ let executeFiltered Stdlib.printLine "" let typesNote = - if includeTypes then $", {Stdlib.Int64.toString totalTypes} types" + if includeTypes then $", {Stdlib.Int.toString totalTypes} types" else "" - let summary = $"{Stdlib.Int64.toString totalFns} fns{typesNote} across {Stdlib.Int64.toString (Stdlib.List.length allKeys)} modules" + let summary = $"{Stdlib.Int.toString totalFns} fns{typesNote} across {Stdlib.Int.toString (Stdlib.List.length allKeys)} modules" Stdlib.printLine (Colors.hint summary) if Stdlib.Bool.not includeTypes then diff --git a/packages/darklang/cli/packages/traversal.dark b/packages/darklang/cli/packages/traversal.dark index 00409994e1..21100582d2 100644 --- a/packages/darklang/cli/packages/traversal.dark +++ b/packages/darklang/cli/packages/traversal.dark @@ -163,7 +163,7 @@ let searchModulesByPrefix | Some pair -> let (idx, _) = pair // Return path up to and including the matching segment - Stdlib.Option.Option.Some (Stdlib.List.take modulePath (idx + 1L)) + Stdlib.Option.Option.Some (Stdlib.List.take modulePath (idx + 1I)) | None -> Stdlib.Option.Option.None) |> Stdlib.List.unique |> Stdlib.List.map (fun path -> Stdlib.String.join path ".") diff --git a/packages/darklang/cli/packages/tree.dark b/packages/darklang/cli/packages/tree.dark index 988769ac14..3689b37994 100644 --- a/packages/darklang/cli/packages/tree.dark +++ b/packages/darklang/cli/packages/tree.dark @@ -231,7 +231,7 @@ let displayTree allEntities |> Stdlib.List.indexedMap (fun index entry -> let (name, entityType, hash) = entry - let isLast = index == (entitiesCount - 1L) + let isLast = index == (entitiesCount - 1I) let treeBranch = if isLast then "└── " else "├── " let fullPrefix = prefix ++ treeBranch diff --git a/packages/darklang/cli/packages/undo.dark b/packages/darklang/cli/packages/undo.dark index 681248fe2f..d63756ff52 100644 --- a/packages/darklang/cli/packages/undo.dark +++ b/packages/darklang/cli/packages/undo.dark @@ -158,7 +158,7 @@ let execute (state: Cli.AppState) (args: List) : Cli.AppState = let count = Stdlib.List.length myRepoints Stdlib.printLine - $" This will revert {Stdlib.Int64.toString count} dependent(s):" + $" This will revert {Stdlib.Int.toString count} dependent(s):" myRepoints |> Stdlib.List.iter (fun r -> diff --git a/packages/darklang/cli/packages/view.dark b/packages/darklang/cli/packages/view.dark index 507fb33b2d..d7724d8f73 100644 --- a/packages/darklang/cli/packages/view.dark +++ b/packages/darklang/cli/packages/view.dark @@ -61,7 +61,7 @@ let viewEntity (branchId: Uuid) (location: PackageLocation) : Unit = let locationStr = Packages.formatLocation location Stdlib.printLine locationStr - Stdlib.printLine (Stdlib.String.repeat "=" (Stdlib.String.length locationStr)) + Stdlib.printLine (Stdlib.String.repeat "=" (Stdlib.Int.fromInt64 (Stdlib.String.length locationStr))) Stdlib.printLine "" // Display submodules diff --git a/packages/darklang/cli/prompt.dark b/packages/darklang/cli/prompt.dark index 1db8479208..c948e9bb04 100644 --- a/packages/darklang/cli/prompt.dark +++ b/packages/darklang/cli/prompt.dark @@ -102,7 +102,7 @@ module History = /// Navigate to previous command in history let navigatePrevious (state: State) : State = if Stdlib.Bool.not (Stdlib.List.isEmpty state.commandHistory) then - let historyLength = Stdlib.List.length state.commandHistory + let historyLength = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length state.commandHistory))) let newIndex = if state.historyIndex == -1L then 0L // Start from the most recent command @@ -111,7 +111,7 @@ module History = state.historyIndex + 1L else state.historyIndex // Stay at oldest command - match Stdlib.List.getAt state.commandHistory newIndex with + match Stdlib.List.getAt state.commandHistory (Stdlib.Int.fromInt64 newIndex) with | Some command -> let commandLength = Stdlib.String.length command let newSavedPrompt = @@ -144,7 +144,7 @@ module History = cursorPosition = restoredPromptLength historyIndex = newIndex } else - match Stdlib.List.getAt state.commandHistory newIndex with + match Stdlib.List.getAt state.commandHistory (Stdlib.Int.fromInt64 newIndex) with | Some command -> let commandLength = Stdlib.String.length command { state with diff --git a/packages/darklang/cli/scm/branch.dark b/packages/darklang/cli/scm/branch.dark index 79225c5e13..363a1de52e 100644 --- a/packages/darklang/cli/scm/branch.dark +++ b/packages/darklang/cli/scm/branch.dark @@ -26,8 +26,8 @@ let branchAnnotation let commits = SCM.PackageOps.getCommits branch.id 1000L let commitCount = Stdlib.List.length commits - if commitCount > 0L then - let count = Stdlib.Int64.toString commitCount + if commitCount > 0I then + let count = Stdlib.Int.toString commitCount [ Colors.info $"{count} committed" ] else [] @@ -59,7 +59,7 @@ let printBranchTree children |> Stdlib.List.indexedMap (fun i child -> - let isLastChild = i == (childCount - 1L) + let isLastChild = i == (childCount - 1I) let connector = if isLastChild then diff --git a/packages/darklang/cli/scm/review/app.dark b/packages/darklang/cli/scm/review/app.dark index 92d463e0a0..3af5f876d2 100644 --- a/packages/darklang/cli/scm/review/app.dark +++ b/packages/darklang/cli/scm/review/app.dark @@ -77,7 +77,7 @@ let flattenGroups (groups: List<(String * List)>) : List Stdlib.List.indexedMap (fun idx group -> let (modPath, items) = group - let spacer = if idx > 0L then [ DetailItem.ModuleHeader "" ] else [] + let spacer = if idx > 0I then [ DetailItem.ModuleHeader "" ] else [] let header = [ DetailItem.ModuleHeader modPath ] let entries = Stdlib.List.map items (fun item -> DetailItem.ItemEntry item) Stdlib.List.append spacer (Stdlib.List.append header entries)) @@ -294,7 +294,7 @@ let buildCommitDiffState (commitList: CommitListState) (entry: CommitEntry) : Di // ── Key handling ── let openDiff (state: AppModel) (detail: DetailState) : KeyResult = - match Stdlib.List.getAt detail.flatItems detail.selected with + match Stdlib.List.getAt detail.flatItems (Stdlib.Int.fromInt64 detail.selected) with | Some flatItem -> match flatItem with | ItemEntry pkg -> @@ -305,13 +305,13 @@ let openDiff (state: AppModel) (detail: DetailState) : KeyResult = | None -> KeyResult.Continue state let openCommitDiff (state: AppModel) (commitList: CommitListState) : KeyResult = - match Stdlib.List.getAt commitList.commits commitList.selected with + match Stdlib.List.getAt commitList.commits (Stdlib.Int.fromInt64 commitList.selected) with | Some entry -> KeyResult.Continue ({ state with screen = Screen.DiffView (buildCommitDiffState commitList entry) }) | None -> KeyResult.Continue state let handleBranchListKey (state: AppModel) (branchList: BranchListState) (key: Stdlib.Cli.Stdin.Key.Key) (keyChar: Stdlib.Option.Option) : KeyResult = - let itemCount = Stdlib.List.length branchList.items + let itemCount = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length branchList.items)) match keyChar with | Some "r" -> let newBranchList = BranchListState { items = loadBranchList (); selected = 0L } @@ -324,7 +324,7 @@ let handleBranchListKey (state: AppModel) (branchList: BranchListState) (key: St | DownArrow -> KeyResult.Continue ({ state with screen = Screen.BranchList ({ branchList with selected = moveDown branchList.selected itemCount }) }) | Enter | RightArrow -> - match Stdlib.List.getAt branchList.items branchList.selected with + match Stdlib.List.getAt branchList.items (Stdlib.Int.fromInt64 branchList.selected) with | Some item -> KeyResult.Continue ({ state with screen = Screen.Detail (buildDetailState item) }) | None -> KeyResult.Continue state | _ -> KeyResult.Continue state @@ -359,12 +359,12 @@ let handleDiffKey (state: AppModel) (diffState: DiffState) (key: Stdlib.Cli.Stdi | UpArrow -> KeyResult.Continue ({ state with screen = Screen.DiffView ({ diffState with scrollOffset = moveUp diffState.scrollOffset }) }) | DownArrow -> - let lineCount = Stdlib.List.length diffState.diffLines + let lineCount = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length diffState.diffLines)) KeyResult.Continue ({ state with screen = Screen.DiffView ({ diffState with scrollOffset = moveDown diffState.scrollOffset lineCount }) }) | _ -> KeyResult.Continue state let handleCommitListKey (state: AppModel) (commitList: CommitListState) (key: Stdlib.Cli.Stdin.Key.Key) : KeyResult = - let itemCount = Stdlib.List.length commitList.commits + let itemCount = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length commitList.commits)) match key with | Escape | LeftArrow -> KeyResult.Continue ({ state with screen = Screen.Detail commitList.returnTo }) | UpArrow -> @@ -409,8 +409,8 @@ let printLine (region: Darklang.Cli.UI.Layout.Region) (row: Int64) (text: String Darklang.Cli.UI.Layout.printAt region row 0L (text ++ "\u001b[K") let clearRows (region: Darklang.Cli.UI.Layout.Region) (startRow: Int64) : Unit = - let rows = Stdlib.List.range startRow (region.rows - 1L) - Stdlib.List.iter rows (fun row -> Darklang.Cli.UI.Layout.printAt region row 0L "\u001b[K") + let rows = Stdlib.List.range (Stdlib.Int.fromInt64 startRow) (Stdlib.Int.fromInt64 (region.rows - 1L)) + Stdlib.List.iter rows (fun row -> Darklang.Cli.UI.Layout.printAt region (Builtin.unwrap (Stdlib.Int.toInt64 row)) 0L "\u001b[K") let renderScrollableList (region: Darklang.Cli.UI.Layout.Region) @@ -420,14 +420,14 @@ let renderScrollableList (rowsPerItem: Int64) (renderItem: Darklang.Cli.UI.Layout.Region -> Int64 -> 'a -> Bool -> Unit) : Unit = - let itemCount = Stdlib.List.length items + let itemCount = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length items)) let listRows = region.rows - startRow let visibleCount = Stdlib.Int64.divide listRows rowsPerItem let scrollOffset = computeScrollOffset selected visibleCount items - |> Stdlib.List.indexedMap (fun idx item -> (idx, item)) - |> Stdlib.List.drop scrollOffset - |> Stdlib.List.take visibleCount + |> Stdlib.List.indexedMap (fun idx item -> (Builtin.unwrap (Stdlib.Int.toInt64 idx), item)) + |> Stdlib.List.drop (Stdlib.Int.fromInt64 scrollOffset) + |> Stdlib.List.take (Stdlib.Int.fromInt64 visibleCount) |> Stdlib.List.iter (fun pair -> let (idx, item) = pair let itemRow = ((idx - scrollOffset) * rowsPerItem) + startRow @@ -447,12 +447,12 @@ let renderHelpBar (region: Darklang.Cli.UI.Layout.Region) (helpText: String) : U let renderBranchListBody (branchList: BranchListState) (region: Darklang.Cli.UI.Layout.Region) : Unit = let itemCount = Stdlib.List.length branchList.items printLine region 0L $" {Darklang.Cli.Colors.bold}branches to review{Darklang.Cli.Colors.reset}" - if itemCount == 0L then + if itemCount == 0I then printLine region 2L (Darklang.Cli.Colors.colorize Darklang.Cli.Colors.dim " No branches with changes to review.") clearRows region 3L else let dim = Darklang.Cli.Colors.dim ++ Darklang.Cli.Colors.brightBlack - let hBar = Stdlib.String.repeat "─" (Stdlib.Int64.max 0L (region.cols - 5L)) + let hBar = Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (Stdlib.Int64.max 0L (region.cols - 5L))) renderScrollableList region branchList.items branchList.selected 2L 4L (fun r cardRow item isSelected -> let borderColor = if isSelected then Darklang.Cli.Colors.cyan else dim let bar = Darklang.Cli.Colors.colorize borderColor "│" @@ -469,7 +469,7 @@ let renderBranchListBody (branchList: BranchListState) (region: Darklang.Cli.UI. let renderDetailBody (detail: DetailState) (region: Darklang.Cli.UI.Layout.Region) : Unit = printLine region 0L $" {Darklang.Cli.Colors.dim}review >{Darklang.Cli.Colors.reset} {Darklang.Cli.Colors.cyan}{detail.branchName}{Darklang.Cli.Colors.reset}" let itemCount = Stdlib.List.length detail.flatItems - if itemCount == 0L then + if itemCount == 0I then printLine region 2L (Darklang.Cli.Colors.colorize Darklang.Cli.Colors.dim " No changes on this branch.") clearRows region 3L else @@ -496,11 +496,11 @@ let renderDiffBody (diffState: DiffState) (region: Darklang.Cli.UI.Layout.Region | ReturnToCommits commitList -> commitList.branchName printLine region 0L $" {Darklang.Cli.Colors.dim}review > {branchName} >{Darklang.Cli.Colors.reset} {Darklang.Cli.Colors.cyan}{diffState.itemName}{Darklang.Cli.Colors.reset}" let listRows = region.rows - 2L - let lineCount = Stdlib.List.length diffState.diffLines + let lineCount = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length diffState.diffLines)) diffState.diffLines - |> Stdlib.List.indexedMap (fun idx line -> (idx, line)) - |> Stdlib.List.drop diffState.scrollOffset - |> Stdlib.List.take listRows + |> Stdlib.List.indexedMap (fun idx line -> (Builtin.unwrap (Stdlib.Int.toInt64 idx), line)) + |> Stdlib.List.drop (Stdlib.Int.fromInt64 diffState.scrollOffset) + |> Stdlib.List.take (Stdlib.Int.fromInt64 listRows) |> Stdlib.List.iter (fun pair -> let (idx, diffLine) = pair let row = (idx - diffState.scrollOffset) + 2L @@ -515,7 +515,7 @@ let renderDiffBody (diffState: DiffState) (region: Darklang.Cli.UI.Layout.Region let renderCommitListBody (commitList: CommitListState) (region: Darklang.Cli.UI.Layout.Region) : Unit = printLine region 0L $" {Darklang.Cli.Colors.dim}review > {commitList.branchName} >{Darklang.Cli.Colors.reset} {Darklang.Cli.Colors.bold}commits{Darklang.Cli.Colors.reset}" let itemCount = Stdlib.List.length commitList.commits - if itemCount == 0L then + if itemCount == 0I then printLine region 2L (Darklang.Cli.Colors.colorize Darklang.Cli.Colors.dim " No commits on this branch.") clearRows region 3L else diff --git a/packages/darklang/cli/scm/review/core.dark b/packages/darklang/cli/scm/review/core.dark index 1a75d23456..b1859ec0e6 100644 --- a/packages/darklang/cli/scm/review/core.dark +++ b/packages/darklang/cli/scm/review/core.dark @@ -77,7 +77,7 @@ let moveDown (selected: Int64) (itemCount: Int64) : Int64 = /// Move up, skipping empty spacer items let moveUpSkipping (selected: Int64) (items: List) : Int64 = let candidate = moveUp selected - match Stdlib.List.getAt items candidate with + match Stdlib.List.getAt items (Stdlib.Int.fromInt64 candidate) with | Some flatItem -> match flatItem with | ModuleHeader modPath -> @@ -88,9 +88,9 @@ let moveUpSkipping (selected: Int64) (items: List) : Int64 = /// Move down, skipping empty spacer items let moveDownSkipping (selected: Int64) (items: List) : Int64 = - let itemCount = Stdlib.List.length items + let itemCount = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length items)) let candidate = moveDown selected itemCount - match Stdlib.List.getAt items candidate with + match Stdlib.List.getAt items (Stdlib.Int.fromInt64 candidate) with | Some flatItem -> match flatItem with | ModuleHeader modPath -> diff --git a/packages/darklang/cli/tracing.dark b/packages/darklang/cli/tracing.dark index 48c6dd0485..06acdd83cb 100644 --- a/packages/darklang/cli/tracing.dark +++ b/packages/darklang/cli/tracing.dark @@ -536,9 +536,9 @@ let executeHotspots state | _ -> let fnCount = Stdlib.List.length rows - let fnWord = if fnCount == 1L then "fn" else "fns" + let fnWord = if fnCount == 1I then "fn" else "fns" Stdlib.printLine - $"Hotspots (last {Stdlib.Int64.toString traceLimit} traces, top {Stdlib.Int64.toString fnCount} {fnWord} by total ms):" + $"Hotspots (last {Stdlib.Int64.toString traceLimit} traces, top {Stdlib.Int.toString fnCount} {fnWord} by total ms):" Stdlib.printLine "" Stdlib.printLine " total ms │ max ms │ count │ fn" Stdlib.printLine " ─────────┼──────────┼───────┼─────────────────────────" @@ -697,7 +697,7 @@ let executeTail | None -> allRows // Drop the first (n-1) — the Nth-most-recent is what's left at head. - let after = Stdlib.List.drop candidates (n - 1L) + let after = Stdlib.List.drop candidates (Stdlib.Int.fromInt64 (n - 1L)) match after with | [] -> let suffix = @@ -887,7 +887,7 @@ let executeListByRoute |> Stdlib.List.filter (fun row -> Stdlib.String.contains (Stdlib.String.toUppercase row.handler) routeUpper) - |> Stdlib.List.take limit + |> Stdlib.List.take (Stdlib.Int.fromInt64 limit) if jsonMode then Stdlib.printLine (Stdlib.Json.serialize> matching) @@ -1003,7 +1003,7 @@ let renderCall renderCall opts branchId childrenMap c childDepth matchedHere) |> Stdlib.List.flatten if visible then - let indent = Stdlib.String.repeat " " (depth + 1L) + let indent = Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (depth + 1L)) let resultRepr = compactDval branchId call.result let durationSuffix = if call.durationMs > 0L then diff --git a/packages/darklang/cli/ui/components/button.dark b/packages/darklang/cli/ui/components/button.dark index a76b7e826f..ce6ad72f04 100644 --- a/packages/darklang/cli/ui/components/button.dark +++ b/packages/darklang/cli/ui/components/button.dark @@ -41,12 +41,12 @@ let renderButton (component: Core.Types.Component) (context: Core.T Core.Rendering.colorize model.color model.text // Build padded text with spacing around styled content - let paddedText = Stdlib.String.repeat " " leftPad ++ styledText ++ Stdlib.String.repeat " " rightPad + let paddedText = Stdlib.String.repeat " " (Stdlib.Int.fromInt64 leftPad) ++ styledText ++ Stdlib.String.repeat " " (Stdlib.Int.fromInt64 rightPad) let focusIndicator = if hasFocus then "► " else " " - [ focusIndicator ++ "┌" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 2L) ++ "┐" + [ focusIndicator ++ "┌" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 2L)) ++ "┐" focusIndicator ++ "│" ++ paddedText ++ "│" - focusIndicator ++ "└" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 2L) ++ "┘" ] + focusIndicator ++ "└" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 2L)) ++ "┘" ] let setButtonText (component: Core.Types.Component) (text: String) : Core.Types.Component = let model = component.model diff --git a/packages/darklang/cli/ui/components/card.dark b/packages/darklang/cli/ui/components/card.dark index 68f59fe59e..4dbd456a25 100644 --- a/packages/darklang/cli/ui/components/card.dark +++ b/packages/darklang/cli/ui/components/card.dark @@ -59,7 +59,7 @@ let renderCard (component: Core.Types.Component) (context: Core.Types else // Calculate padding based on raw text, then apply styling let titleLen = Stdlib.String.length model.title - let rightPad = if innerWidth > titleLen then Stdlib.String.repeat " " (innerWidth - titleLen) else "" + let rightPad = if innerWidth > titleLen then Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (innerWidth - titleLen)) else "" let styledTitle = Core.Rendering.colorize model.headerColor (Core.Rendering.bold model.title) left ++ " " ++ styledTitle ++ rightPad ++ " " ++ right @@ -70,14 +70,14 @@ let renderCard (component: Core.Types.Component) (context: Core.Types let paddedSubtitle = Core.Rendering.padText model.subtitle innerWidth Core.Types.Alignment.Left left ++ " " ++ paddedSubtitle ++ " " ++ right - let headerSeparator = left ++ Stdlib.String.repeat horizontal (model.width - 2L) ++ right + let headerSeparator = left ++ Stdlib.String.repeat horizontal (Stdlib.Int.fromInt64 (model.width - 2L)) ++ right [titleLine; subtitleLine; headerSeparator] |> Stdlib.List.filter (fun line -> Stdlib.Bool.not (Stdlib.String.isEmpty line)) // Create content section let contentLines = - let maxContentHeight = model.height - 2L - Stdlib.List.length headerLines - Stdlib.List.length model.footer + let maxContentHeight = (Stdlib.Int.fromInt64 (model.height - 2L)) - Stdlib.List.length headerLines - Stdlib.List.length model.footer let paddedContent = model.content |> Stdlib.List.take maxContentHeight @@ -88,8 +88,8 @@ let renderCard (component: Core.Types.Component) (context: Core.Types let remainingHeight = maxContentHeight - Stdlib.List.length paddedContent let emptyLines = - if remainingHeight > 0L then - let emptyLine = left ++ Stdlib.String.repeat " " (model.width - 2L) ++ right + if remainingHeight > 0I then + let emptyLine = left ++ Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (model.width - 2L)) ++ right match Stdlib.List.repeat remainingHeight emptyLine with | Ok lines -> lines | Error _ -> [] @@ -104,7 +104,7 @@ let renderCard (component: Core.Types.Component) (context: Core.Types if Stdlib.List.isEmpty model.footer then [] else - let footerSeparator = left ++ (Stdlib.String.repeat horizontal (model.width - 2L)) ++ right + let footerSeparator = left ++ (Stdlib.String.repeat horizontal (Stdlib.Int.fromInt64 (model.width - 2L))) ++ right let footerContent = model.footer |> Stdlib.List.map (fun line -> @@ -117,11 +117,11 @@ let renderCard (component: Core.Types.Component) (context: Core.Types // Create borders let topBorder = if Stdlib.List.isEmpty headerLines then - top ++ (Stdlib.String.repeat horizontal (model.width - 2L)) ++ topRight + top ++ (Stdlib.String.repeat horizontal (Stdlib.Int.fromInt64 (model.width - 2L))) ++ topRight else - top ++ (Stdlib.String.repeat horizontal (model.width - 2L)) ++ topRight + top ++ (Stdlib.String.repeat horizontal (Stdlib.Int.fromInt64 (model.width - 2L))) ++ topRight - let bottomBorder = bottom ++ (Stdlib.String.repeat horizontal (model.width - 2L)) ++ bottomRight + let bottomBorder = bottom ++ (Stdlib.String.repeat horizontal (Stdlib.Int.fromInt64 (model.width - 2L))) ++ bottomRight // Combine all sections let cardContent = @@ -136,12 +136,12 @@ let renderCard (component: Core.Types.Component) (context: Core.Types let shadowedContent = cardContent |> Stdlib.List.indexedMap (fun i line -> - if i == Stdlib.List.length cardContent - 1L then - line ++ " " ++ (Core.Rendering.dim (Stdlib.String.repeat "▄" (model.width - 1L))) + if i == Stdlib.List.length cardContent - 1I then + line ++ " " ++ (Core.Rendering.dim (Stdlib.String.repeat "▄" (Stdlib.Int.fromInt64 (model.width - 1L)))) else line ++ Core.Rendering.dim "▌") - let shadowBottom = " " ++ (Core.Rendering.dim (Stdlib.String.repeat "▀" model.width)) + let shadowBottom = " " ++ (Core.Rendering.dim (Stdlib.String.repeat "▀" (Stdlib.Int.fromInt64 model.width))) shadowedContent |> Stdlib.List.append [shadowBottom] else @@ -202,20 +202,20 @@ let createMediaCard (title: String) (description: String) (mediaWidth: Int64) (m let renderMediaCard (component: Core.Types.Component) (context: Core.Types.RenderContext) : List = let model = component.model - let topBorder = "┌" ++ (Stdlib.String.repeat "─" (model.width - 2L)) ++ "┐" - let bottomBorder = "└" ++ (Stdlib.String.repeat "─" (model.width - 2L)) ++ "┘" + let topBorder = "┌" ++ (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L))) ++ "┐" + let bottomBorder = "└" ++ (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L))) ++ "┘" // Create media placeholder let mediaLines = - let centerY = Stdlib.Int64.divide model.mediaHeight 2L - (Stdlib.List.range 0L model.mediaHeight) + let centerY = Stdlib.Int.fromInt64 (Stdlib.Int64.divide model.mediaHeight 2L) + (Stdlib.List.range 0I (Stdlib.Int.fromInt64 model.mediaHeight)) |> Stdlib.List.map (fun i -> if i == centerY then let centeredPlaceholder = Core.Rendering.padText model.mediaPlaceholder model.mediaWidth Core.Types.Alignment.Center let borderedLine = Core.Rendering.padText centeredPlaceholder (model.width - 4L) Core.Types.Alignment.Center "│ " ++ borderedLine ++ " │" else - let emptyLine = Stdlib.String.repeat " " (model.width - 4L) + let emptyLine = Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (model.width - 4L)) "│ " ++ emptyLine ++ " │") // Create title and description @@ -228,7 +228,7 @@ let renderMediaCard (component: Core.Types.Component) (context: let paddedDesc = Core.Rendering.padText model.description (model.width - 4L) Core.Types.Alignment.Left "│ " ++ paddedDesc ++ " │" - let separatorLine = "├" ++ (Stdlib.String.repeat "─" (model.width - 2L)) ++ "┤" + let separatorLine = "├" ++ (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L))) ++ "┤" // Create actions if any let actionLines = diff --git a/packages/darklang/cli/ui/components/divider.dark b/packages/darklang/cli/ui/components/divider.dark index 411a13d384..abcdd9f024 100644 --- a/packages/darklang/cli/ui/components/divider.dark +++ b/packages/darklang/cli/ui/components/divider.dark @@ -18,7 +18,7 @@ let createDivider (character: String) (length: Int64) (color: Core.Types.Color) let renderDivider (component: Core.Types.Component) (context: Core.Types.RenderContext) : List = let model = component.model - let line = Stdlib.String.repeat model.character model.length + let line = Stdlib.String.repeat model.character (Stdlib.Int.fromInt64 model.length) let coloredLine = Core.Rendering.colorize model.color line [ coloredLine ] diff --git a/packages/darklang/cli/ui/components/dropdown.dark b/packages/darklang/cli/ui/components/dropdown.dark index c91871163d..c6078d5e2d 100644 --- a/packages/darklang/cli/ui/components/dropdown.dark +++ b/packages/darklang/cli/ui/components/dropdown.dark @@ -24,7 +24,7 @@ let createDropdown (placeholder: String) (items: List) : Core.Type |> Stdlib.List.map (fun item -> Stdlib.String.length item.label) |> Stdlib.List.append [Stdlib.String.length placeholder] |> Stdlib.List.fold 20L (fun acc len -> if len > acc then len else acc) - let height = if model.isOpen then Stdlib.Int64.min model.maxHeight (Stdlib.List.length items + 2L) else 1L + let height = if model.isOpen then Stdlib.Int64.min model.maxHeight ((Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length items))) + 2L) else 1L let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = maxWidth + 4L; height = height } } Core.Types.Component { id = "dropdown" @@ -40,7 +40,7 @@ let renderDropdown (component: Core.Types.Component) (context: Co let displayText = if model.selectedIndex >= 0L then - match Stdlib.List.getAt model.items model.selectedIndex with + match Stdlib.List.getAt model.items (Stdlib.Int.fromInt64 model.selectedIndex) with | Some item -> item.label | None -> model.placeholder else @@ -58,13 +58,13 @@ let renderDropdown (component: Core.Types.Component) (context: Co if model.isOpen then let visibleItems = model.items - |> Stdlib.List.take model.maxHeight + |> Stdlib.List.take (Stdlib.Int.fromInt64 model.maxHeight) |> Stdlib.List.indexedMap (fun i item -> if item.separator then - " ├" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 4L) ++ "┤" + " ├" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 4L)) ++ "┤" else - let isSelected = i == model.selectedIndex - let isHovered = hasFocus && i == model.selectedIndex + let isSelected = (Builtin.unwrap (Stdlib.Int.toInt64 i)) == model.selectedIndex + let isHovered = hasFocus && (Builtin.unwrap (Stdlib.Int.toInt64 i)) == model.selectedIndex let prefix = if isSelected then "●" else " " let itemColor = @@ -76,7 +76,7 @@ let renderDropdown (component: Core.Types.Component) (context: Co let paddedLabel = Core.Rendering.padText styledLabel (component.bounds.dimensions.width - 4L) Core.Types.Alignment.Left " │ " ++ paddedLabel ++ " │") - let bottomBorder = " └" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 4L) ++ "┘" + let bottomBorder = " └" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 4L)) ++ "┘" [mainLine] |> Stdlib.List.append visibleItems |> Stdlib.List.append [bottomBorder] @@ -85,8 +85,8 @@ let renderDropdown (component: Core.Types.Component) (context: Co let selectDropdownItem (component: Core.Types.Component) (index: Int64) : Core.Types.Component = let model = component.model - if index >= 0L && index < Stdlib.List.length model.items then - match Stdlib.List.getAt model.items index with + if index >= 0L && index < (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length model.items))) then + match Stdlib.List.getAt model.items (Stdlib.Int.fromInt64 index) with | Some item -> if item.disabled || item.separator then component @@ -128,7 +128,7 @@ let createMultiSelect (placeholder: String) (items: List) (maxSele |> Stdlib.List.map (fun item -> Stdlib.String.length item.label) |> Stdlib.List.append [Stdlib.String.length placeholder] |> Stdlib.List.fold 25L (fun acc len -> if len > acc then len else acc) - let height = if model.isOpen then Stdlib.Int64.min model.maxHeight (Stdlib.List.length items + 2L) else 1L + let height = if model.isOpen then Stdlib.Int64.min model.maxHeight ((Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length items))) + 2L) else 1L let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = maxWidth + 4L; height = height } } Core.Types.Component { id = "multiselect" @@ -147,7 +147,7 @@ let renderMultiSelect (component: Core.Types.Component) (conte model.placeholder else let selectedCount = Stdlib.List.length model.selectedIndices - Stdlib.Int64.toString selectedCount ++ " selected" + Stdlib.Int.toString selectedCount ++ " selected" let paddedText = Core.Rendering.padText displayText (component.bounds.dimensions.width - 6L) Core.Types.Alignment.Left let arrow = if model.isOpen then "▲" else "▼" @@ -161,12 +161,12 @@ let renderMultiSelect (component: Core.Types.Component) (conte if model.isOpen then let visibleItems = model.items - |> Stdlib.List.take model.maxHeight + |> Stdlib.List.take (Stdlib.Int.fromInt64 model.maxHeight) |> Stdlib.List.indexedMap (fun i item -> if item.separator then - " ├" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 4L) ++ "┤" + " ├" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 4L)) ++ "┤" else - let isSelected = Stdlib.List.``member`` model.selectedIndices i + let isSelected = Stdlib.List.``member`` model.selectedIndices (Builtin.unwrap (Stdlib.Int.toInt64 i)) let checkMark = if isSelected then "☑" else "☐" let itemColor = @@ -178,7 +178,7 @@ let renderMultiSelect (component: Core.Types.Component) (conte let paddedLabel = Core.Rendering.padText styledLabel (component.bounds.dimensions.width - 4L) Core.Types.Alignment.Left " │ " ++ paddedLabel ++ " │") - let bottomBorder = " └" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 4L) ++ "┘" + let bottomBorder = " └" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 4L)) ++ "┘" [mainLine] |> Stdlib.List.append visibleItems |> Stdlib.List.append [bottomBorder] @@ -187,8 +187,8 @@ let renderMultiSelect (component: Core.Types.Component) (conte let toggleMultiSelectItem (component: Core.Types.Component) (index: Int64) : Core.Types.Component = let model = component.model - if index >= 0L && index < Stdlib.List.length model.items then - match Stdlib.List.getAt model.items index with + if index >= 0L && index < (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length model.items))) then + match Stdlib.List.getAt model.items (Stdlib.Int.fromInt64 index) with | Some item -> if item.disabled || item.separator then component @@ -198,7 +198,7 @@ let toggleMultiSelectItem (component: Core.Types.Component) (i if isSelected then Stdlib.List.filter model.selectedIndices (fun i -> i != index) else - if Stdlib.List.length model.selectedIndices < model.maxSelections then + if (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length model.selectedIndices))) < model.maxSelections then model.selectedIndices |> Stdlib.List.append [index] else @@ -220,7 +220,7 @@ let createContextMenu (items: List) : Core.Types.Component Stdlib.List.map (fun item -> Stdlib.String.length item.label + 4L) |> Stdlib.List.fold 15L (fun acc len -> if len > acc then len else acc) - let height = Stdlib.List.length items + 2L + let height = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length items))) + 2L let bounds = Core.Types.Bounds { position = model.position; dimensions = Core.Types.Dimensions { width = maxWidth; height = height } } Core.Types.Component { id = "contextmenu" @@ -237,14 +237,14 @@ let renderContextMenu (component: Core.Types.Component) (conte else let hasFocus = context.hasFocus && component.state == Core.Types.ComponentState.Focused - let topBorder = "┌" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 2L) ++ "┐" - let bottomBorder = "└" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 2L) ++ "┘" + let topBorder = "┌" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 2L)) ++ "┐" + let bottomBorder = "└" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 2L)) ++ "┘" let menuItems = model.items |> Stdlib.List.map (fun item -> if item.separator then - "├" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 2L) ++ "┤" + "├" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 2L)) ++ "┤" else let itemColor = if item.disabled then Core.Types.Color.Dark else Core.Types.Color.Default let paddedLabel = Core.Rendering.padText item.label (component.bounds.dimensions.width - 4L) Core.Types.Alignment.Left diff --git a/packages/darklang/cli/ui/components/forms.dark b/packages/darklang/cli/ui/components/forms.dark index 890746db70..fce64863f7 100644 --- a/packages/darklang/cli/ui/components/forms.dark +++ b/packages/darklang/cli/ui/components/forms.dark @@ -29,7 +29,7 @@ let renderTextInput (component: Core.Types.Component) (context: // Calculate padding based on raw text length let (rawValue, styledValue) = if model.password then - let masked = Stdlib.String.repeat "*" (Stdlib.String.length model.value) + let masked = Stdlib.String.repeat "*" (Stdlib.Int.fromInt64 (Stdlib.String.length model.value)) (masked, masked) else if Stdlib.String.isEmpty model.value then (model.placeholder, Core.Rendering.dim model.placeholder) @@ -37,13 +37,13 @@ let renderTextInput (component: Core.Types.Component) (context: (model.value, model.value) let textLen = Stdlib.String.length rawValue - let rightPad = if innerWidth > textLen then Stdlib.String.repeat " " (innerWidth - textLen) else "" + let rightPad = if innerWidth > textLen then Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (innerWidth - textLen)) else "" let cursor = if hasFocus then "│" else " " let focusIndicator = if hasFocus then "► " else " " - [ focusIndicator ++ "┌" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 2L) ++ "┐" + [ focusIndicator ++ "┌" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 2L)) ++ "┐" focusIndicator ++ "│ " ++ styledValue ++ rightPad ++ cursor ++ " │" - focusIndicator ++ "└" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 2L) ++ "┘" ] + focusIndicator ++ "└" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 2L)) ++ "┘" ] let updateTextInput (component: Core.Types.Component) (event: Core.Types.ComponentEvent) : Core.Types.Component = match event with @@ -125,7 +125,7 @@ let createRadioGroup (options: List) (selectedIndex: Int64) : Core.Types options |> Stdlib.List.map (fun opt -> Stdlib.String.length opt + 6L) |> Stdlib.List.fold 20L (fun acc len -> if len > acc then len else acc) - let height = Stdlib.List.length options + let height = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length options)) let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = maxWidth; height = height } } Core.Types.Component { id = "radiogroup" @@ -141,20 +141,20 @@ let renderRadioGroup (component: Core.Types.Component) (context: Cor model.options |> Stdlib.List.indexedMap (fun i option -> - let isSelected = i == model.selectedIndex + let isSelected = (Builtin.unwrap (Stdlib.Int.toInt64 i)) == model.selectedIndex let radioSymbol = if isSelected then "●" else "○" let boxColor = if model.disabled then Core.Types.Color.Dark else Core.Types.Color.Primary let labelColor = if model.disabled then Core.Types.Color.Dark else Core.Types.Color.Default let styledRadio = Core.Rendering.colorize boxColor ("(" ++ radioSymbol ++ ")") let styledLabel = Core.Rendering.colorize labelColor option - let focusIndicator = if hasFocus && i == model.selectedIndex then "► " else " " + let focusIndicator = if hasFocus && (Builtin.unwrap (Stdlib.Int.toInt64 i)) == model.selectedIndex then "► " else " " focusIndicator ++ styledRadio ++ " " ++ styledLabel) let selectRadioOption (component: Core.Types.Component) (index: Int64) : Core.Types.Component = let model = component.model - if model.disabled || index < 0L || index >= Stdlib.List.length model.options then + if model.disabled || index < 0L || index >= (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length model.options))) then component else { component with model = { model with selectedIndex = index } } @@ -173,7 +173,7 @@ let createSelect (options: List) (selectedIndex: Int64) : Core.Types.Com options |> Stdlib.List.map Stdlib.String.length |> Stdlib.List.fold 10L (fun acc len -> if len > acc then len else acc) - let baseHeight = if model.isOpen then Stdlib.List.length options + 2L else 1L + let baseHeight = if model.isOpen then (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length options))) + 2L else 1L let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = maxWidth + 4L; height = baseHeight } } Core.Types.Component { id = "select" @@ -188,7 +188,7 @@ let renderSelect (component: Core.Types.Component) (context: Core.T let hasFocus = context.hasFocus && component.state == Core.Types.ComponentState.Focused let selectedOption = - match Stdlib.List.getAt model.options model.selectedIndex with + match Stdlib.List.getAt model.options (Stdlib.Int.fromInt64 model.selectedIndex) with | Some opt -> opt | None -> "" @@ -202,7 +202,7 @@ let renderSelect (component: Core.Types.Component) (context: Core.T let optionLines = model.options |> Stdlib.List.indexedMap (fun i option -> - let isSelected = i == model.selectedIndex + let isSelected = (Builtin.unwrap (Stdlib.Int.toInt64 i)) == model.selectedIndex let prefix = if isSelected then "►" else " " let styledOption = if isSelected then @@ -211,7 +211,7 @@ let renderSelect (component: Core.Types.Component) (context: Core.T prefix ++ " " ++ option " │" ++ Core.Rendering.padText styledOption (component.bounds.dimensions.width - 4L) Core.Types.Alignment.Left ++ "│") - let bottomLine = " └" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 2L) ++ "┘" + let bottomLine = " └" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 2L)) ++ "┘" [mainLine] |> Stdlib.List.append optionLines |> Stdlib.List.append [bottomLine] @@ -262,14 +262,14 @@ let renderSlider (component: Core.Types.Component) (context: Core.T |> Builtin.unwrap let emptyWidth = Stdlib.Int64.subtract model.width filledWidth - let track = Stdlib.String.repeat "═" filledWidth ++ Stdlib.String.repeat "─" emptyWidth + let track = Stdlib.String.repeat "═" (Stdlib.Int.fromInt64 filledWidth) ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 emptyWidth) let handle = "●" let valueText = "Value: " ++ Stdlib.Float.toString model.value let focusIndicator = if hasFocus then "► " else " " [ focusIndicator ++ model.label ++ " (" ++ valueText ++ ")" focusIndicator ++ "├" ++ track ++ "┤" - focusIndicator ++ Stdlib.String.repeat " " filledWidth ++ handle ] + focusIndicator ++ Stdlib.String.repeat " " (Stdlib.Int.fromInt64 filledWidth) ++ handle ] let updateSlider (component: Core.Types.Component) (direction: String) : Core.Types.Component = let model = component.model diff --git a/packages/darklang/cli/ui/components/layout.dark b/packages/darklang/cli/ui/components/layout.dark index dc5d85078e..bc9fe56c31 100644 --- a/packages/darklang/cli/ui/components/layout.dark +++ b/packages/darklang/cli/ui/components/layout.dark @@ -44,7 +44,7 @@ type PanelModel = let createPanel (title: String) (content: List) (color: Core.Types.Color) : Core.Types.Component = let model = PanelModel { content = content; title = title; color = color; collapsible = false; collapsed = false } - let contentHeight = if model.collapsed then 1L else Stdlib.List.length content + 2L + let contentHeight = if model.collapsed then 1L else (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length content))) + 2L let maxWidth = (Stdlib.List.push content title) |> Stdlib.List.map Stdlib.String.length @@ -90,7 +90,7 @@ type GridModel<'TItem> = let createGrid (items: List<'TItem>) (columns: Int64) (itemWidth: Int64) (itemHeight: Int64) : Core.Types.Component> = let model = GridModel { items = items; columns = columns; spacing = 1L; itemWidth = itemWidth; itemHeight = itemHeight } - let rows = Stdlib.Int64.divide (Stdlib.List.length items + columns - 1L) columns + let rows = Stdlib.Int64.divide ((Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length items))) + columns - 1L) columns let totalWidth = columns * itemWidth + (columns - 1L) * model.spacing let totalHeight = rows * itemHeight + (rows - 1L) * model.spacing let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = totalWidth; height = totalHeight } } @@ -107,7 +107,7 @@ let renderGrid (component: Core.Types.Component>) (context: Co // Simplified grid rendering - just render items in a vertical list for now model.items |> Stdlib.List.indexedMap (fun index item -> - let renderedItem = renderItem item index context + let renderedItem = renderItem item (Builtin.unwrap (Stdlib.Int.toInt64 index)) context renderedItem) |> Stdlib.List.flatten @@ -137,17 +137,17 @@ let renderHStack (component: Core.Types.Component>) (context let maxHeight = itemRenderings |> Stdlib.List.map Stdlib.List.length - |> Stdlib.List.fold 1L (fun acc len -> if len > acc then len else acc) + |> Stdlib.List.fold 1I (fun acc len -> if len > acc then len else acc) // Combine items horizontally line by line - (Stdlib.List.range 0L (maxHeight - 1L)) + (Stdlib.List.range 0I (maxHeight - 1I)) |> Stdlib.List.map (fun lineIndex -> itemRenderings |> Stdlib.List.map (fun itemLines -> match Stdlib.List.getAt itemLines lineIndex with | Some line -> line | None -> "") - |> Stdlib.String.join (Stdlib.String.repeat " " model.spacing)) + |> Stdlib.String.join (Stdlib.String.repeat " " (Stdlib.Int.fromInt64 model.spacing))) // Vertical Stack Component type VStackModel<'TItem> = @@ -167,7 +167,7 @@ let createVStack (items: List<'TItem>) (spacing: Int64) : Core.Types.Component>) (context: Core.Types.RenderContext) (renderItem: 'TItem -> Core.Types.RenderContext -> List) : List = let model = component.model - let spacingLines = (Stdlib.List.range 0L (model.spacing - 1L)) |> Stdlib.List.map (fun _ -> "") + let spacingLines = (Stdlib.List.range 0I (Stdlib.Int.fromInt64 (model.spacing - 1L))) |> Stdlib.List.map (fun _ -> "") model.items |> Stdlib.List.map (fun item -> renderItem item context) diff --git a/packages/darklang/cli/ui/components/listview.dark b/packages/darklang/cli/ui/components/listview.dark index 4a29410432..d443cddfa4 100644 --- a/packages/darklang/cli/ui/components/listview.dark +++ b/packages/darklang/cli/ui/components/listview.dark @@ -34,17 +34,17 @@ let renderListView (component: Core.Types.Component) (context: Co let visibleItems = model.items - |> Stdlib.List.drop model.scrollOffset - |> Stdlib.List.take (model.height - 2L) + |> Stdlib.List.drop (Stdlib.Int.fromInt64 model.scrollOffset) + |> Stdlib.List.take (Stdlib.Int.fromInt64 (model.height - 2L)) let content = visibleItems |> Stdlib.List.indexedMap (fun i item -> - let globalIndex = model.scrollOffset + i + let globalIndex = model.scrollOffset + (Builtin.unwrap (Stdlib.Int.toInt64 i)) let marker = if globalIndex == model.selectedIndex then "▶ " else " " let rawText = marker ++ item.text let textLen = Stdlib.String.length rawText - let rightPad = if innerWidth > textLen then Stdlib.String.repeat " " (innerWidth - textLen) else "" + let rightPad = if innerWidth > textLen then Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (innerWidth - textLen)) else "" // Style after calculating padding let styledText = @@ -59,8 +59,8 @@ let renderListView (component: Core.Types.Component) (context: Co styledText ++ rightPad) - let topBorder = "┌" ++ Stdlib.String.repeat "─" (model.width - 2L) ++ "┐" - let bottomBorder = "└" ++ Stdlib.String.repeat "─" (model.width - 2L) ++ "┘" + let topBorder = "┌" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L)) ++ "┐" + let bottomBorder = "└" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L)) ++ "┘" let contentLines = content |> Stdlib.List.map (fun line -> "│ " ++ line ++ " │") @@ -71,11 +71,11 @@ let renderListView (component: Core.Types.Component) (context: Co let selectItem (component: Core.Types.Component) (index: Int64) : Core.Types.Component = let model = component.model - let clampedIndex = Stdlib.Int64.max 0L (Stdlib.Int64.min index (Stdlib.List.length model.items - 1L)) + let clampedIndex = Stdlib.Int64.max 0L (Stdlib.Int64.min index ((Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length model.items))) - 1L)) { component with model = { model with selectedIndex = clampedIndex } } let getSelectedItem (component: Core.Types.Component) : ListItem = let model = component.model - match Stdlib.List.getAt model.items model.selectedIndex with + match Stdlib.List.getAt model.items (Stdlib.Int.fromInt64 model.selectedIndex) with | Some item -> item | None -> ListItem { text = ""; enabled = false; data = "" } \ No newline at end of file diff --git a/packages/darklang/cli/ui/components/message.dark b/packages/darklang/cli/ui/components/message.dark index d919a2a2b4..1f6d6edf98 100644 --- a/packages/darklang/cli/ui/components/message.dark +++ b/packages/darklang/cli/ui/components/message.dark @@ -35,8 +35,8 @@ let renderMessage (component: Core.Types.Component) (context: Core | Info -> "ℹ" | _ -> "•" - let topBorder = "┌" ++ Stdlib.String.repeat "─" (model.width - 2L) ++ "┐" - let bottomBorder = "└" ++ Stdlib.String.repeat "─" (model.width - 2L) ++ "┘" + let topBorder = "┌" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L)) ++ "┐" + let bottomBorder = "└" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L)) ++ "┘" let titleLine = let dismissButton = if model.isDismissible then "✕" else "" @@ -46,7 +46,7 @@ let renderMessage (component: Core.Types.Component) (context: Core let rawTitleLen = Stdlib.String.length rawTitle let innerWidth = model.width - 4L // borders and padding let paddingNeeded = innerWidth - rawTitleLen - dismissLen - let rightPad = if paddingNeeded > 0L then Stdlib.String.repeat " " paddingNeeded else "" + let rightPad = if paddingNeeded > 0L then Stdlib.String.repeat " " (Stdlib.Int.fromInt64 paddingNeeded) else "" // Apply styling after calculating padding let styledTitle = Core.Rendering.colorize model.messageType (Core.Rendering.bold rawTitle) @@ -111,14 +111,14 @@ let renderToast (component: Core.Types.Component) (context: Core.Typ let rawText = typeIcon ++ " " ++ model.message let innerWidth = component.bounds.dimensions.width - 4L let textLen = Stdlib.String.length rawText - let rightPad = if innerWidth > textLen then Stdlib.String.repeat " " (innerWidth - textLen) else "" + let rightPad = if innerWidth > textLen then Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (innerWidth - textLen)) else "" // Style the content let styledContent = Core.Rendering.colorize model.toastType rawText - let topBorder = "╭" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 2L) ++ "╮" + let topBorder = "╭" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 2L)) ++ "╮" let contentLine = "│ " ++ styledContent ++ rightPad ++ " │" - let bottomBorder = "╰" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 2L) ++ "╯" + let bottomBorder = "╰" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 2L)) ++ "╯" [topBorder; contentLine; bottomBorder] diff --git a/packages/darklang/cli/ui/components/modal.dark b/packages/darklang/cli/ui/components/modal.dark index 788e2fb84a..d62fd7852f 100644 --- a/packages/darklang/cli/ui/components/modal.dark +++ b/packages/darklang/cli/ui/components/modal.dark @@ -35,15 +35,15 @@ let renderModal (component: Core.Types.Component) (context: Core.Typ let backdropWidth = 60L let backdropHeight = 20L let backdrop = - Stdlib.List.repeat backdropHeight (Core.Rendering.dim (Stdlib.String.repeat "░" backdropWidth)) + Stdlib.List.repeat (Stdlib.Int.fromInt64 backdropHeight) (Core.Rendering.dim (Stdlib.String.repeat "░" (Stdlib.Int.fromInt64 backdropWidth))) // Calculate modal position (centered) let modalX = Stdlib.Int64.divide (backdropWidth - model.width) 2L - let modalY = Stdlib.Int64.divide (backdropHeight - model.height) 2L + let modalY = Stdlib.Int.fromInt64 (Stdlib.Int64.divide (backdropHeight - model.height) 2L) // Create modal box - let topBorder = "╔" ++ Stdlib.String.repeat "═" (model.width - 2L) ++ "╗" - let bottomBorder = "╚" ++ Stdlib.String.repeat "═" (model.width - 2L) ++ "╝" + let topBorder = "╔" ++ Stdlib.String.repeat "═" (Stdlib.Int.fromInt64 (model.width - 2L)) ++ "╗" + let bottomBorder = "╚" ++ Stdlib.String.repeat "═" (Stdlib.Int.fromInt64 (model.width - 2L)) ++ "╝" let titleLine = let closeButton = if model.hasCloseButton then " ✕" else "" @@ -52,7 +52,7 @@ let renderModal (component: Core.Types.Component) (context: Core.Typ let titleColor = if hasFocus then Core.Types.Color.Primary else Core.Types.Color.Default "║ " ++ Core.Rendering.colorize titleColor (Core.Rendering.bold paddedTitle) ++ closeButton ++ " ║" - let separatorLine = "╠" ++ Stdlib.String.repeat "═" (model.width - 2L) ++ "╣" + let separatorLine = "╠" ++ Stdlib.String.repeat "═" (Stdlib.Int.fromInt64 (model.width - 2L)) ++ "╣" let contentLines = model.content @@ -61,10 +61,10 @@ let renderModal (component: Core.Types.Component) (context: Core.Typ "║ " ++ paddedLine ++ " ║") // Fill remaining space if content is shorter than modal height - let remainingHeight = model.height - 4L - Stdlib.List.length contentLines + let remainingHeight = (Stdlib.Int.fromInt64 (model.height - 4L)) - Stdlib.List.length contentLines let fillerLines = - if remainingHeight > 0L then - Stdlib.List.repeat remainingHeight ("║" ++ Stdlib.String.repeat " " (model.width - 2L) ++ "║") + if remainingHeight > 0I then + Stdlib.List.repeat remainingHeight ("║" ++ Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (model.width - 2L)) ++ "║") else [] @@ -82,8 +82,8 @@ let renderModal (component: Core.Types.Component) (context: Core.Typ let modalLineIndex = i - modalY match Stdlib.List.getAt modalContent modalLineIndex with | Some modalLine -> - let beforeModal = Stdlib.String.repeat " " modalX - let afterModal = Stdlib.String.repeat " " (backdropWidth - modalX - model.width) + let beforeModal = Stdlib.String.repeat " " (Stdlib.Int.fromInt64 modalX) + let afterModal = Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (backdropWidth - modalX - model.width)) beforeModal ++ modalLine ++ afterModal | None -> backdropLine else @@ -136,21 +136,21 @@ let renderConfirmDialog (component: Core.Types.Component) (c else let hasFocus = context.hasFocus && component.state == Core.Types.ComponentState.Focused - let topBorder = "┌" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 2L) ++ "┐" - let bottomBorder = "└" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 2L) ++ "┘" + let topBorder = "┌" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 2L)) ++ "┐" + let bottomBorder = "└" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 2L)) ++ "┘" let titleLine = let paddedTitle = Core.Rendering.padText model.title (component.bounds.dimensions.width - 4L) Core.Types.Alignment.Center let titleColor = if hasFocus then Core.Types.Color.Warning else Core.Types.Color.Default "│ " ++ Core.Rendering.colorize titleColor (Core.Rendering.bold paddedTitle) ++ " │" - let separatorLine = "├" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 2L) ++ "┤" + let separatorLine = "├" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 2L)) ++ "┤" let messageLine = let paddedMessage = Core.Rendering.padText model.message (component.bounds.dimensions.width - 4L) Core.Types.Alignment.Center "│ " ++ paddedMessage ++ " │" - let emptyLine = "│" ++ Stdlib.String.repeat " " (component.bounds.dimensions.width - 2L) ++ "│" + let emptyLine = "│" ++ Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 2L)) ++ "│" let buttonLine = let confirmButton = diff --git a/packages/darklang/cli/ui/components/navigation.dark b/packages/darklang/cli/ui/components/navigation.dark index da74a405ec..89ff8a6bf0 100644 --- a/packages/darklang/cli/ui/components/navigation.dark +++ b/packages/darklang/cli/ui/components/navigation.dark @@ -23,7 +23,7 @@ let createMenu (title: String) (items: List) : Core.Types.Component Stdlib.List.map (fun item -> Stdlib.String.length item.label + Stdlib.String.length item.shortcut + 4L) |> Stdlib.List.fold 20L (fun acc len -> if len > acc then len else acc) - let height = if model.isOpen then Stdlib.List.length items + 2L else 1L + let height = if model.isOpen then (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length items))) + 2L else 1L let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = maxWidth; height = height } } Core.Types.Component { id = "menu-" ++ title @@ -45,7 +45,7 @@ let renderMenu (component: Core.Types.Component) (context: Core.Types let menuItems = model.items |> Stdlib.List.indexedMap (fun i item -> - let isSelected = i == model.selectedIndex + let isSelected = (Builtin.unwrap (Stdlib.Int.toInt64 i)) == model.selectedIndex let prefix = if isSelected then "►" else " " let itemColor = if Stdlib.Bool.not item.enabled then Core.Types.Color.Dark @@ -57,8 +57,8 @@ let renderMenu (component: Core.Types.Component) (context: Core.Types let styledItem = Core.Rendering.colorize itemColor (prefix ++ " " ++ label ++ " " ++ shortcut) "│" ++ styledItem ++ "│") - let topBorder = "┌" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 2L) ++ "┐" - let bottomBorder = "└" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 2L) ++ "┘" + let topBorder = "┌" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 2L)) ++ "┐" + let bottomBorder = "└" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 2L)) ++ "┘" let titleLine = "│" ++ Core.Rendering.padText styledTitle (component.bounds.dimensions.width - 2L) Core.Types.Alignment.Center ++ "│" [ topBorder; titleLine ] @@ -69,7 +69,7 @@ let renderMenu (component: Core.Types.Component) (context: Core.Types let selectMenuItem (component: Core.Types.Component) (index: Int64) : Core.Types.Component = let model = component.model - if index >= 0L && index < Stdlib.List.length model.items then + if index >= 0L && index < (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length model.items))) then { component with model = { model with selectedIndex = index } } else component @@ -86,7 +86,7 @@ type TabModel = let createTabs (tabs: List) (activeIndex: Int64) : Core.Types.Component = let model = TabModel { tabs = tabs; activeIndex = activeIndex; tabWidth = 12L } - let totalWidth = Stdlib.List.length tabs * model.tabWidth + let totalWidth = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length tabs))) * model.tabWidth let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = totalWidth; height = 2L } } Core.Types.Component { id = "tabs" @@ -103,7 +103,7 @@ let renderTabs (component: Core.Types.Component) (context: Core.Types. let tabHeaders = model.tabs |> Stdlib.List.indexedMap (fun i tab -> - let isActive = i == model.activeIndex + let isActive = (Builtin.unwrap (Stdlib.Int.toInt64 i)) == model.activeIndex let isFocused = hasFocus && isActive let tabColor = @@ -115,15 +115,15 @@ let renderTabs (component: Core.Types.Component) (context: Core.Types. let styledTab = Core.Rendering.colorize tabColor paddedTab if isActive then - "┌" ++ Stdlib.String.repeat "─" (model.tabWidth - 2L) ++ "┐" + "┌" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.tabWidth - 2L)) ++ "┐" else - " " ++ Stdlib.String.repeat " " (model.tabWidth - 2L) ++ " ") + " " ++ Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (model.tabWidth - 2L)) ++ " ") |> Stdlib.String.join "" let tabLabels = model.tabs |> Stdlib.List.indexedMap (fun i tab -> - let isActive = i == model.activeIndex + let isActive = (Builtin.unwrap (Stdlib.Int.toInt64 i)) == model.activeIndex let isFocused = hasFocus && isActive let tabColor = @@ -144,7 +144,7 @@ let renderTabs (component: Core.Types.Component) (context: Core.Types. let selectTab (component: Core.Types.Component) (index: Int64) : Core.Types.Component = let model = component.model - if index >= 0L && index < Stdlib.List.length model.tabs then + if index >= 0L && index < (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length model.tabs))) then { component with model = { model with activeIndex = index } } else component @@ -172,7 +172,7 @@ let renderBreadcrumb (component: Core.Types.Component) (context let breadcrumbText = model.crumbs |> Stdlib.List.indexedMap (fun i crumb -> - if i == Stdlib.List.length model.crumbs - 1L then + if i == Stdlib.List.length model.crumbs - 1I then Core.Rendering.colorize Core.Types.Color.Primary crumb // Last crumb is highlighted else crumb) @@ -210,7 +210,7 @@ let renderNavBar (component: Core.Types.Component) (context: Core.T let navItems = model.items |> Stdlib.List.indexedMap (fun i item -> - let isSelected = i == model.selectedIndex && hasFocus + let isSelected = (Builtin.unwrap (Stdlib.Int.toInt64 i)) == model.selectedIndex && hasFocus let itemColor = if Stdlib.Bool.not item.enabled then Core.Types.Color.Dark else if isSelected then Core.Types.Color.Primary @@ -227,7 +227,7 @@ let renderNavBar (component: Core.Types.Component) (context: Core.T let selectNavItem (component: Core.Types.Component) (index: Int64) : Core.Types.Component = let model = component.model - if index >= 0L && index < Stdlib.List.length model.items then + if index >= 0L && index < (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length model.items))) then { component with model = { model with selectedIndex = index } } else component \ No newline at end of file diff --git a/packages/darklang/cli/ui/components/pagination.dark b/packages/darklang/cli/ui/components/pagination.dark index 33b946e04a..13e0cd5071 100644 --- a/packages/darklang/cli/ui/components/pagination.dark +++ b/packages/darklang/cli/ui/components/pagination.dark @@ -65,12 +65,12 @@ let renderPagination (component: Core.Types.Component) (context let endPage = Stdlib.Int64.min model.totalPages (startPage + model.maxVisiblePages - 1L) let adjustedStartPage = Stdlib.Int64.max 1L (endPage - model.maxVisiblePages + 1L) - let pages = Stdlib.List.range adjustedStartPage endPage + let pages = Stdlib.List.range (Stdlib.Int.fromInt64 adjustedStartPage) (Stdlib.Int.fromInt64 endPage) let pageButtons = pages |> Stdlib.List.map (fun page -> - let isCurrent = page == model.currentPage - renderPageButton model.style page isCurrent false) + let isCurrent = (Builtin.unwrap (Stdlib.Int.toInt64 page)) == model.currentPage + renderPageButton model.style (Builtin.unwrap (Stdlib.Int.toInt64 page)) isCurrent false) let prevButton = if model.currentPage > 1L then @@ -202,7 +202,7 @@ let addStep (component: Core.Types.Component) (step: StepMo let newSteps = model.steps |> Stdlib.List.append [step] let newHeight = match model.style with - | Vertical -> (Stdlib.List.length newSteps * 2L) + 1L + | Vertical -> ((Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length newSteps))) * 2L) + 1L | _ -> 3L let newBounds = Core.Types.Bounds { position = component.bounds.position; dimensions = Core.Types.Dimensions { width = model.width; height = newHeight } } { component with @@ -217,8 +217,8 @@ let renderStepNavigation (component: Core.Types.Component) let stepTexts = model.steps |> Stdlib.List.indexedMap (fun i step -> - let stepNumber = Stdlib.Int64.toString (i + 1L) - let isActive = i == model.currentStep + let stepNumber = Stdlib.Int.toString (i + 1I) + let isActive = (Builtin.unwrap (Stdlib.Int.toInt64 i)) == model.currentStep let stepText = if model.showNumbers then stepNumber ++ "." ++ step.title else step.title let stepColor = @@ -234,21 +234,21 @@ let renderStepNavigation (component: Core.Types.Component) let combinedSteps = Stdlib.String.join stepTexts separator let paddedSteps = Core.Rendering.padText combinedSteps model.width Core.Types.Alignment.Center - let topBorder = "┌" ++ (Stdlib.String.repeat "─" (model.width - 2L)) ++ "┐" - let bottomBorder = "└" ++ (Stdlib.String.repeat "─" (model.width - 2L)) ++ "┘" + let topBorder = "┌" ++ (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L))) ++ "┐" + let bottomBorder = "└" ++ (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L))) ++ "┘" let stepLine = "│ " ++ paddedSteps ++ " │" [topBorder; stepLine; bottomBorder] | Vertical -> - let topBorder = "┌" ++ (Stdlib.String.repeat "─" (model.width - 2L)) ++ "┐" - let bottomBorder = "└" ++ (Stdlib.String.repeat "─" (model.width - 2L)) ++ "┘" + let topBorder = "┌" ++ (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L))) ++ "┐" + let bottomBorder = "└" ++ (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L))) ++ "┘" let stepLines = model.steps |> Stdlib.List.indexedMap (fun i step -> - let stepNumber = Stdlib.Int64.toString (i + 1L) - let isActive = i == model.currentStep + let stepNumber = Stdlib.Int.toString (i + 1I) + let isActive = (Builtin.unwrap (Stdlib.Int.toInt64 i)) == model.currentStep let stepText = if model.showNumbers then stepNumber ++ ". " ++ step.title else step.title let stepColor = @@ -266,8 +266,8 @@ let renderStepNavigation (component: Core.Types.Component) let paddedStep = Core.Rendering.padText styledStep (model.width - 4L) Core.Types.Alignment.Left let stepLine = "│ " ++ paddedStep ++ " │" - if i < Stdlib.List.length model.steps - 1L then - [stepLine; "│" ++ (Stdlib.String.repeat " " (model.width - 2L)) ++ "│"] + if i < Stdlib.List.length model.steps - 1I then + [stepLine; "│" ++ (Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (model.width - 2L))) ++ "│"] else [stepLine]) |> Stdlib.List.fold [] Stdlib.List.append @@ -280,7 +280,7 @@ let renderStepNavigation (component: Core.Types.Component) let dotTexts = model.steps |> Stdlib.List.indexedMap (fun i step -> - let isActive = i == model.currentStep + let isActive = (Builtin.unwrap (Stdlib.Int.toInt64 i)) == model.currentStep let dot = if step.isCompleted then "●" else if isActive then "◉" @@ -301,8 +301,8 @@ let renderStepNavigation (component: Core.Types.Component) let goToStep (component: Core.Types.Component) (stepIndex: Int64) : Core.Types.Component = let model = component.model - if stepIndex >= 0L && stepIndex < Stdlib.List.length model.steps then - match Stdlib.List.getAt model.steps stepIndex with + if stepIndex >= 0L && stepIndex < (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length model.steps))) then + match Stdlib.List.getAt model.steps (Stdlib.Int.fromInt64 stepIndex) with | Some step -> if step.isDisabled then component @@ -314,7 +314,7 @@ let goToStep (component: Core.Types.Component) (stepIndex: let nextStep (component: Core.Types.Component) : Core.Types.Component = let model = component.model - if model.currentStep < Stdlib.List.length model.steps - 1L then + if model.currentStep < (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length model.steps))) - 1L then { component with model = { model with currentStep = model.currentStep + 1L } } else component @@ -331,7 +331,7 @@ let completeCurrentStep (component: Core.Types.Component) : let updatedSteps = model.steps |> Stdlib.List.indexedMap (fun i step -> - if i == model.currentStep then + if (Builtin.unwrap (Stdlib.Int.toInt64 i)) == model.currentStep then { step with isCompleted = true } else step) diff --git a/packages/darklang/cli/ui/components/panel.dark b/packages/darklang/cli/ui/components/panel.dark index b98533e85f..3e6d582e34 100644 --- a/packages/darklang/cli/ui/components/panel.dark +++ b/packages/darklang/cli/ui/components/panel.dark @@ -40,7 +40,7 @@ let createPanel (title: String) (width: Int64) : Core.Types.Component) (item: PanelItem) : Core.Types.Component = let model = component.model let newItems = model.items |> Stdlib.List.append [item] - let newHeight = if model.showHeader then Stdlib.List.length newItems + 3L else Stdlib.List.length newItems + 2L + let newHeight = if model.showHeader then (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length newItems))) + 3L else (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length newItems))) + 2L let newBounds = Core.Types.Bounds { position = component.bounds.position; dimensions = Core.Types.Dimensions { width = model.width; height = newHeight } } { component with model = { model with items = newItems } @@ -50,15 +50,15 @@ let renderPanel (component: Core.Types.Component) (context: Core.Typ let model = component.model let hasFocus = context.hasFocus && component.state == Core.Types.ComponentState.Focused - let topBorder = "┌" ++ (Stdlib.String.repeat "─" (model.width - 2L)) ++ "┐" - let bottomBorder = "└" ++ (Stdlib.String.repeat "─" (model.width - 2L)) ++ "┘" + let topBorder = "┌" ++ (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L))) ++ "┐" + let bottomBorder = "└" ++ (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L))) ++ "┘" let headerLines = if model.showHeader then let styledTitle = Core.Rendering.colorize model.headerColor (Core.Rendering.bold model.title) let paddedTitle = Core.Rendering.padText styledTitle (model.width - 4L) Core.Types.Alignment.Center let titleLine = "│ " ++ paddedTitle ++ " │" - let separatorLine = "├" ++ (Stdlib.String.repeat "─" (model.width - 2L)) ++ "┤" + let separatorLine = "├" ++ (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L))) ++ "┤" [titleLine; separatorLine] else [] @@ -67,10 +67,10 @@ let renderPanel (component: Core.Types.Component) (context: Core.Typ model.items |> Stdlib.List.indexedMap (fun i item -> if item.itemType == PanelItemType.Separator then - "├" ++ (Stdlib.String.repeat "─" (model.width - 2L)) ++ "┤" + "├" ++ (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L))) ++ "┤" else - let isSelected = i == model.selectedIndex - let isHovered = hasFocus && i == model.selectedIndex + let isSelected = (Builtin.unwrap (Stdlib.Int.toInt64 i)) == model.selectedIndex + let isHovered = hasFocus && (Builtin.unwrap (Stdlib.Int.toInt64 i)) == model.selectedIndex let prefix = if item.isDisabled then " " @@ -98,8 +98,8 @@ let renderPanel (component: Core.Types.Component) (context: Core.Typ let selectPanelItem (component: Core.Types.Component) (index: Int64) : Core.Types.Component = let model = component.model - if index >= 0L && index < Stdlib.List.length model.items then - match Stdlib.List.getAt model.items index with + if index >= 0L && index < (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length model.items))) then + match Stdlib.List.getAt model.items (Stdlib.Int.fromInt64 index) with | Some item -> if item.isDisabled || item.itemType == PanelItemType.Separator then component @@ -119,7 +119,7 @@ let setPanelColors (component: Core.Types.Component) (headerColor: C let hideHeader (component: Core.Types.Component) : Core.Types.Component = let model = component.model - let newHeight = Stdlib.List.length model.items + 2L + let newHeight = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length model.items))) + 2L let newBounds = Core.Types.Bounds { position = component.bounds.position; dimensions = Core.Types.Dimensions { width = model.width; height = newHeight } } { component with model = { model with showHeader = false } @@ -160,14 +160,14 @@ let renderTabPanel (component: Core.Types.Component) (context: Co match model.tabStyle with | Boxed -> - let topBorder = "┌" ++ (Stdlib.String.repeat "─" (model.width - 2L)) ++ "┐" - let bottomBorder = "└" ++ (Stdlib.String.repeat "─" (model.width - 2L)) ++ "┘" + let topBorder = "┌" ++ (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L))) ++ "┐" + let bottomBorder = "└" ++ (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L))) ++ "┘" let tabLine = let tabTexts = model.tabs |> Stdlib.List.indexedMap (fun i tab -> - let isActive = i == model.activeTabIndex + let isActive = (Builtin.unwrap (Stdlib.Int.toInt64 i)) == model.activeTabIndex let tabColor = if isActive then Core.Types.Color.Primary else Core.Types.Color.Default let styledTab = Core.Rendering.colorize tabColor tab.label if isActive then "[" ++ styledTab ++ "]" else " " ++ styledTab ++ " ") @@ -183,7 +183,7 @@ let renderTabPanel (component: Core.Types.Component) (context: Co let tabTexts = model.tabs |> Stdlib.List.indexedMap (fun i tab -> - let isActive = i == model.activeTabIndex + let isActive = (Builtin.unwrap (Stdlib.Int.toInt64 i)) == model.activeTabIndex if isActive then "●" ++ tab.label else "○" ++ tab.label) let combinedTabs = Stdlib.String.join tabTexts " │ " @@ -197,7 +197,7 @@ let renderTabPanel (component: Core.Types.Component) (context: Co let tabTexts = model.tabs |> Stdlib.List.indexedMap (fun i tab -> - let isActive = i == model.activeTabIndex + let isActive = (Builtin.unwrap (Stdlib.Int.toInt64 i)) == model.activeTabIndex let tabColor = if isActive then Core.Types.Color.Primary else Core.Types.Color.Secondary let styledTab = Core.Rendering.colorize tabColor tab.label if isActive then "(" ++ styledTab ++ ")" else " " ++ styledTab ++ " ") @@ -210,7 +210,7 @@ let renderTabPanel (component: Core.Types.Component) (context: Co let setActiveTab (component: Core.Types.Component) (index: Int64) : Core.Types.Component = let model = component.model - if index >= 0L && index < Stdlib.List.length model.tabs then + if index >= 0L && index < (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length model.tabs))) then { component with model = { model with activeTabIndex = index } } else component @@ -237,7 +237,7 @@ let createFilterPanel (title: String) (width: Int64) : Core.Types.Component) (filter: PanelItem) : Core.Types.Component = let model = component.model let newFilters = model.filters |> Stdlib.List.append [filter] - let newHeight = Stdlib.List.length newFilters + 3L + let newHeight = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length newFilters))) + 3L let newBounds = Core.Types.Bounds { position = component.bounds.position; dimensions = Core.Types.Dimensions { width = model.width; height = newHeight } } { component with model = { model with filters = newFilters } @@ -246,20 +246,20 @@ let addFilter (component: Core.Types.Component) (filter: Panel let renderFilterPanel (component: Core.Types.Component) (context: Core.Types.RenderContext) : List = let model = component.model - let topBorder = "┌" ++ (Stdlib.String.repeat "─" (model.width - 2L)) ++ "┐" - let bottomBorder = "└" ++ (Stdlib.String.repeat "─" (model.width - 2L)) ++ "┘" + let topBorder = "┌" ++ (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L))) ++ "┐" + let bottomBorder = "└" ++ (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L))) ++ "┘" let titleLine = let styledTitle = Core.Rendering.colorize Core.Types.Color.Primary (Core.Rendering.bold model.title) let paddedTitle = Core.Rendering.padText styledTitle (model.width - 4L) Core.Types.Alignment.Left "│ " ++ paddedTitle ++ " │" - let separatorLine = "├" ++ (Stdlib.String.repeat "─" (model.width - 2L)) ++ "┤" + let separatorLine = "├" ++ (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L))) ++ "┤" let filterLines = model.filters |> Stdlib.List.indexedMap (fun i filter -> - let isApplied = Stdlib.List.``member`` model.appliedFilters i + let isApplied = Stdlib.List.``member`` model.appliedFilters (Builtin.unwrap (Stdlib.Int.toInt64 i)) let checkbox = if isApplied then "☑" else "☐" let filterColor = if isApplied then Core.Types.Color.Success else Core.Types.Color.Default let styledLabel = Core.Rendering.colorize filterColor (checkbox ++ " " ++ filter.label) @@ -272,7 +272,7 @@ let renderFilterPanel (component: Core.Types.Component) (conte let toggleFilter (component: Core.Types.Component) (index: Int64) : Core.Types.Component = let model = component.model - if index >= 0L && index < Stdlib.List.length model.filters then + if index >= 0L && index < (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length model.filters))) then let isApplied = Stdlib.List.``member`` model.appliedFilters index let newAppliedFilters = if isApplied then diff --git a/packages/darklang/cli/ui/components/progress.dark b/packages/darklang/cli/ui/components/progress.dark index 19166d42de..29a98c5b27 100644 --- a/packages/darklang/cli/ui/components/progress.dark +++ b/packages/darklang/cli/ui/components/progress.dark @@ -24,8 +24,8 @@ let renderProgressBar (component: Core.Types.Component) (context: let progress = model.value - model.min let availableWidth = component.bounds.dimensions.width - 2L let filledWidth = if range == 0L then 0L else Stdlib.Int64.divide (progress * availableWidth) range - let filled = Stdlib.String.repeat "█" filledWidth - let empty = Stdlib.String.repeat "░" (component.bounds.dimensions.width - 2L - filledWidth) + let filled = Stdlib.String.repeat "█" (Stdlib.Int.fromInt64 filledWidth) + let empty = Stdlib.String.repeat "░" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 2L - filledWidth)) let progressText = "[" ++ filled ++ empty ++ "]" let coloredProgress = Core.Rendering.colorize model.color progressText diff --git a/packages/darklang/cli/ui/components/scrollbar.dark b/packages/darklang/cli/ui/components/scrollbar.dark index 4df99e7dd2..59491343e2 100644 --- a/packages/darklang/cli/ui/components/scrollbar.dark +++ b/packages/darklang/cli/ui/components/scrollbar.dark @@ -29,7 +29,7 @@ let renderScrollbar (component: Core.Types.Component) (context: if model.total <= model.visible then let maxIndex = model.height - 1L - (Stdlib.List.range 0L maxIndex) + (Stdlib.List.range 0I (Stdlib.Int.fromInt64 maxIndex)) |> Stdlib.List.map (fun _ -> "│") else let thumbSize = Stdlib.Int64.max 1L (Stdlib.Int64.divide (model.visible * model.height) model.total) @@ -42,9 +42,9 @@ let renderScrollbar (component: Core.Types.Component) (context: Stdlib.Int64.divide (model.position * heightOffset) remainingSpace let maxIndex = model.height - 1L - (Stdlib.List.range 0L maxIndex) + (Stdlib.List.range 0I (Stdlib.Int.fromInt64 maxIndex)) |> Stdlib.List.map (fun i -> - if i >= thumbPos && i < (thumbPos + thumbSize) then + if (Builtin.unwrap (Stdlib.Int.toInt64 i)) >= thumbPos && (Builtin.unwrap (Stdlib.Int.toInt64 i)) < (thumbPos + thumbSize) then "█" else "░") @@ -64,7 +64,7 @@ let renderHorizontalScrollbar (component: Core.Types.Component) let model = component.model if model.total <= model.visible then - [Stdlib.String.repeat "─" model.height] + [Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 model.height)] else let thumbSize = Stdlib.Int64.max 1L (Stdlib.Int64.divide (model.visible * model.height) model.total) let remainingSpace = model.total - model.visible @@ -76,9 +76,9 @@ let renderHorizontalScrollbar (component: Core.Types.Component) let maxIndex = model.height - 1L let scrollLine = - (Stdlib.List.range 0L maxIndex) + (Stdlib.List.range 0I (Stdlib.Int.fromInt64 maxIndex)) |> Stdlib.List.map (fun i -> - if i >= thumbPos && i < (thumbPos + thumbSize) then + if (Builtin.unwrap (Stdlib.Int.toInt64 i)) >= thumbPos && (Builtin.unwrap (Stdlib.Int.toInt64 i)) < (thumbPos + thumbSize) then "█" else "░") diff --git a/packages/darklang/cli/ui/components/spinner.dark b/packages/darklang/cli/ui/components/spinner.dark index 65019f317a..aefb8812b6 100644 --- a/packages/darklang/cli/ui/components/spinner.dark +++ b/packages/darklang/cli/ui/components/spinner.dark @@ -57,10 +57,10 @@ let renderSpinner (component: Core.Types.Component) (context: Core let frame = let frameIndex = - match Stdlib.Int64.remainder model.frameIndex frameCount with + match Stdlib.Int64.remainder model.frameIndex (Builtin.unwrap (Stdlib.Int.toInt64 frameCount)) with | Ok idx -> idx | Error _ -> 0L - match Stdlib.List.getAt frames frameIndex with + match Stdlib.List.getAt frames (Stdlib.Int.fromInt64 frameIndex) with | Some f -> f | None -> "?" @@ -73,7 +73,7 @@ let tick (component: Core.Types.Component) : Core.Types.Component< let frames = getFrames model.style let frameCount = Stdlib.List.length frames let nextIndex = - match Stdlib.Int64.remainder (model.frameIndex + 1L) frameCount with + match Stdlib.Int64.remainder (model.frameIndex + 1L) (Builtin.unwrap (Stdlib.Int.toInt64 frameCount)) with | Ok idx -> idx | Error _ -> 0L { component with model = { model with frameIndex = nextIndex } } diff --git a/packages/darklang/cli/ui/components/statusbar.dark b/packages/darklang/cli/ui/components/statusbar.dark index 08462995e7..24c72a5008 100644 --- a/packages/darklang/cli/ui/components/statusbar.dark +++ b/packages/darklang/cli/ui/components/statusbar.dark @@ -33,7 +33,7 @@ let renderStatusBar (component: Core.Types.Component) (context: let paddingSpace = model.width - leftLen - rightLen let padding = if paddingSpace > 0L then - Stdlib.String.repeat " " paddingSpace + Stdlib.String.repeat " " (Stdlib.Int.fromInt64 paddingSpace) else "" model.leftText ++ padding ++ model.rightText @@ -46,12 +46,12 @@ let renderStatusBar (component: Core.Types.Component) (context: let rightPadding = model.width - leftLen - centerLen - leftPadding let leftPad = if leftPadding > 0L then - Stdlib.String.repeat " " leftPadding + Stdlib.String.repeat " " (Stdlib.Int.fromInt64 leftPadding) else "" let rightPad = if rightPadding > 0L then - Stdlib.String.repeat " " rightPadding + Stdlib.String.repeat " " (Stdlib.Int.fromInt64 rightPadding) else "" model.leftText ++ leftPad ++ model.centerText ++ rightPad diff --git a/packages/darklang/cli/ui/components/table.dark b/packages/darklang/cli/ui/components/table.dark index f5130b6ea7..8805f58c4f 100644 --- a/packages/darklang/cli/ui/components/table.dark +++ b/packages/darklang/cli/ui/components/table.dark @@ -26,7 +26,7 @@ let createTable (columns: List) (rows: List>) : Core.Types. |> Stdlib.List.map (fun col -> col.width + 1L) |> Stdlib.List.fold 1L (fun acc w -> acc + w) - let height = (Stdlib.List.length rows) + 3L + let height = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length rows))) + 3L let model = TableModel @@ -65,7 +65,7 @@ let renderTable (component: Core.Types.Component) (context: Core.Typ // Build column separator segments (horizontal lines for each column width) let columnSegments = - model.columns |> Stdlib.List.map (fun col -> Stdlib.String.repeat horiz col.width) + model.columns |> Stdlib.List.map (fun col -> Stdlib.String.repeat horiz (Stdlib.Int.fromInt64 col.width)) // Top border: ┌───┬───┬───┐ let topBorder = @@ -98,7 +98,7 @@ let renderTable (component: Core.Types.Component) (context: Core.Typ let dataLines = model.rows |> Stdlib.List.indexedMap (fun rowIndex row -> - let isSelected = rowIndex == model.selectedRow + let isSelected = (Builtin.unwrap (Stdlib.Int.toInt64 rowIndex)) == model.selectedRow let cellsOpt = Stdlib.List.map2 row model.columns (fun cellValue col -> @@ -133,7 +133,7 @@ let addTableRow (component: Core.Types.Component) (row: List let selectRow (component: Core.Types.Component) (index: Int64) : Core.Types.Component = let model = component.model - let maxIndex = (Stdlib.List.length model.rows) - 1L + let maxIndex = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length model.rows))) - 1L let clampedIndex = if index < 0L then 0L @@ -145,7 +145,7 @@ let selectRow (component: Core.Types.Component) (index: Int64) : Cor let selectNextRow (component: Core.Types.Component) : Core.Types.Component = let model = component.model - let maxIndex = (Stdlib.List.length model.rows) - 1L + let maxIndex = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length model.rows))) - 1L let nextIndex = if model.selectedRow < maxIndex then model.selectedRow + 1L @@ -181,6 +181,6 @@ let showTableHeader (component: Core.Types.Component) : Core.Types.C let getSelectedRow (component: Core.Types.Component) : Stdlib.Option.Option> = let model = component.model if model.selectedRow >= 0L then - Stdlib.List.getAt model.rows model.selectedRow + Stdlib.List.getAt model.rows (Stdlib.Int.fromInt64 model.selectedRow) else Stdlib.Option.Option.None diff --git a/packages/darklang/cli/ui/components/textblock.dark b/packages/darklang/cli/ui/components/textblock.dark index a14af105fd..92b1d46f27 100644 --- a/packages/darklang/cli/ui/components/textblock.dark +++ b/packages/darklang/cli/ui/components/textblock.dark @@ -14,7 +14,7 @@ let createTextBlock (lines: List) (color: Core.Types.Color) (alignment: lines |> Stdlib.List.map Stdlib.String.length |> Stdlib.List.fold 0L (fun acc len -> if len > acc then len else acc) - let height = Stdlib.List.length lines + let height = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length lines)) let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = maxWidth; height = height } } Core.Types.Component { id = "textblock" @@ -37,7 +37,7 @@ let setTextBlockLines (component: Core.Types.Component) (lines: lines |> Stdlib.List.map Stdlib.String.length |> Stdlib.List.fold 0L (fun acc len -> if len > acc then len else acc) - let height = Stdlib.List.length lines + let height = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length lines)) let newBounds = Core.Types.Bounds { position = component.bounds.position; dimensions = Core.Types.Dimensions { width = maxWidth; height = height } } { component with model = { model with lines = lines } diff --git a/packages/darklang/cli/ui/core/rendering.dark b/packages/darklang/cli/ui/core/rendering.dark index c3490be65d..5873ad71e1 100644 --- a/packages/darklang/cli/ui/core/rendering.dark +++ b/packages/darklang/cli/ui/core/rendering.dark @@ -88,8 +88,8 @@ let drawBoxWithStyle (bounds: Types.Bounds) (title: String) (content: List Stdlib.List.map (fun line -> let lineLength = Stdlib.String.length line - let padding = if lineLength < innerWidth - 1L then Stdlib.String.repeat " " (innerWidth - 1L - lineLength) else "" + let padding = if lineLength < innerWidth - 1L then Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (innerWidth - 1L - lineLength)) else "" vert ++ " " ++ line ++ padding ++ vert) [topBorder] @@ -126,13 +126,13 @@ let padText (text: String) (width: Int64) (alignment: Types.Alignment) : String else let padding = width - textLength match alignment with - | Left -> text ++ Stdlib.String.repeat " " padding - | Right -> Stdlib.String.repeat " " padding ++ text + | Left -> text ++ Stdlib.String.repeat " " (Stdlib.Int.fromInt64 padding) + | Right -> Stdlib.String.repeat " " (Stdlib.Int.fromInt64 padding) ++ text | Center -> let leftPad = Stdlib.Int64.divide padding 2L let rightPad = padding - leftPad - Stdlib.String.repeat " " leftPad ++ text ++ Stdlib.String.repeat " " rightPad - | Justify -> text ++ Stdlib.String.repeat " " padding + Stdlib.String.repeat " " (Stdlib.Int.fromInt64 leftPad) ++ text ++ Stdlib.String.repeat " " (Stdlib.Int.fromInt64 rightPad) + | Justify -> text ++ Stdlib.String.repeat " " (Stdlib.Int.fromInt64 padding) let truncateText (text: String) (maxWidth: Int64) : String = if Stdlib.String.length text <= maxWidth then diff --git a/packages/darklang/cli/ui/demo.dark b/packages/darklang/cli/ui/demo.dark index 788232d326..3baa471438 100644 --- a/packages/darklang/cli/ui/demo.dark +++ b/packages/darklang/cli/ui/demo.dark @@ -44,7 +44,7 @@ let run (unit: Unit) : Int64 = printSection "Spinner Styles" let dotsFrames = Components.Spinner.getFrames Components.Spinner.SpinnerStyle.Dots let lineFrames = Components.Spinner.getFrames Components.Spinner.SpinnerStyle.Line - Stdlib.printLine ("Dots: " ++ Stdlib.String.join (Stdlib.List.take dotsFrames 6L) " ") + Stdlib.printLine ("Dots: " ++ Stdlib.String.join (Stdlib.List.take dotsFrames 6I) " ") Stdlib.printLine ("Line: " ++ Stdlib.String.join lineFrames " ") // Table diff --git a/packages/darklang/cli/ui/layout.dark b/packages/darklang/cli/ui/layout.dark index 2acd201ee7..81e077c513 100644 --- a/packages/darklang/cli/ui/layout.dark +++ b/packages/darklang/cli/ui/layout.dark @@ -43,13 +43,14 @@ let printAt (region: Region) (row: Int64) (col: Int64) (text: String) : Unit = /// Fill a row with a repeated character, within the region. let fillRow (region: Region) (row: Int64) (ch: String) : Unit = - let line = Stdlib.String.repeat ch region.cols + let line = Stdlib.String.repeat ch (Stdlib.Int.fromInt64 region.cols) printAt region row 0L line /// Fill the entire region with spaces (clear it). let clearRegion (region: Region) : Unit = - (Stdlib.List.range 0L (region.rows - 1L)) - |> Stdlib.List.iter (fun row -> fillRow region row " ") + (Stdlib.List.range 0I (Stdlib.Int.fromInt64 (region.rows - 1L))) + |> Stdlib.List.iter (fun row -> + fillRow region (Builtin.unwrap (Stdlib.Int.toInt64 row)) " ") // --- Layout negotiation --- @@ -58,7 +59,7 @@ let clearRegion (region: Region) : Unit = /// Each gets at least min, then remaining space is split toward preferred. let distributeRows (totalRows: Int64) (requests: List) : List = let count = Stdlib.List.length requests - if count == 0L then + if count == 0I then [] else // First pass: give everyone their minimum diff --git a/packages/darklang/cli/utils/logo.dark b/packages/darklang/cli/utils/logo.dark index 5b22395ed4..25abe81d3a 100644 --- a/packages/darklang/cli/utils/logo.dark +++ b/packages/darklang/cli/utils/logo.dark @@ -73,9 +73,9 @@ let combineLogoAndText (logoStr: String) (textLines: List) (color: Strin let finalLogoLines = if logoHeight < targetHeight then // e.g, 3 < 7 = true let totalPadding = targetHeight - logoHeight // 7 - 3 = 4 empty lines needed - let paddingTop = Stdlib.Int64.divide totalPadding 2L // 4 ÷ 2 = 2 lines above + let paddingTop = Stdlib.Int.divide totalPadding 2I // 4 ÷ 2 = 2 lines above let paddingBottom = totalPadding - paddingTop // 4 - 2 = 2 lines below - let emptyLogoLine = Stdlib.String.repeat " " maxLogoWidth // if maxLogoWidth = 6, then emptyLogoLine = " " (6 spaces) + let emptyLogoLine = Stdlib.String.repeat " " (Stdlib.Int.fromInt64 maxLogoWidth) // if maxLogoWidth = 6, then emptyLogoLine = " " (6 spaces) match Stdlib.List.repeat paddingTop emptyLogoLine with // Create 2 empty top logo lines | Ok topEmpty -> match Stdlib.List.repeat paddingBottom emptyLogoLine with // Create 2 empty bottom logo lines @@ -90,7 +90,7 @@ let combineLogoAndText (logoStr: String) (textLines: List) (color: Strin let finalTextLines = if textHeight < targetHeight then let totalPadding = targetHeight - textHeight - let paddingTop = Stdlib.Int64.divide totalPadding 2L + let paddingTop = Stdlib.Int.divide totalPadding 2I let paddingBottom = totalPadding - paddingTop match Stdlib.List.repeat paddingTop "" with | Ok topEmpty -> diff --git a/packages/darklang/cli/utils/syntaxHighlighting.dark b/packages/darklang/cli/utils/syntaxHighlighting.dark index b8d88cbeff..75036399e8 100644 --- a/packages/darklang/cli/utils/syntaxHighlighting.dark +++ b/packages/darklang/cli/utils/syntaxHighlighting.dark @@ -76,7 +76,7 @@ let applyTokenColors // For the current line, find all tokens that belong to it by filtering tokens where the row matches the current line index let lineTokens = sortedTokens - |> Stdlib.List.filter (fun token -> token.range.start.row == lineIndex) + |> Stdlib.List.filter (fun token -> Stdlib.Int.fromInt64 token.range.start.row == lineIndex) if Stdlib.List.isEmpty lineTokens then line diff --git a/packages/darklang/github.dark b/packages/darklang/github.dark index 751878a1d7..33e2342c59 100644 --- a/packages/darklang/github.dark +++ b/packages/darklang/github.dark @@ -62,7 +62,7 @@ module Releases = | Some firstAsset -> // Asset name format: darklang-alpha-BUILDHASH-platform let parts = Stdlib.String.split firstAsset.name "-" - match Stdlib.List.getAt parts 2L with + match Stdlib.List.getAt parts 2I with | Some hash -> // Return in same format as CLI version (first 7 chars) Stdlib.Result.Result.Ok $"alpha-{Stdlib.String.slice hash 0L 7L}" diff --git a/packages/darklang/internal/dark-packages/dark-packages.dark b/packages/darklang/internal/dark-packages/dark-packages.dark index 9b0c36b704..1b8cf9851c 100644 --- a/packages/darklang/internal/dark-packages/dark-packages.dark +++ b/packages/darklang/internal/dark-packages/dark-packages.dark @@ -41,7 +41,7 @@ let parseNameToLocation let parts = Stdlib.String.split name "." let partsLength = Stdlib.List.length parts - if partsLength < 2L then + if partsLength < 2I then Stdlib.Result.Result.Error "Invalid name format. Expected 'Owner.Module.Name' or 'Owner.Name'" else @@ -56,7 +56,7 @@ let parseNameToLocation match Stdlib.List.tail parts with | None -> Stdlib.Result.Result.Error "Invalid name format" | Some middleParts -> - let modules = Stdlib.List.take middleParts (partsLength - 2L) + let modules = Stdlib.List.take middleParts (partsLength - 2I) Stdlib.Result.Result.Ok (LanguageTools.ProgramTypes.PackageLocation { owner = owner; modules = modules; name = entityName }) @@ -216,9 +216,9 @@ let locationHandlerFn (req: HttpRequest) : HttpResponse = let parts = Stdlib.String.split location "." let partsLength = Stdlib.List.length parts - if partsLength < 1L then + if partsLength < 1I then Stdlib.Http.badRequest "Invalid location format. Expected 'Owner', 'Owner.Module', or 'Owner.Module.Name'" - else if partsLength == 1L then + else if partsLength == 1I then // single segment → list direct descendants under that owner match Stdlib.List.head parts with | None -> Stdlib.Http.badRequest "Invalid location: empty segment" diff --git a/packages/darklang/internal/darklang-internal-mcp-server/tools.dark b/packages/darklang/internal/darklang-internal-mcp-server/tools.dark index c5e654ecb8..809e8ac94d 100644 --- a/packages/darklang/internal/darklang-internal-mcp-server/tools.dark +++ b/packages/darklang/internal/darklang-internal-mcp-server/tools.dark @@ -24,7 +24,7 @@ let searchFunctions () : ModelContextProtocol.ServerBuilder.Tool = handler = fun query -> let results = LanguageTools.FunctionSearch.search query - let resultCount = (Stdlib.List.length results) |> Stdlib.Int64.toString + let resultCount = (Stdlib.List.length results) |> Stdlib.Int.toString let formattedResults = results |> Stdlib.List.map (fun fn -> $"- {fn.name}: {fn.description}") @@ -57,7 +57,7 @@ let listPackages () : ModelContextProtocol.ServerBuilder.Tool = description = "List all available Darklang packages" handler = fun filter -> let packages = LanguageTools.PackageManager.listPackages filter - let packageCount = (Stdlib.List.length packages) |> Stdlib.Int64.toString + let packageCount = (Stdlib.List.length packages) |> Stdlib.Int.toString let formattedPackages = packages |> Stdlib.List.map (fun pkg -> $"- {pkg.name} (v{pkg.version}): {pkg.description}") diff --git a/packages/darklang/languageTools/lsp-server/branches.dark b/packages/darklang/languageTools/lsp-server/branches.dark index bf9b555125..98ba2e6bca 100644 --- a/packages/darklang/languageTools/lsp-server/branches.dark +++ b/packages/darklang/languageTools/lsp-server/branches.dark @@ -269,7 +269,7 @@ let handleRebaseStatusRequest let resultJson = Json.Object [ ("conflicts", conflictsJson) - ("hasConflicts", Json.Bool (Stdlib.List.length conflicts > 0L)) ] + ("hasConflicts", Json.Bool (Stdlib.List.length conflicts > 0I)) ] let responseJson = (JsonRPC.Response.Ok.make (Stdlib.Option.Option.Some requestID) resultJson) diff --git a/packages/darklang/languageTools/lsp-server/cursorPosition.dark b/packages/darklang/languageTools/lsp-server/cursorPosition.dark index 8c29d5d830..f5e263afdd 100644 --- a/packages/darklang/languageTools/lsp-server/cursorPosition.dark +++ b/packages/darklang/languageTools/lsp-server/cursorPosition.dark @@ -51,7 +51,7 @@ let wordUnderCursor let currentLine = text |> Stdlib.String.split "\n" - |> Stdlib.List.getAt line + |> Stdlib.List.getAt (Stdlib.Int.fromInt64 line) |> Stdlib.Option.withDefault "" let lineToCursor = currentLine |> Stdlib.String.slice 0L character diff --git a/packages/darklang/languageTools/lsp-server/hover.dark b/packages/darklang/languageTools/lsp-server/hover.dark index 1910053a30..9c3c76daf6 100644 --- a/packages/darklang/languageTools/lsp-server/hover.dark +++ b/packages/darklang/languageTools/lsp-server/hover.dark @@ -10,7 +10,7 @@ let getTextAtRange let endColumn = range.end_.column let lines = text |> Stdlib.String.split "\n" - let textLines = lines |> Stdlib.List.getAt startLine + let textLines = lines |> Stdlib.List.getAt (Stdlib.Int.fromInt64 startLine) match textLines with | Some line -> diff --git a/packages/darklang/languageTools/lsp-server/logging.dark b/packages/darklang/languageTools/lsp-server/logging.dark index 13e007d3c0..721e6b8908 100644 --- a/packages/darklang/languageTools/lsp-server/logging.dark +++ b/packages/darklang/languageTools/lsp-server/logging.dark @@ -20,7 +20,7 @@ let logAndSendToClient (response: String) : Unit = response |> Stdlib.String.toBytes_v0 |> Stdlib.List.length - |> Stdlib.Int64.toString + |> Stdlib.Int.toString Builtin.print $"Content-Length: {contentLengthInBytes}\r\n\r\n{response}" diff --git a/packages/darklang/languageTools/lsp-server/semanticTokens.dark b/packages/darklang/languageTools/lsp-server/semanticTokens.dark index 6453d1cada..0593f7fe64 100644 --- a/packages/darklang/languageTools/lsp-server/semanticTokens.dark +++ b/packages/darklang/languageTools/lsp-server/semanticTokens.dark @@ -67,15 +67,15 @@ module EncodeSemanticTokens = let bStart = b.range.start if Stdlib.Int64.lessThan aStart.row bStart.row then - -1L + -1I elif Stdlib.Int64.greaterThan aStart.row bStart.row then - 1L + 1I else if Stdlib.Int64.lessThan aStart.column bStart.column then - -1L + -1I else if Stdlib.Int64.greaterThan aStart.column bStart.column then - 1L + 1I else - 0L) + 0I) match sortedTokens with | Error _ -> [] diff --git a/packages/darklang/languageTools/lsp.dark b/packages/darklang/languageTools/lsp.dark index 262bc7adb7..681778b106 100644 --- a/packages/darklang/languageTools/lsp.dark +++ b/packages/darklang/languageTools/lsp.dark @@ -62,7 +62,8 @@ let getDiagnostics (uri: String) (text: String) : String = | None -> 0L Position - { line = (Stdlib.List.length lines) - 1L + { line = + (Builtin.unwrap (Stdlib.Int.toInt64 ((Stdlib.List.length lines) - 1I))) character = lastLineLength } Range { start = start; end_ = end' } diff --git a/packages/darklang/languageTools/parser/core.dark b/packages/darklang/languageTools/parser/core.dark index cbbce324bc..adb58e00de 100644 --- a/packages/darklang/languageTools/parser/core.dark +++ b/packages/darklang/languageTools/parser/core.dark @@ -187,7 +187,7 @@ let decodeChars match chars with | [] -> Stdlib.Result.Result.Ok acc | '\\' :: afterBackslash :: _ -> - let len = escapeLength afterBackslash + let len = Stdlib.Int.fromInt64 (escapeLength afterBackslash) let escapeChars = Stdlib.List.take chars len let remaining = Stdlib.List.drop chars len if Stdlib.List.length escapeChars < len then @@ -291,7 +291,7 @@ let baseParseList contentsNode.children |> Stdlib.List.filter (fun c -> c.typ != "indent" && c.typ != "dedent") - |> Stdlib.List.chunkBySize 2L + |> Stdlib.List.chunkBySize 2I |> (fun chunkedResult -> match chunkedResult with | Ok pairs -> @@ -344,7 +344,7 @@ let baseParseTuple (findNodeByFieldName node "rest") |> Stdlib.Option.map (fun restNode -> restNode.children - |> Stdlib.List.chunkBySize 2L + |> Stdlib.List.chunkBySize 2I |> (fun chunkedResult -> match chunkedResult with | Ok pairs -> @@ -398,7 +398,7 @@ let baseParseDict |> findNodeByFieldName "content" |> Stdlib.Option.map (fun contentsNode -> contentsNode.children - |> Stdlib.List.chunkBySize 2L + |> Stdlib.List.chunkBySize 2I |> (fun chunkedResult -> match chunkedResult with | Ok pairs -> @@ -467,7 +467,7 @@ let baseParseEnum enumFieldsNode.children |> Stdlib.List.filter (fun c -> c.typ != "indent" && c.typ != "dedent") - |> Stdlib.List.chunkBySize 2L + |> Stdlib.List.chunkBySize 2I |> (fun chunkedResult -> match chunkedResult with | Ok pairs -> diff --git a/packages/darklang/languageTools/parser/expr.dark b/packages/darklang/languageTools/parser/expr.dark index 09a6ad0806..1aefdc0bfb 100644 --- a/packages/darklang/languageTools/parser/expr.dark +++ b/packages/darklang/languageTools/parser/expr.dark @@ -313,7 +313,7 @@ let parseRecordLiteral |> findNodeByFieldName "content" |> Stdlib.Option.map (fun contentsNode -> contentsNode.children - |> Stdlib.List.chunkBySize 2L + |> Stdlib.List.chunkBySize 2I |> (fun chunkedResult -> match chunkedResult with | Ok pairs -> @@ -373,7 +373,7 @@ let parseRecordUpdate fieldUpdatesNode.children |> Stdlib.List.filter (fun c -> c.typ != "indent" && c.typ != "dedent") - |> Stdlib.List.chunkBySize 2L + |> Stdlib.List.chunkBySize 2I |> (fun chunkedResult -> match chunkedResult with | Ok pairs -> @@ -812,7 +812,7 @@ let parsePipeExpression (findNodeByFieldName node "pipe_exprs") |> Stdlib.Option.map (fun pipeExprNode -> pipeExprNode.children - |> Stdlib.List.chunkBySize 2L + |> Stdlib.List.chunkBySize 2I |> (fun chunkedResult -> match chunkedResult with | Ok pairs -> diff --git a/packages/darklang/languageTools/parser/functionDeclaration.dark b/packages/darklang/languageTools/parser/functionDeclaration.dark index 6d1a352330..87c555a04a 100644 --- a/packages/darklang/languageTools/parser/functionDeclaration.dark +++ b/packages/darklang/languageTools/parser/functionDeclaration.dark @@ -87,7 +87,7 @@ let parse typeParamsNode |> findNodeByFieldName "params" |> Stdlib.Option.map (fun node -> - match node.children |> Stdlib.List.chunkBySize 2L with + match node.children |> Stdlib.List.chunkBySize 2I with | Ok pairs -> pairs |> Stdlib.List.map (fun typeParamSeparatorPair -> match typeParamSeparatorPair with diff --git a/packages/darklang/languageTools/parser/identifiers.dark b/packages/darklang/languageTools/parser/identifiers.dark index bc4ddbd2d8..dea427b544 100644 --- a/packages/darklang/languageTools/parser/identifiers.dark +++ b/packages/darklang/languageTools/parser/identifiers.dark @@ -77,7 +77,7 @@ let extractTypeArgs match findNodeByFieldName typeArgs "type_args_items" with | None -> [] |> Stdlib.Result.Result.Ok | Some typeArgsNode -> - match typeArgsNode.children |> Stdlib.List.chunkBySize 2L with + match typeArgsNode.children |> Stdlib.List.chunkBySize 2I with | Ok pairs -> pairs |> Stdlib.List.map (fun typeArgSeparatorPair -> diff --git a/packages/darklang/languageTools/parser/matchPattern.dark b/packages/darklang/languageTools/parser/matchPattern.dark index 78cbd28ee9..c173d88d39 100644 --- a/packages/darklang/languageTools/parser/matchPattern.dark +++ b/packages/darklang/languageTools/parser/matchPattern.dark @@ -256,7 +256,7 @@ let parseMPEnum let enumFieldsNode = (findNodeByFieldName node "enum_fields") |> Stdlib.Option.map (fun enumFieldsNode -> - match enumFieldsNode.children |> Stdlib.List.chunkBySize 2L with + match enumFieldsNode.children |> Stdlib.List.chunkBySize 2I with | Ok pairs -> pairs |> Stdlib.List.map (fun contentSymbolPair -> @@ -288,7 +288,7 @@ let parseMPOr | firstPattern :: restPatterns -> let firstPattern = MatchPattern.parseMatchPattern firstPattern let restPatterns = - match restPatterns |> Stdlib.List.chunkBySize 2L with + match restPatterns |> Stdlib.List.chunkBySize 2I with | Ok chunks -> chunks |> Stdlib.List.map (fun patternPipeSymbolPair -> diff --git a/packages/darklang/languageTools/parser/typeDeclaration.dark b/packages/darklang/languageTools/parser/typeDeclaration.dark index de040fa1bf..df22046bd3 100644 --- a/packages/darklang/languageTools/parser/typeDeclaration.dark +++ b/packages/darklang/languageTools/parser/typeDeclaration.dark @@ -76,7 +76,7 @@ let parseDefinition let recordFields = match (findNodeByFieldName child "fields") with | Some fieldsNode -> - match fieldsNode.children |> Stdlib.List.chunkBySize 2L with + match fieldsNode.children |> Stdlib.List.chunkBySize 2I with | Ok pairs -> pairs |> Stdlib.List.map (fun fieldSeparatorPair -> match fieldSeparatorPair with @@ -178,7 +178,7 @@ let parse match findNodeByFieldName typeParamsNode "params" with | None -> [] |> Stdlib.Result.Result.Ok | Some paramsNode -> - match paramsNode.children |> Stdlib.List.chunkBySize 2L with + match paramsNode.children |> Stdlib.List.chunkBySize 2I with | Ok pairs -> pairs |> Stdlib.List.map (fun typeParamSeparatorPair -> diff --git a/packages/darklang/languageTools/parser/typeReference.dark b/packages/darklang/languageTools/parser/typeReference.dark index 12d45f32a1..beacb3d85b 100644 --- a/packages/darklang/languageTools/parser/typeReference.dark +++ b/packages/darklang/languageTools/parser/typeReference.dark @@ -104,7 +104,7 @@ let parseBuiltIn firstChild |> findNodeByFieldName "rest" |> Stdlib.Option.map (fun restNode -> - match restNode.children |> Stdlib.List.chunkBySize 2L with + match restNode.children |> Stdlib.List.chunkBySize 2I with | Ok pairs -> pairs |> Stdlib.List.map (fun symbolTypePair -> match symbolTypePair with @@ -166,7 +166,7 @@ let parseBuiltIn | None -> createUnparseableError firstChild let argsNodes = - match firstChild.children |> Stdlib.List.dropLast |> Stdlib.List.chunkBySize 2L with + match firstChild.children |> Stdlib.List.dropLast |> Stdlib.List.chunkBySize 2I with | Ok pairs -> pairs |> Stdlib.List.map (fun typeArrowPair -> match typeArrowPair with diff --git a/packages/darklang/languageTools/writtenTypesToProgramTypes.dark b/packages/darklang/languageTools/writtenTypesToProgramTypes.dark index 06ed11aabf..72f8094418 100644 --- a/packages/darklang/languageTools/writtenTypesToProgramTypes.dark +++ b/packages/darklang/languageTools/writtenTypesToProgramTypes.dark @@ -1454,7 +1454,8 @@ module FunctionDeclaration = // Build argument mapping from parameter names to indices let argMap = params - |> Stdlib.List.indexedMap (fun i param -> (param.name, i)) + |> Stdlib.List.indexedMap (fun i param -> + (param.name, (Builtin.unwrap (Stdlib.Int.toInt64 i)))) |> Stdlib.List.fold Stdlib.Dict.empty (fun acc (name, idx) -> Stdlib.Dict.set acc name idx) let functionContext = diff --git a/packages/darklang/llm/tools/file-system.dark b/packages/darklang/llm/tools/file-system.dark index 5a1200f915..8237415d30 100644 --- a/packages/darklang/llm/tools/file-system.dark +++ b/packages/darklang/llm/tools/file-system.dark @@ -117,7 +117,7 @@ let searchFileForPattern else if Stdlib.String.contains line pattern then let matchText = $"{displayPath}:{Stdlib.Int64.toString lineNumber}: {line}" let updatedMatches = Stdlib.List.append currentState.matches [ matchText ] - let reachedLimit = (Stdlib.List.length updatedMatches) >= maxSearchResults + let reachedLimit = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length updatedMatches))) >= maxSearchResults let updatedState = { currentState with matches = updatedMatches diff --git a/packages/darklang/modelContextProtocol/serverBuilder/main.dark b/packages/darklang/modelContextProtocol/serverBuilder/main.dark index a239bc6fcc..a0daf2c844 100644 --- a/packages/darklang/modelContextProtocol/serverBuilder/main.dark +++ b/packages/darklang/modelContextProtocol/serverBuilder/main.dark @@ -54,7 +54,7 @@ let runServerCliLoop (state: State.BuilderServerState) : Int64 = | BatchOfRequests items -> // Handle batch requests by processing each one in sequence - let len = (Stdlib.List.length items) |> Stdlib.Int64.toString + let len = (Stdlib.List.length items) |> Stdlib.Int.toString logWithPath state.logFilePath $"Got batch request with {len} items" let processedState = diff --git a/packages/darklang/opml/opml.dark b/packages/darklang/opml/opml.dark index 6a99296a25..410cee055b 100644 --- a/packages/darklang/opml/opml.dark +++ b/packages/darklang/opml/opml.dark @@ -14,7 +14,7 @@ let escapeXml (text: String) : String = let nodesToOpml (nodes: List) (depth: Int64) : List = nodes |> Stdlib.List.fold [] (fun acc node -> - let indent = Stdlib.String.repeat " " (depth + 2L) + let indent = Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (depth + 2L)) let escaped = escapeXml node.text if Stdlib.List.isEmpty node.children then Stdlib.List.append acc [$"{indent}"] diff --git a/packages/darklang/prettyPrinter/capabilities.dark b/packages/darklang/prettyPrinter/capabilities.dark index 0df0f53bef..4097f4636b 100644 --- a/packages/darklang/prettyPrinter/capabilities.dark +++ b/packages/darklang/prettyPrinter/capabilities.dark @@ -40,7 +40,7 @@ let detail (spec: String) : String = | [ "exec"; prog ] -> prog | "exec" :: prog :: progArgs -> $"""{prog} ({Stdlib.String.join progArgs " "})""" | [ _ ] -> "" // flag domains - | _ -> Stdlib.String.join (Stdlib.List.drop parts 1L) " " + | _ -> Stdlib.String.join (Stdlib.List.drop parts 1I) " " /// One aligned "domain detail" line for a single spec — the single source of truth for a caps row /// (used by `caps list`, `caps `, and the interactive editor's rows). diff --git a/packages/darklang/prettyPrinter/common.dark b/packages/darklang/prettyPrinter/common.dark index f87306160b..5e1789176f 100644 --- a/packages/darklang/prettyPrinter/common.dark +++ b/packages/darklang/prettyPrinter/common.dark @@ -15,7 +15,7 @@ let indent (s: String) : String = |> Stdlib.String.join "\n" let indentByLevel (level: Int64) (s: String) : String = - let indentStr = Stdlib.String.repeat " " level + let indentStr = Stdlib.String.repeat " " (Stdlib.Int.fromInt64 level) s |> Stdlib.String.split "\n" diff --git a/packages/darklang/prettyPrinter/programTypes.dark b/packages/darklang/prettyPrinter/programTypes.dark index 45acf58a81..043ad0a4c0 100644 --- a/packages/darklang/prettyPrinter/programTypes.dark +++ b/packages/darklang/prettyPrinter/programTypes.dark @@ -1008,7 +1008,8 @@ let packageFn let argMap = p.parameters - |> Stdlib.List.indexedMap (fun i param -> (param.name, i)) + |> Stdlib.List.indexedMap (fun i param -> + (param.name, (Builtin.unwrap (Stdlib.Int.toInt64 i)))) |> Stdlib.List.fold Stdlib.Dict.empty (fun acc (name, idx) -> Stdlib.Dict.set acc name idx) @@ -1100,9 +1101,9 @@ module PackageOp = | Undeprecate _target -> "Undeprecate" | PropagateUpdate (_propId, _sloc, _fromRefs, _toRef, repoints) -> - let count = (Stdlib.List.length repoints) |> Stdlib.Int64.toString + let count = (Stdlib.List.length repoints) |> Stdlib.Int.toString $"PropagateUpdate ({count} repoint(s))" | RevertPropagation (_revertId, _propIds, _sloc, _restoredRef, repoints) -> - let count = (Stdlib.List.length repoints) |> Stdlib.Int64.toString + let count = (Stdlib.List.length repoints) |> Stdlib.Int.toString $"RevertPropagation ({count} repoint(s))" \ No newline at end of file diff --git a/packages/darklang/prettyPrinter/runtimeError.dark b/packages/darklang/prettyPrinter/runtimeError.dark index ed9928064b..6a2fb15692 100644 --- a/packages/darklang/prettyPrinter/runtimeError.dark +++ b/packages/darklang/prettyPrinter/runtimeError.dark @@ -406,7 +406,7 @@ module RuntimeError = | NonOptionOrResult actual -> [ ES.String "Can only unwrap Options and Results, yet got "; ES.FullValue actual ] | MultipleArgs args -> [ ES.String "Unwrap expects a single argument, but got " - ES.Int(Stdlib.List.length args) ] + ES.Int(Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length args))) ] | Apply err -> match err with diff --git a/packages/darklang/prettyPrinter/runtimeTypes.dark b/packages/darklang/prettyPrinter/runtimeTypes.dark index db34e550eb..7534b53f85 100644 --- a/packages/darklang/prettyPrinter/runtimeTypes.dark +++ b/packages/darklang/prettyPrinter/runtimeTypes.dark @@ -358,7 +358,7 @@ module Dval = | DStreamStub vt -> $"Stream<{valueType branchId vt}>" let makeSpaces (len: Int64) : String = - match Stdlib.List.repeat len " " with + match Stdlib.List.repeat (Stdlib.Int.fromInt64 len) " " with | Ok spaces -> spaces |> Stdlib.String.join "" | Error _ -> "" diff --git a/packages/darklang/scm/partialCommit.dark b/packages/darklang/scm/partialCommit.dark index 3fbe6cc25a..bd4e470a86 100644 --- a/packages/darklang/scm/partialCommit.dark +++ b/packages/darklang/scm/partialCommit.dark @@ -533,11 +533,11 @@ let groupLines (label: String) (items: List) : List = let propagationLines (items: List) : List = let n = Stdlib.List.length items - if n == 0L then + if n == 0I then [] else - let header = $" propagated repoints ({Stdlib.Int64.toString n}):" - let shown = Stdlib.List.take items 5L + let header = $" propagated repoints ({Stdlib.Int.toString n}):" + let shown = Stdlib.List.take items 5I let rows = shown |> Stdlib.List.map (fun i -> $" {itemKindLabel i.kind} {i.fqn}") @@ -545,8 +545,8 @@ let propagationLines (items: List) : List = let more = n - (Stdlib.List.length shown) let tail = - if more > 0L then - [ $" ... and {Stdlib.Int64.toString more} more" ] + if more > 0I then + [ $" ... and {Stdlib.Int.toString more} more" ] else [] diff --git a/packages/darklang/stdlib/cli/daemon.dark b/packages/darklang/stdlib/cli/daemon.dark index 9d89b8e216..f09bdf53e5 100644 --- a/packages/darklang/stdlib/cli/daemon.dark +++ b/packages/darklang/stdlib/cli/daemon.dark @@ -24,7 +24,7 @@ let logPath (name: String) : String = (runDir ()) ++ "/" ++ name ++ ".log" // The daemon's last `n` log lines (newest at the bottom); empty if it never logged. -let tailLog (name: String) (n: Int64) : List = +let tailLog (name: String) (n: Int) : List = match File.readLines (logPath name) with | Ok lines -> let total = Stdlib.List.length lines @@ -135,7 +135,7 @@ let waitUntilRunning : Stdlib.Result.Result = if tries <= 0L then let hint = - match tailLog name 1L with + match tailLog name 1I with | [ line ] -> $" (last log: {line})" | _ -> "" diff --git a/packages/darklang/stdlib/cli/path.dark b/packages/darklang/stdlib/cli/path.dark index 79d534b436..5de148d74d 100644 --- a/packages/darklang/stdlib/cli/path.dark +++ b/packages/darklang/stdlib/cli/path.dark @@ -171,5 +171,5 @@ let relativeTo let parts = Stdlib.List.append ups tail - if Stdlib.List.length parts == 0L then "." + if Stdlib.List.length parts == 0I then "." else Stdlib.String.join parts "/")) diff --git a/packages/darklang/stdlib/cli/process.dark b/packages/darklang/stdlib/cli/process.dark index e4eca945e5..52a2143a8e 100644 --- a/packages/darklang/stdlib/cli/process.dark +++ b/packages/darklang/stdlib/cli/process.dark @@ -115,7 +115,7 @@ let runWithEnv let (k, _v) = pair (Stdlib.String.contains k "=") || (Stdlib.String.contains k " ")) - if (Stdlib.List.length invalid) > 0L then + if (Stdlib.List.length invalid) > 0I then let badName = (Stdlib.List.head invalid) |> Builtin.unwrap diff --git a/packages/darklang/stdlib/cli/ui/progress.dark b/packages/darklang/stdlib/cli/ui/progress.dark index 3dd3e1a908..1653d1b71c 100644 --- a/packages/darklang/stdlib/cli/ui/progress.dark +++ b/packages/darklang/stdlib/cli/ui/progress.dark @@ -14,8 +14,8 @@ let bar (current: Int64) (total: Int64) (label: String) : Unit = let empty = width - filled - let filledStr = Stdlib.String.repeat "#" filled - let emptyStr = Stdlib.String.repeat "-" empty + let filledStr = Stdlib.String.repeat "#" (Stdlib.Int.fromInt64 filled) + let emptyStr = Stdlib.String.repeat "-" (Stdlib.Int.fromInt64 empty) let pct = if total == 0L then 0L diff --git a/packages/darklang/stdlib/cli/ui/prompt.dark b/packages/darklang/stdlib/cli/ui/prompt.dark index 1372ab9c69..7095665df3 100644 --- a/packages/darklang/stdlib/cli/ui/prompt.dark +++ b/packages/darklang/stdlib/cli/ui/prompt.dark @@ -21,14 +21,14 @@ let select (question: String) (choices: List) : String = let _ = choices |> Stdlib.List.indexedMap (fun i choice -> - Builtin.printLine ($" {Color.bold (Stdlib.Int64.toString (i + 1L))}. {choice}")) + Builtin.printLine ($" {Color.bold (Stdlib.Int.toString (i + 1I))}. {choice}")) Builtin.print "Enter number: " let input = Builtin.stdinReadLine () - match Stdlib.Int64.parse input with + match Stdlib.Int.parse input with | Ok n -> - match Stdlib.List.getAt choices (n - 1L) with + match Stdlib.List.getAt choices (n - 1I) with | Some choice -> choice | None -> Builtin.printLine (Color.red "Invalid selection") diff --git a/packages/darklang/stdlib/cli/ui/table.dark b/packages/darklang/stdlib/cli/ui/table.dark index e9f704219f..b428e18550 100644 --- a/packages/darklang/stdlib/cli/ui/table.dark +++ b/packages/darklang/stdlib/cli/ui/table.dark @@ -25,7 +25,7 @@ let print (columns: List) (rows: List>) : Unit = let padding = width - (Stdlib.String.length s) if padding <= 0L then s - else s ++ (Stdlib.String.repeat " " padding)) + else s ++ (Stdlib.String.repeat " " (Stdlib.Int.fromInt64 padding))) // Print header row let headerLine = @@ -41,7 +41,7 @@ let print (columns: List) (rows: List>) : Unit = // Print separator let sepLine = colWidths - |> Stdlib.List.map (fun w -> Stdlib.String.repeat "-" w) + |> Stdlib.List.map (fun w -> Stdlib.String.repeat "-" (Stdlib.Int.fromInt64 w)) |> Stdlib.String.join " " Builtin.printLine sepLine diff --git a/packages/darklang/stdlib/diff.dark b/packages/darklang/stdlib/diff.dark index e910872775..773e7cfb54 100644 --- a/packages/darklang/stdlib/diff.dark +++ b/packages/darklang/stdlib/diff.dark @@ -6,7 +6,7 @@ type DiffLine = | Removed of String /// Helper to safely index into a 2D list -let tableGet (table: List>) (row: Int64) (col: Int64) : Int64 = +let tableGet (table: List>) (row: Int) (col: Int) : Int64 = let r = Stdlib.Option.withDefault (Stdlib.List.getAt table row) [] Stdlib.Option.withDefault (Stdlib.List.getAt r col) 0L @@ -14,7 +14,7 @@ let tableGet (table: List>) (row: Int64) (col: Int64) : Int64 = let buildTable (oldLines: List) (newLines: List) : List> = let zeroRow = Stdlib.List.map - (Stdlib.List.range 0L (Stdlib.List.length oldLines)) + (Stdlib.List.range 0I (Stdlib.List.length oldLines)) (fun _i -> 0L) Stdlib.List.fold newLines [zeroRow] (fun table newLine -> let prevRow = Stdlib.Option.withDefault (Stdlib.List.last table) [] @@ -22,7 +22,7 @@ let buildTable (oldLines: List) (newLines: List) : List let (i, oldLine) = pair - let above = Stdlib.Option.withDefault (Stdlib.List.getAt prevRow (i + 1L)) 0L + let above = Stdlib.Option.withDefault (Stdlib.List.getAt prevRow (i + 1I)) 0L let diag = Stdlib.Option.withDefault (Stdlib.List.getAt prevRow i) 0L let left = Stdlib.Option.withDefault (Stdlib.List.last row) 0L let cell = @@ -37,29 +37,29 @@ let trace (oldLines: List) (newLines: List) (table: List>) - (i: Int64) - (j: Int64) + (i: Int) + (j: Int) : List = - if (i == 0L) && (j == 0L) then + if (i == 0I) && (j == 0I) then [] - else if (i > 0L) && (j > 0L) then - let o = Stdlib.Option.withDefault (Stdlib.List.getAt oldLines (i - 1L)) "" - let n = Stdlib.Option.withDefault (Stdlib.List.getAt newLines (j - 1L)) "" + else if (i > 0I) && (j > 0I) then + let o = Stdlib.Option.withDefault (Stdlib.List.getAt oldLines (i - 1I)) "" + let n = Stdlib.Option.withDefault (Stdlib.List.getAt newLines (j - 1I)) "" if o == n then - Stdlib.List.append (trace oldLines newLines table (i - 1L) (j - 1L)) [DiffLine.Same o] + Stdlib.List.append (trace oldLines newLines table (i - 1I) (j - 1I)) [DiffLine.Same o] else - let up = tableGet table (j - 1L) i - let left = tableGet table j (i - 1L) + let up = tableGet table (j - 1I) i + let left = tableGet table j (i - 1I) if up >= left then - Stdlib.List.append (trace oldLines newLines table i (j - 1L)) [DiffLine.Added n] + Stdlib.List.append (trace oldLines newLines table i (j - 1I)) [DiffLine.Added n] else - Stdlib.List.append (trace oldLines newLines table (i - 1L) j) [DiffLine.Removed o] - else if j > 0L then - let n = Stdlib.Option.withDefault (Stdlib.List.getAt newLines (j - 1L)) "" - Stdlib.List.append (trace oldLines newLines table i (j - 1L)) [DiffLine.Added n] + Stdlib.List.append (trace oldLines newLines table (i - 1I) j) [DiffLine.Removed o] + else if j > 0I then + let n = Stdlib.Option.withDefault (Stdlib.List.getAt newLines (j - 1I)) "" + Stdlib.List.append (trace oldLines newLines table i (j - 1I)) [DiffLine.Added n] else - let o = Stdlib.Option.withDefault (Stdlib.List.getAt oldLines (i - 1L)) "" - Stdlib.List.append (trace oldLines newLines table (i - 1L) j) [DiffLine.Removed o] + let o = Stdlib.Option.withDefault (Stdlib.List.getAt oldLines (i - 1I)) "" + Stdlib.List.append (trace oldLines newLines table (i - 1I) j) [DiffLine.Removed o] /// Compute a line-based diff between two strings. let lines (oldText: String) (newText: String) : List = diff --git a/packages/darklang/stdlib/httpserver.dark b/packages/darklang/stdlib/httpserver.dark index 3ad6580ab9..5c66555172 100644 --- a/packages/darklang/stdlib/httpserver.dark +++ b/packages/darklang/stdlib/httpserver.dark @@ -66,7 +66,7 @@ let matchRoute (routePattern: String) (requestPath: String) : RouteMatch = let routeLen = List.length routeSegs let pathLen = List.length pathSegs - if (routeLen == 0L) && (pathLen == 0L) then + if (routeLen == 0I) && (pathLen == 0I) then RouteMatch { matched = true; vars = [] } else if routeLen != pathLen then RouteMatch { matched = false; vars = [] } diff --git a/packages/darklang/stdlib/list.dark b/packages/darklang/stdlib/list.dark index cd5c7e7e04..05e72a7f08 100644 --- a/packages/darklang/stdlib/list.dark +++ b/packages/darklang/stdlib/list.dark @@ -76,7 +76,7 @@ let findFirst (list: List<'a>) (fn: 'a -> Bool) : Option.Option<'a> = /// Returns the index of the first element in for which /// returns true. Returns {{None}} if no such element exists. -let findFirstIndex (list: List<'a>) (fn: 'a -> Bool) : Option.Option = +let findFirstIndex (list: List<'a>) (fn: 'a -> Bool) : Option.Option = list |> indexedMap (fun i item -> (i, item)) |> findFirst (fun (_i, item) -> fn item) @@ -89,37 +89,37 @@ let ``member`` (list: List<'a>) (value: 'a) : Bool = // TODO: inline as a nested helper fn once Dark supports local function definitions -let repeatUnsafe (times: Int64) (value: 'a) : List<'a> = - if times <= 0L then +let repeatUnsafe (times: Int) (value: 'a) : List<'a> = + if times <= 0I then [] else - push (repeatUnsafe (times - 1L) value) value + push (repeatUnsafe (times - 1I) value) value /// Returns a list containing repeated times let repeat - (times: Int64) + (times: Int) (value: 'a) : Result.Result, String> = - if times < 0L then + if times < 0I then Result.Result.Error - $"Expected `times` to be positive, but it was `{times |> Int64.toString}`" + $"Expected `times` to be positive, but it was `{times |> Int.toString}`" else Result.Result.Ok(repeatUnsafe times value) /// Returns the number of values in -let ``length`` (list: List<'a>) : Int64 = +let ``length`` (list: List<'a>) : Int = Builtin.listLength list /// Returns a list of numbers where each element is {{1}} larger than the /// previous. You provide the and numbers in the list. -let range (lowest: Int64) (highest: Int64) : List = +let range (lowest: Int) (highest: Int) : List = if lowest > highest then [] else - push (range (lowest + 1L) highest) lowest + push (range (lowest + 1I) highest) lowest /// Folds into a single value, by repeatedly applying to any two pairs. @@ -216,20 +216,20 @@ let sortBy (list: List<'a>) (fn: 'a -> 'b) : List<'a> = /// This is a bit much. CLEANUP tidy this up module SortByComparatorHelpers = let validate - (comparator: 'a -> 'a -> Int64) + (comparator: 'a -> 'a -> Int) (x: 'a) (y: 'a) - : Result.Result = + : Result.Result = let result = comparator x y - if result == -1L || result == 0L || result == 1L then + if result == -1I || result == 0I || result == 1I then Result.Result.Ok result else Result.Result.Error - $"Expected comparator function to return -1, 0, or 1, but it returned {Int64.toString result}" + $"Expected comparator function to return -1, 0, or 1, but it returned {Int.toString result}" let merge - (comparator: 'a -> 'a -> Int64) + (comparator: 'a -> 'a -> Int) (left: List<'a>) (right: List<'a>) : Result.Result, String> = @@ -240,7 +240,7 @@ module SortByComparatorHelpers = match validate comparator x y with | Error msg -> Result.Result.Error msg | Ok result -> - if result <= 0L then + if result <= 0I then match merge comparator xs right with | Error msg -> Result.Result.Error msg | Ok merged -> Result.Result.Ok(push merged x) @@ -258,7 +258,7 @@ module SortByComparatorHelpers = (push left x, push right y) let mergeSort - (comparator: 'a -> 'a -> Int64) + (comparator: 'a -> 'a -> Int) (lst: List<'a>) : Result.Result, String> = match lst with @@ -283,7 +283,7 @@ module SortByComparatorHelpers = /// of control. let sortByComparator (list: List<'a>) - (fn: 'a -> 'a -> Int64) + (fn: 'a -> 'a -> Int) : Result.Result, String> = SortByComparatorHelpers.mergeSort fn list @@ -338,13 +338,13 @@ let filterMap /// Drops the first values from -let drop (list: List<'a>) (count: Int64) : List<'a> = - if count <= 0L then +let drop (list: List<'a>) (count: Int) : List<'a> = + if count <= 0I then list else match list with | [] -> [] - | _ :: tail -> drop tail (count - 1L) + | _ :: tail -> drop tail (count - 1I) /// Drops the longest prefix of which satisfies the predicate @@ -365,14 +365,14 @@ let dropLast (list: List<'a>) : List<'a> = /// Drops all but the first values from -let take (list: List<'a>) (count: Int64) : List<'a> = - if count <= 0L then +let take (list: List<'a>) (count: Int) : List<'a> = + if count <= 0I then [] else match list with | [] -> [] | head :: tail -> - push (take tail (count - 1L)) head + push (take tail (count - 1I)) head /// Return the longest prefix of which satisfies the predicate @@ -397,11 +397,11 @@ let map (list: List<'a>) (fn: 'a -> 'b) : List<'b> = /// Calls on every and its in , /// returning a list of the results of those calls. /// Consider if you don't need the index. -let indexedMap (list: List<'a>) (fn: Int64 -> 'a -> 'b) : List<'b> = +let indexedMap (list: List<'a>) (fn: Int -> 'a -> 'b) : List<'b> = list - |> fold ([], 0L) (fun (acc, index) item -> + |> fold ([], 0I) (fun (acc, index) item -> let mappedItem = fn index item - (pushBack acc mappedItem, index + 1L)) + (pushBack acc mappedItem, index + 1I)) |> Tuple2.first @@ -515,17 +515,17 @@ let unzip (pairs: List<('a * 'b)>) : (List<'a> * List<'b>) = /// Returns {{Some value}} at in if is /// less than the length of the list otherwise returns {{None}}. -let getAt (list: List<'a>) (index: Int64) : Option.Option<'a> = - if index < 0L then +let getAt (list: List<'a>) (index: Int) : Option.Option<'a> = + if index < 0I then Option.Option.None else match list with | [] -> Option.Option.None | head :: tail -> - if index == 0L then + if index == 0I then Option.Option.Some head else - getAt tail (index - 1L) + getAt tail (index - 1I) /// Returns {{Just }}, where is a randomly @@ -583,7 +583,7 @@ let iter (list: List<'a>) (f: 'a -> Unit) : Unit = /// Helper function for chunkBySize. Recursively divides a list into chunks of a given size. let chunkBySizeHelper - (size: Int64) + (size: Int) (currentList: List<'a>) (accum: List>) : List> = @@ -607,9 +607,9 @@ type ChunkBySizeError = | SizeMustBeGreaterThanZero /// If is less than or equal to zero, returns an error let chunkBySize (list: List<'a>) - (size: Int64) + (size: Int) : Result.Result>, ChunkBySizeError> = - if size <= 0L then + if size <= 0I then Result.Result.Error ChunkBySizeError.SizeMustBeGreaterThanZero else diff --git a/packages/darklang/stdlib/string.dark b/packages/darklang/stdlib/string.dark index 928fcd83ee..27b4e48da7 100644 --- a/packages/darklang/stdlib/string.dark +++ b/packages/darklang/stdlib/string.dark @@ -188,10 +188,10 @@ let digest (s: String) : String = /// Generate a random alphanumeric of length . /// Charset is {{[A-Za-z0-9]}} (62 chars). Errors if is negative. -let random (length: Int64) : Result.Result = - if length < 0L then +let random (length: Int) : Result.Result = + if length < 0I then Result.Result.Error - $"Expected `length` to be positive, but it was `{length |> Int64.toString}`" + $"Expected `length` to be positive, but it was `{length |> Int.toString}`" else let characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" @@ -203,7 +203,7 @@ let random (length: Int64) : Result.Result = String.slice characters index (index + 1L)) let result = - (List.range 0L (length - 1L)) + (List.range 0I (length - 1I)) |> List.map (fun _ -> randomChar ()) |> String.join "" @@ -327,7 +327,7 @@ let padStart Result.Result.Ok string else let padCount = goalLength - String.length string - let pad = String.repeat padWith padCount + let pad = String.repeat padWith (Stdlib.Int.fromInt64 padCount) Result.Result.Ok(pad ++ string) @@ -347,7 +347,7 @@ let padEnd Result.Result.Ok string else let padCount = goalLength - String.length string - let pad = String.repeat padWith padCount + let pad = String.repeat padWith (Stdlib.Int.fromInt64 padCount) Result.Result.Ok(string ++ pad) @@ -473,8 +473,8 @@ let lastIndexOfEgc /// Returns the repeated for a specified times. /// If is less than or equal to 0, returns an empty string. -let repeat (string: String) (count: Int64) : String = - if count <= 0L then +let repeat (string: String) (count: Int) : String = + if count <= 0I then "" else String.join ((List.repeat count string) |> Builtin.unwrap) "" @@ -508,5 +508,5 @@ let head (str: String) : Option.Option = /// Returns {{Some c}} for the character at (0-based, EGC, not /// byte), or {{None}} if is negative or past the end. -let charAt (str: String) (index: Int64) : Option.Option = +let charAt (str: String) (index: Int) : Option.Option = str |> String.toList |> List.getAt index \ No newline at end of file diff --git a/packages/darklang/stdlib/valueSearch.dark b/packages/darklang/stdlib/valueSearch.dark index 0109f678ce..d5ac9f1b4a 100644 --- a/packages/darklang/stdlib/valueSearch.dark +++ b/packages/darklang/stdlib/valueSearch.dark @@ -20,7 +20,7 @@ let isValueInNamespace (namespaceParts: List) (valuePath: List) : Bool = - if (Stdlib.List.length namespaceParts) == 0L then + if (Stdlib.List.length namespaceParts) == 0I then true else (Stdlib.List.take valuePath (Stdlib.List.length namespaceParts)) diff --git a/packages/darklang/wip/ai/anthropic/integration-tests.dark b/packages/darklang/wip/ai/anthropic/integration-tests.dark index e5bd8ce61c..6af4a37020 100644 --- a/packages/darklang/wip/ai/anthropic/integration-tests.dark +++ b/packages/darklang/wip/ai/anthropic/integration-tests.dark @@ -929,7 +929,7 @@ module BatchTests = (batchId: String) (maxAttempts: Int64) : Stdlib.Result.Result = - let attempts = Stdlib.List.range 1L maxAttempts + let attempts = Stdlib.List.range 1I (Stdlib.Int.fromInt64 maxAttempts) Stdlib.List.fold attempts @@ -969,7 +969,7 @@ module BatchTests = match Batch.getBatchResults apiKey completedBatch.id with | Ok results -> let successfulResults = Batch.getSuccessfulResults results - if Stdlib.List.length successfulResults >= 1L then + if Stdlib.List.length successfulResults >= 1I then TestResult.Pass else TestResult.Fail "No successful results found" @@ -1005,7 +1005,7 @@ module PromptCachingTests = // Create a large system prompt that will be cached (must be > 1024 tokens for caching) let largeSystemPrompt = "You are a helpful assistant. " ++ - (Stdlib.String.repeat "This is filler text to make the prompt large enough for caching. " 200L) + (Stdlib.String.repeat "This is filler text to make the prompt large enough for caching. " 200I) let cachedBlock = Content.systemBlockCached diff --git a/packages/stachu/darklangParser.dark b/packages/stachu/darklangParser.dark index b3273143b6..2ab22ff66c 100644 --- a/packages/stachu/darklangParser.dark +++ b/packages/stachu/darklangParser.dark @@ -189,8 +189,8 @@ let qualifiedName () : P = let allParts = parts match Stdlib.List.length allParts with - | 0L -> QualifiedName { modules = []; name = "" } - | 1L -> + | 0I -> QualifiedName { modules = []; name = "" } + | 1I -> match Stdlib.List.head allParts with | Some name -> QualifiedName { modules = []; name = name } | None -> QualifiedName { modules = []; name = "" } @@ -518,8 +518,8 @@ let enumLiteral (exprParser: P) : P = // Construct the type name from remaining parts let typeName = match Stdlib.List.length typeParts with - | 0L -> QualifiedName { modules = []; name = "" } - | 1L -> + | 0I -> QualifiedName { modules = []; name = "" } + | 1I -> let name = Stdlib.Option.withDefault (Stdlib.List.head typeParts) "" QualifiedName { modules = []; name = name } | _ -> @@ -702,7 +702,7 @@ let fnApplication (atomParser: P) : P = let (fn, args) = result match Stdlib.List.length args with - | 0L -> fn + | 0I -> fn | _ -> Expr.EApply(fn, [], args)) (Parser.andThen atomParser (Parser.many (Parser.keepRight (ws1 ()) atomParser))) @@ -799,7 +799,7 @@ let pipeExpr (exprParser: P) (atomParser: P) : P = let (expr, parts) = result match Stdlib.List.length parts with - | 0L -> expr + | 0I -> expr | _ -> Expr.EPipe(expr, parts)) (Parser.andThen exprParser diff --git a/packages/stachu/parser.dark b/packages/stachu/parser.dark index d3f715a882..161a21f8dd 100644 --- a/packages/stachu/parser.dark +++ b/packages/stachu/parser.dark @@ -183,8 +183,8 @@ let manyStrings (parser: Parser) : Parser> = Parser { run = (fun input -> - let maxIterations = 100L - let indices = Stdlib.List.range 0L maxIterations + let maxIterations = 100I + let indices = Stdlib.List.range 0I maxIterations let initialAcc = ManyAcc { results = []; remaining = input; done_ = false } @@ -224,8 +224,8 @@ let many (parser: Parser<'a>) : Parser> = Parser { run = (fun input -> - let maxIterations = 100L - let indices = Stdlib.List.range 0L maxIterations + let maxIterations = 100I + let indices = Stdlib.List.range 0I maxIterations let initialAcc = ManyAccGeneric { results = []; remaining = input; done_ = false } From 24cb42f8848573405d9659e0253d72f7213800d4 Mon Sep 17 00:00:00 2001 From: OceanOak Date: Tue, 16 Jun 2026 18:18:37 +0000 Subject: [PATCH 11/61] Migrate opml nodesToOpml depth to Int --- packages/darklang/opml/opml.dark | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/darklang/opml/opml.dark b/packages/darklang/opml/opml.dark index 410cee055b..49f6779c66 100644 --- a/packages/darklang/opml/opml.dark +++ b/packages/darklang/opml/opml.dark @@ -11,15 +11,15 @@ let escapeXml (text: String) : String = |> Stdlib.String.replaceAll ">" ">" |> Stdlib.String.replaceAll "\"" """ -let nodesToOpml (nodes: List) (depth: Int64) : List = +let nodesToOpml (nodes: List) (depth: Int) : List = nodes |> Stdlib.List.fold [] (fun acc node -> - let indent = Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (depth + 2L)) + let indent = Stdlib.String.repeat " " (depth + 2I) let escaped = escapeXml node.text if Stdlib.List.isEmpty node.children then Stdlib.List.append acc [$"{indent}"] else - let childLines = nodesToOpml node.children (depth + 1L) + let childLines = nodesToOpml node.children (depth + 1I) let open_ = $"{indent}" let close = $"{indent}" Stdlib.List.append acc (Stdlib.List.append (Stdlib.List.append [open_] childLines) [close])) @@ -32,7 +32,7 @@ let export (title: String) (nodes: List) : String = $" {title}" " " " " ] - let body = nodesToOpml nodes 0L + let body = nodesToOpml nodes 0I let footer = [ " " "" ] From 5a02848dd0bdddbd136c853a381bb3354285265f Mon Sep 17 00:00:00 2001 From: OceanOak Date: Tue, 16 Jun 2026 18:27:23 +0000 Subject: [PATCH 12/61] Migrate navInteractive index/viewport state to Int --- .../darklang/cli/packages/navInteractive.dark | 108 +++++++++--------- 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/packages/darklang/cli/packages/navInteractive.dark b/packages/darklang/cli/packages/navInteractive.dark index aa3ea1a51a..fe4eb8b8f7 100644 --- a/packages/darklang/cli/packages/navInteractive.dark +++ b/packages/darklang/cli/packages/navInteractive.dark @@ -24,8 +24,8 @@ type Mode = type State = { items: List - selectedIndex: Int64 - scrollOffset: Int64 + selectedIndex: Int + scrollOffset: Int currentLocation: PackageLocation mode: Mode display: Display @@ -81,8 +81,8 @@ let buildState (branchId: Uuid) (location: PackageLocation) : State = State { items = allItems - selectedIndex = 0L - scrollOffset = 0L + selectedIndex = 0I + scrollOffset = 0I currentLocation = location mode = Mode.Nav display = Display.JustName @@ -92,8 +92,8 @@ let buildState (branchId: Uuid) (location: PackageLocation) : State = // Truncated view for inline display to avoid flooding screen with large modules let viewEntityTruncated (branchId: Uuid) (location: PackageLocation) : Unit = - let maxItemsPerCategory = 3L - let maxTotalLines = 12L + let maxItemsPerCategory = 3I + let maxTotalLines = 12I match location with | Module path -> @@ -104,35 +104,35 @@ let viewEntityTruncated (branchId: Uuid) (location: PackageLocation) : Unit = let currentPathLength = Stdlib.List.length path let directSubmodules = Query.getDirectSubmodules results currentPathLength - let lineCount = 1L // Start with location line + let lineCount = 1I // Start with location line let lineCount = if Stdlib.Bool.not (Stdlib.List.isEmpty directSubmodules) then Stdlib.printLine (Display.getSectionHeader "submodule") - let itemsToShow = Stdlib.List.take directSubmodules (Stdlib.Int.fromInt64 maxItemsPerCategory) + let itemsToShow = Stdlib.List.take directSubmodules maxItemsPerCategory itemsToShow |> Stdlib.List.iter (fun name -> Stdlib.printLine $" {name}/") - let remaining = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length directSubmodules))) - maxItemsPerCategory - if remaining > 0L then - Stdlib.printLine $" ... and {Stdlib.Int64.toString remaining} more modules" + let remaining = (Stdlib.List.length directSubmodules) - maxItemsPerCategory + if remaining > 0I then + Stdlib.printLine $" ... and {Stdlib.Int.toString remaining} more modules" - lineCount + 1L + (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length itemsToShow))) + (if remaining > 0L then 1L else 0L) + lineCount + 1I + (Stdlib.List.length itemsToShow) + (if remaining > 0I then 1I else 0I) else lineCount // Only show other categories if we haven't exceeded line limit if lineCount < maxTotalLines then let remainingLines = maxTotalLines - lineCount - let itemsPerRemaining = Stdlib.Int64.min 2L remainingLines + let itemsPerRemaining = Stdlib.Int.min 2I remainingLines // Show types (limited) - if Stdlib.Bool.not (Stdlib.List.isEmpty results.types) && itemsPerRemaining > 0L then + if Stdlib.Bool.not (Stdlib.List.isEmpty results.types) && itemsPerRemaining > 0I then Stdlib.printLine (Display.getSectionHeader "type") - let typesToShow = Stdlib.List.take results.types (Stdlib.Int.fromInt64 itemsPerRemaining) + let typesToShow = Stdlib.List.take results.types itemsPerRemaining typesToShow |> Stdlib.List.iter (fun t -> Stdlib.printLine $" {t.location.name}") - let remaining = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length results.types))) - itemsPerRemaining - if remaining > 0L then - Stdlib.printLine $" ... and {Stdlib.Int64.toString remaining} more types" + let remaining = (Stdlib.List.length results.types) - itemsPerRemaining + if remaining > 0I then + Stdlib.printLine $" ... and {Stdlib.Int.toString remaining} more types" | _ -> // For individual entities, show full view since they're typically small @@ -167,25 +167,25 @@ let display (navState: State) : Unit = Stdlib.printLine (Stdlib.String.repeat "━" 60I) // Calculate viewport - let viewportHeight = 12L - let totalItems = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length navState.items))) + let viewportHeight = 12I + let totalItems = (Stdlib.List.length navState.items) - if totalItems == 0L then + if totalItems == 0I then Stdlib.printLine " (empty directory)" else // Calculate visible items let startIndex = navState.scrollOffset - let endIndex = Stdlib.Int64.min (startIndex + viewportHeight) totalItems + let endIndex = Stdlib.Int.min (startIndex + viewportHeight) totalItems let visibleItems = navState.items - |> Stdlib.List.drop (Stdlib.Int.fromInt64 startIndex) - |> Stdlib.List.take (Stdlib.Int.fromInt64 (endIndex - startIndex)) + |> Stdlib.List.drop startIndex + |> Stdlib.List.take (endIndex - startIndex) // Display items visibleItems |> Stdlib.List.indexedMap (fun relativeIndex item -> - let absoluteIndex = startIndex + (Builtin.unwrap (Stdlib.Int.toInt64 relativeIndex)) + let absoluteIndex = startIndex + relativeIndex let isSelected = absoluteIndex == navState.selectedIndex let icon = Display.getIcon item.entityType @@ -207,8 +207,8 @@ let display (navState: State) : Unit = // Show inline view and actions if displaying source and there are items match navState.display with | Source -> - if totalItems > 0L then - match Stdlib.List.getAt navState.items (Stdlib.Int.fromInt64 navState.selectedIndex) with + if totalItems > 0I then + match Stdlib.List.getAt navState.items navState.selectedIndex with | Some selectedItem -> Stdlib.printLines [ ""; (Stdlib.String.repeat "─" 60I) ] viewEntityTruncated navState.branchId selectedItem.location @@ -227,13 +227,13 @@ let display (navState: State) : Unit = // Navigation helper functions let moveUp (navState: State) : State = - let totalItems = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length navState.items))) - if totalItems > 0L then + let totalItems = (Stdlib.List.length navState.items) + if totalItems > 0I then let newIndex = - if navState.selectedIndex > 0L then - navState.selectedIndex - 1L + if navState.selectedIndex > 0I then + navState.selectedIndex - 1I else - totalItems - 1L + totalItems - 1I let newScrollOffset = if newIndex < navState.scrollOffset then @@ -248,18 +248,18 @@ let moveUp (navState: State) : State = navState let moveDown (navState: State) : State = - let totalItems = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length navState.items))) - if totalItems > 0L then + let totalItems = (Stdlib.List.length navState.items) + if totalItems > 0I then let newIndex = - if navState.selectedIndex < totalItems - 1L then - navState.selectedIndex + 1L + if navState.selectedIndex < totalItems - 1I then + navState.selectedIndex + 1I else - 0L + 0I - let viewportHeight = 12L + let viewportHeight = 12I let newScrollOffset = if newIndex >= navState.scrollOffset + viewportHeight then - newIndex - viewportHeight + 1L + newIndex - viewportHeight + 1I else navState.scrollOffset @@ -277,9 +277,9 @@ let exitToMainPrompt (state: Cli.AppState) : Cli.AppState = prompt = Prompt.Editing.clear state.prompt } let selectAndExit (state: Cli.AppState) (navState: State) : Cli.AppState = - let totalItems = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length navState.items))) - if totalItems > 0L then - match Stdlib.List.getAt navState.items (Stdlib.Int.fromInt64 navState.selectedIndex) with + let totalItems = (Stdlib.List.length navState.items) + if totalItems > 0I then + match Stdlib.List.getAt navState.items navState.selectedIndex with | Some selectedItem -> exitAlternateScreen () let newState = Nav.navTo state selectedItem.location @@ -294,9 +294,9 @@ let selectAndExit (state: Cli.AppState) (navState: State) : Cli.AppState = exitToMainPrompt state let navigateIntoModule (state: Cli.AppState) (navState: State) : Cli.AppState = - let totalItems = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length navState.items))) - if totalItems > 0L then - match Stdlib.List.getAt navState.items (Stdlib.Int.fromInt64 navState.selectedIndex) with + let totalItems = (Stdlib.List.length navState.items) + if totalItems > 0I then + match Stdlib.List.getAt navState.items navState.selectedIndex with | Some selectedItem -> match selectedItem.entityType with | Module -> @@ -328,8 +328,8 @@ let performSearch (navState: State) : State = // Empty query - restore all items { navState with items = navState.allItems - selectedIndex = 0L - scrollOffset = 0L } + selectedIndex = 0I + scrollOffset = 0I } else // Search through package system let currentModule = modulePathOf navState.currentLocation @@ -373,8 +373,8 @@ let performSearch (navState: State) : State = { navState with items = searchItems - selectedIndex = 0L - scrollOffset = 0L } + selectedIndex = 0I + scrollOffset = 0I } // Common key handlers let handleNavKeys (navState: State) (key: Stdlib.Cli.Stdin.Key.Key) : Stdlib.Option.Option = @@ -404,8 +404,8 @@ let handleSearchKeys mode = Mode.Nav searchQuery = "" items = navState.allItems - selectedIndex = 0L - scrollOffset = 0L } + selectedIndex = 0I + scrollOffset = 0I } Stdlib.Option.Option.Some( { state with currentPage = Page.InteractiveNav newNavState }) | Backspace -> @@ -455,9 +455,9 @@ let handleNavModeKeys | U -> match navState.display with | Source -> - let totalItems = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length navState.items))) - if totalItems > 0L then - match Stdlib.List.getAt navState.items (Stdlib.Int.fromInt64 navState.selectedIndex) with + let totalItems = (Stdlib.List.length navState.items) + if totalItems > 0I then + match Stdlib.List.getAt navState.items navState.selectedIndex with | Some selectedItem -> exitAlternateScreen () let locationStr = Packages.formatLocation selectedItem.location From 8771fce406ad52b5f83e0e4941a673848f4532b3 Mon Sep 17 00:00:00 2001 From: OceanOak Date: Wed, 17 Jun 2026 09:51:35 +0000 Subject: [PATCH 13/61] Migrate String length/index/slice fns from Int64 to Int --- .../src/Builtins/Builtins.Pure/Libs/String.fs | 69 +++- backend/testfiles/execution/cloud/db.dark | 4 +- backend/testfiles/execution/language/big.dark | 2 +- .../language/flow-control/ematch.dark | 2 +- backend/testfiles/execution/stdlib/list.dark | 2 +- .../testfiles/execution/stdlib/string.dark | 340 +++++++++--------- packages/darklang/cli/ai/agent.dark | 7 +- packages/darklang/cli/apps/command.dark | 2 +- packages/darklang/cli/apps/editor.dark | 8 +- .../darklang/cli/apps/views/ai-chats.dark | 4 +- .../cli/apps/views/package-stats.dark | 8 +- packages/darklang/cli/caps/command.dark | 2 +- packages/darklang/cli/caps/lineInput.dark | 24 +- packages/darklang/cli/core.dark | 6 +- .../darklang/cli/installation/download.dark | 4 +- packages/darklang/cli/outliner/main.dark | 2 +- packages/darklang/cli/outliner/markdown.dark | 6 +- .../darklang/cli/outliner/outline-editor.dark | 2 +- .../darklang/cli/outliner/text-editor.dark | 22 +- packages/darklang/cli/packages/db.dark | 10 +- packages/darklang/cli/packages/location.dark | 2 +- .../darklang/cli/packages/navInteractive.dark | 4 +- packages/darklang/cli/packages/tree.dark | 2 +- packages/darklang/cli/packages/view.dark | 2 +- packages/darklang/cli/prompt.dark | 32 +- packages/darklang/cli/scm/commit.dark | 2 +- packages/darklang/cli/scm/showCommit.dark | 4 +- .../darklang/cli/ui/components/button.dark | 4 +- packages/darklang/cli/ui/components/card.dark | 2 +- .../darklang/cli/ui/components/dropdown.dark | 14 +- .../darklang/cli/ui/components/forms.dark | 16 +- .../darklang/cli/ui/components/label.dark | 4 +- .../darklang/cli/ui/components/layout.dark | 2 +- .../darklang/cli/ui/components/listview.dark | 2 +- .../darklang/cli/ui/components/message.dark | 8 +- .../darklang/cli/ui/components/modal.dark | 2 +- .../cli/ui/components/navigation.dark | 8 +- .../darklang/cli/ui/components/spinner.dark | 2 +- .../darklang/cli/ui/components/statusbar.dark | 8 +- .../darklang/cli/ui/components/textblock.dark | 4 +- packages/darklang/cli/ui/core/rendering.dark | 16 +- packages/darklang/cli/ui/layout.dark | 4 +- packages/darklang/cli/utils/completion.dark | 20 +- packages/darklang/cli/utils/logo.dark | 2 +- .../cli/utils/syntaxHighlighting.dark | 8 +- packages/darklang/github.dark | 2 +- .../darklang/languageTools/capabilities.dark | 2 +- .../languageTools/lsp-server/completions.dark | 8 +- .../lsp-server/cursorPosition.dark | 3 +- .../languageTools/lsp-server/docSync.dark | 4 +- .../lsp-server/fileSystemProvider.dark | 12 +- .../languageTools/lsp-server/hover.dark | 6 +- .../languageTools/lsp-server/lsp-server.dark | 2 +- packages/darklang/languageTools/lsp.dark | 3 +- .../darklang/languageTools/parser/core.dark | 4 +- .../darklang/languageTools/parser/expr.dark | 2 +- .../languageTools/parser/matchPattern.dark | 2 +- .../darklang/languageTools/programTypes.dark | 2 +- packages/darklang/llm/tools/file-system.dark | 2 +- .../resources/resources.dark | 4 +- .../serverBuilder/io.dark | 2 +- .../darklang/prettyPrinter/capabilities.dark | 4 +- packages/darklang/prettyPrinter/common.dark | 31 +- .../darklang/prettyPrinter/programTypes.dark | 2 +- .../darklang/prettyPrinter/runtimeError.dark | 2 +- .../darklang/prettyPrinter/runtimeTypes.dark | 12 +- packages/darklang/stdlib/cli/file.dark | 2 +- packages/darklang/stdlib/cli/fileSystem.dark | 4 +- packages/darklang/stdlib/cli/path.dark | 16 +- packages/darklang/stdlib/cli/ui/table.dark | 12 +- packages/darklang/stdlib/duration.dark | 6 +- packages/darklang/stdlib/http.dark | 72 ++++ packages/darklang/stdlib/httpclient.dark | 6 +- packages/darklang/stdlib/httpserver.dark | 4 +- packages/darklang/stdlib/string.dark | 88 ++--- packages/darklang/stdlib/valueSearch.dark | 2 +- packages/darklang/tracing/format.dark | 2 +- .../wip/ai/anthropic/integration-tests.dark | 42 +-- packages/stachu/darklangParser.dark | 2 +- packages/stachu/parser.dark | 2 +- 80 files changed, 591 insertions(+), 480 deletions(-) diff --git a/backend/src/Builtins/Builtins.Pure/Libs/String.fs b/backend/src/Builtins/Builtins.Pure/Libs/String.fs index 337623239f..f69698bcdf 100644 --- a/backend/src/Builtins/Builtins.Pure/Libs/String.fs +++ b/backend/src/Builtins/Builtins.Pure/Libs/String.fs @@ -110,12 +110,12 @@ let fns () : List = { name = fn "stringLength" 0 typeParams = [] parameters = [ Param.make "s" TString "" ] - returnType = TInt64 + returnType = TInt description = "Returns the length of the string" fn = (function | _, _, _, [ DString s ] -> - s |> String.lengthInEgcs |> int64 |> Dval.int64 |> Ply + s |> String.lengthInEgcs |> bigint |> Dval.int |> Ply | _ -> incorrectArgs ()) sqlSpec = NotYetImplemented // CLEANUP: Sqlite has "LENGTH" but that counts characters; if we can get it to count EGCs, great previewable = Pure @@ -268,22 +268,25 @@ let fns () : List = typeParams = [] parameters = [ Param.make "string" TString "" - Param.make "from" TInt64 "" - Param.make "to" TInt64 "" ] + Param.make "from" TInt "" + Param.make "to" TInt "" ] returnType = TString description = "Returns the substring of between the and indices. Negative indices start counting from the end of ." fn = (function - | _, _, _, [ DString s; DInt64 first; DInt64 last ] -> + | _, _, _, [ DString s; DInt firstD; DInt lastD ] -> let getLengthInTextElements s = StringInfo(s).LengthInTextElements + // slice positions are bounded by string length; narrow Int -> native int + let first = int (DarkInt.toBigInt firstD) + let last = int (DarkInt.toBigInt lastD) + // Handle negative indexes (which allow counting from the end) let first = - if first < 0 then getLengthInTextElements (s) + int first else int first - let last = - if last < 0 then getLengthInTextElements (s) + int last else int last + if first < 0 then getLengthInTextElements (s) + first else first + let last = if last < 0 then getLengthInTextElements (s) + last else last if first >= last then Ply(DString "") @@ -451,6 +454,31 @@ let fns () : List = deprecated = NotDeprecated } + { name = fn "stringContains" 0 + typeParams = [] + parameters = + [ Param.make "lookingIn" TString "The string to search within" + Param.make "searchingFor" TString "The substring to look for" ] + returnType = TBool + description = + "Returns {{true}} if contains . + SQL-queryable: it only checks found/not-found, which SQLite's INSTR and + .NET's Contains agree on (unlike index position, which they count + differently for some Unicode text)." + fn = + (function + | _, _, _, [ DString lookingIn; DString searchingFor ] -> + Ply(DBool(lookingIn.Contains(searchingFor))) + | _ -> incorrectArgs ()) + // Emits a complete boolean fragment, so no Int value reaches the SqlCompiler. + sqlSpec = + SqlCallback2(fun lookingIn searchingFor -> + $"(INSTR({lookingIn}, {searchingFor}) > 0)") + previewable = Pure + capabilities = LibExecution.Capabilities.noCaps + deprecated = NotDeprecated } + + { name = fn "stringIndexOf" 0 typeParams = [] parameters = @@ -459,7 +487,7 @@ let fns () : List = "searchFor" TString "The string to search for within " ] - returnType = TInt64 + returnType = TInt description = "Returns the index of the first occurrence of in , measured in UTF-16 code units (the .NET string representation). Returns -1 if @@ -479,8 +507,13 @@ let fns () : List = (function | _, _, _, [ DString str; DString search ] -> let index = str.IndexOf(search) - Ply(DInt64 index) + Ply(Dval.int (bigint index)) | _ -> incorrectArgs ()) + // CLEANUP: now returns Int, which the SqlCompiler can't compile, so this + // sqlSpec is dormant — String.indexOf isn't usable in DB.query until Int is + // queryable. (String.contains has its own queryable Bool builtin, so it's + // unaffected.) The INSTR spec is kept so it works again automatically once + // Int becomes queryable. sqlSpec = SqlCallback2(fun str search -> $"(INSTR({str}, {search}) - 1)") previewable = Pure capabilities = LibExecution.Capabilities.noCaps @@ -495,7 +528,7 @@ let fns () : List = "searchFor" TString "The string to search for within " ] - returnType = TInt64 + returnType = TInt description = "Returns the index of the first occurrence of in , measured in extended grapheme clusters (consistent with {{String.length}}, @@ -509,7 +542,7 @@ let fns () : List = (function | _, _, _, [ DString str; DString search ] -> if search = "" then - Ply(DInt64 0L) + Ply(Dval.int (bigint 0)) else // EGC start offsets (UTF-16) of str. A valid match must start at one // of these AND end at one of these (or at str.Length). @@ -538,7 +571,7 @@ let fns () : List = ) = 0 if endIsBoundary && matches then foundAt <- egcIndex egcIndex <- egcIndex + 1 - Ply(DInt64(int64 foundAt)) + Ply(Dval.int (bigint foundAt)) | _ -> incorrectArgs ()) sqlSpec = NotYetImplemented previewable = Pure @@ -554,7 +587,7 @@ let fns () : List = "searchFor" TString "The string to search for within " ] - returnType = TInt64 + returnType = TInt description = "Returns the index of the last occurrence of in , measured in UTF-16 code units. Returns -1 if does not occur. @@ -564,7 +597,7 @@ let fns () : List = (function | _, _, _, [ DString str; DString search ] -> let index = str.LastIndexOf(search) - Ply(DInt64 index) + Ply(Dval.int (bigint index)) | _ -> incorrectArgs ()) sqlSpec = NotYetImplemented previewable = Pure @@ -580,7 +613,7 @@ let fns () : List = "searchFor" TString "The string to search for within " ] - returnType = TInt64 + returnType = TInt description = "Returns the index of the last occurrence of in , measured in extended grapheme clusters (consistent with {{String.length}}, @@ -591,7 +624,7 @@ let fns () : List = (function | _, _, _, [ DString str; DString search ] -> if search = "" then - Ply(DInt64(int64 (StringInfo(str).LengthInTextElements))) + Ply(Dval.int (bigint (StringInfo(str).LengthInTextElements))) else let starts = StringInfo.ParseCombiningCharacters(str) let mutable lastFound = -1 @@ -618,7 +651,7 @@ let fns () : List = ) = 0 if endIsBoundary && matches then lastFound <- egcIndex egcIndex <- egcIndex + 1 - Ply(DInt64(int64 lastFound)) + Ply(Dval.int (bigint lastFound)) | _ -> incorrectArgs ()) sqlSpec = NotYetImplemented previewable = Pure diff --git a/backend/testfiles/execution/cloud/db.dark b/backend/testfiles/execution/cloud/db.dark index b7c368476c..e378df9cff 100644 --- a/backend/testfiles/execution/cloud/db.dark +++ b/backend/testfiles/execution/cloud/db.dark @@ -826,7 +826,7 @@ module CompiledFunctions = // (friends (fun p -> Stdlib.String.reverse p.name == "lehcaR")) = [ "Rachel" ] // TODO: SQLite's LENGTH counts characters, not EGCs so we made it non queriable for now - // (friends (fun p -> Stdlib.String.length p.name > 5L)) = [ " Chandler " + // (friends (fun p -> Stdlib.String.length p.name > 5I)) = [ " Chandler " // "GrumpyCat" // "Rachel" ] (friends (fun p -> Stdlib.String.contains p.name "ROSS")) = [] @@ -1025,4 +1025,4 @@ module QueryCount = Stdlib.DB.queryCount PersonDB (fun p -> p.height > 3L)) = 4I -((Stdlib.DB.generateKey ()) |> Stdlib.String.length) = 36L +((Stdlib.DB.generateKey ()) |> Stdlib.String.length) = 36I diff --git a/backend/testfiles/execution/language/big.dark b/backend/testfiles/execution/language/big.dark index 632b44c4ff..695b79b6b1 100644 --- a/backend/testfiles/execution/language/big.dark +++ b/backend/testfiles/execution/language/big.dark @@ -29,7 +29,7 @@ module BigTestCase = |> (++) "\nhex64Encode: " |> (++) hexEncode |> (++) "\nstring length: " - |> (++) (Stdlib.Int64.toString_v0 sl) + |> (++) (Stdlib.Int.toString sl) |> (++) "\nbytes length: " |> (++) (Stdlib.Int.toString bl) |> (++) "\nbool: " diff --git a/backend/testfiles/execution/language/flow-control/ematch.dark b/backend/testfiles/execution/language/flow-control/ematch.dark index 3a4c07bf37..b0a2524c60 100644 --- a/backend/testfiles/execution/language/flow-control/ematch.dark +++ b/backend/testfiles/execution/language/flow-control/ematch.dark @@ -733,7 +733,7 @@ module GuardClause = | _ -> "fail") = "fail" (match (5L, "hello") with - | (x, y) when x > 0L && Stdlib.String.length y == 5L -> "pass" + | (x, y) when x > 0L && Stdlib.String.length y == 5I -> "pass" | _ -> "fail") = "pass" (match -5L with diff --git a/backend/testfiles/execution/stdlib/list.dark b/backend/testfiles/execution/stdlib/list.dark index 22d5f010e9..1317d21cd6 100644 --- a/backend/testfiles/execution/stdlib/list.dark +++ b/backend/testfiles/execution/stdlib/list.dark @@ -345,7 +345,7 @@ module GroupByWithKey = Stdlib.List.groupByWithKey_v0 [ "apple"; "banana"; "avocado"; "grape"; "apricot" ] - (fun s -> Stdlib.String.first_v0 s 1L) = [ ("a", [ "apple"; "avocado"; "apricot" ]) + (fun s -> Stdlib.String.first_v0 s 1I) = [ ("a", [ "apple"; "avocado"; "apricot" ]) ("b", [ "banana" ]) ("g", [ "grape" ]) ] diff --git a/backend/testfiles/execution/stdlib/string.dark b/backend/testfiles/execution/stdlib/string.dark index 7c5ada33b9..c6827d8be7 100644 --- a/backend/testfiles/execution/stdlib/string.dark +++ b/backend/testfiles/execution/stdlib/string.dark @@ -292,9 +292,9 @@ module Digest = module Random = (Stdlib.String.random 5I) == (Stdlib.String.random 5I) = false - Stdlib.String.length ((Stdlib.String.random 10I) |> Builtin.unwrap) = 10L - Stdlib.String.length ((Stdlib.String.random 5I) |> Builtin.unwrap) = 5L - Stdlib.String.length ((Stdlib.String.random 0I) |> Builtin.unwrap) = 0L + Stdlib.String.length ((Stdlib.String.random 10I) |> Builtin.unwrap) = 10I + Stdlib.String.length ((Stdlib.String.random 5I) |> Builtin.unwrap) = 5I + Stdlib.String.length ((Stdlib.String.random 0I) |> Builtin.unwrap) = 0I Stdlib.String.random -1I = Stdlib.Result.Result.Error "Expected `length` to be positive, but it was `-1`" @@ -334,15 +334,15 @@ module NewLine = module Length = - Stdlib.String.length "😄" = 1L - Stdlib.String.length "" = 0L - Stdlib.String.length "abcdef" = 6L - Stdlib.String.length "🧑🏽‍🦰🧑🏼‍💻🧑🏻‍🍼✋✋🏻✋🏿" = 6L - Stdlib.String.length "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇" = 5L - Stdlib.String.length "﷽﷽﷽﷽﷽" = 5L - Stdlib.String.length "👱👱🏻👱🏼👱🏽👱🏾👱🏿" = 6L - Stdlib.String.length "🧟‍♀️🧟‍♂️" = 2L - Stdlib.String.length "👨‍❤️‍💋‍👨👩‍👩‍👧‍👦🏳️‍⚧️‍️🇵🇷" = 4L + Stdlib.String.length "😄" = 1I + Stdlib.String.length "" = 0I + Stdlib.String.length "abcdef" = 6I + Stdlib.String.length "🧑🏽‍🦰🧑🏼‍💻🧑🏻‍🍼✋✋🏻✋🏿" = 6I + Stdlib.String.length "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇" = 5I + Stdlib.String.length "﷽﷽﷽﷽﷽" = 5I + Stdlib.String.length "👱👱🏻👱🏼👱🏽👱🏾👱🏿" = 6I + Stdlib.String.length "🧟‍♀️🧟‍♂️" = 2I + Stdlib.String.length "👨‍❤️‍💋‍👨👩‍👩‍👧‍👦🏳️‍⚧️‍️🇵🇷" = 4I module Prepend = @@ -527,35 +527,35 @@ module SplitFirst = module SplitN = - Stdlib.String.splitN "a|b|c|d" "|" 2L = [ "a"; "b|c|d" ] - Stdlib.String.splitN "a|b|c|d" "|" 3L = [ "a"; "b"; "c|d" ] - Stdlib.String.splitN "a|b|c|d" "|" 4L = [ "a"; "b"; "c"; "d" ] - Stdlib.String.splitN "a|b|c|d" "|" 99L = [ "a"; "b"; "c"; "d" ] + Stdlib.String.splitN "a|b|c|d" "|" 2I = [ "a"; "b|c|d" ] + Stdlib.String.splitN "a|b|c|d" "|" 3I = [ "a"; "b"; "c|d" ] + Stdlib.String.splitN "a|b|c|d" "|" 4I = [ "a"; "b"; "c"; "d" ] + Stdlib.String.splitN "a|b|c|d" "|" 99I = [ "a"; "b"; "c"; "d" ] - Stdlib.String.splitN "a|b|c|d" "|" 1L = [ "a|b|c|d" ] - Stdlib.String.splitN "a|b|c|d" "|" 0L = [ "a|b|c|d" ] - Stdlib.String.splitN "a|b|c|d" "|" -1L = [ "a|b|c|d" ] + Stdlib.String.splitN "a|b|c|d" "|" 1I = [ "a|b|c|d" ] + Stdlib.String.splitN "a|b|c|d" "|" 0I = [ "a|b|c|d" ] + Stdlib.String.splitN "a|b|c|d" "|" -1I = [ "a|b|c|d" ] - Stdlib.String.splitN "abc" "|" 3L = [ "abc" ] - Stdlib.String.splitN "" "|" 3L = [ "" ] + Stdlib.String.splitN "abc" "|" 3I = [ "abc" ] + Stdlib.String.splitN "" "|" 3I = [ "" ] - Stdlib.String.splitN "abc" "" 3L = [ "abc" ] - Stdlib.String.splitN "a|b" "" 2L = [ "a|b" ] + Stdlib.String.splitN "abc" "" 3I = [ "abc" ] + Stdlib.String.splitN "a|b" "" 2I = [ "a|b" ] - Stdlib.String.splitN "hello😄world😄sun" "😄" 2L = [ "hello"; "world😄sun" ] - Stdlib.String.splitN "a==b==c==d" "==" 3L = [ "a"; "b"; "c==d" ] + Stdlib.String.splitN "hello😄world😄sun" "😄" 2I = [ "hello"; "world😄sun" ] + Stdlib.String.splitN "a==b==c==d" "==" 3I = [ "a"; "b"; "c==d" ] // ZWJ-bearing prefixes work because splitN routes through indexOfEgc. - Stdlib.String.splitN "🧑🏽‍🦰|🧑🏼‍💻|🧑🏻‍🍼" "|" 2L = [ "🧑🏽‍🦰"; "🧑🏼‍💻|🧑🏻‍🍼" ] - Stdlib.String.splitN "🧑🏽‍🦰|🧑🏼‍💻|🧑🏻‍🍼" "|" 3L = [ "🧑🏽‍🦰"; "🧑🏼‍💻"; "🧑🏻‍🍼" ] + Stdlib.String.splitN "🧑🏽‍🦰|🧑🏼‍💻|🧑🏻‍🍼" "|" 2I = [ "🧑🏽‍🦰"; "🧑🏼‍💻|🧑🏻‍🍼" ] + Stdlib.String.splitN "🧑🏽‍🦰|🧑🏼‍💻|🧑🏻‍🍼" "|" 3I = [ "🧑🏽‍🦰"; "🧑🏼‍💻"; "🧑🏻‍🍼" ] // ZWJ separator with mixed-width content on both sides. - Stdlib.String.splitN "a🧑🏼‍💻b🧑🏼‍💻c" "🧑🏼‍💻" 2L = [ "a"; "b🧑🏼‍💻c" ] - Stdlib.String.splitN "a🧑🏼‍💻b🧑🏼‍💻c" "🧑🏼‍💻" 3L = [ "a"; "b"; "c" ] - Stdlib.String.splitN "żółw🧑🏼‍💻x🧑🏼‍💻y" "🧑🏼‍💻" 2L = [ "żółw"; "x🧑🏼‍💻y" ] + Stdlib.String.splitN "a🧑🏼‍💻b🧑🏼‍💻c" "🧑🏼‍💻" 2I = [ "a"; "b🧑🏼‍💻c" ] + Stdlib.String.splitN "a🧑🏼‍💻b🧑🏼‍💻c" "🧑🏼‍💻" 3I = [ "a"; "b"; "c" ] + Stdlib.String.splitN "żółw🧑🏼‍💻x🧑🏼‍💻y" "🧑🏼‍💻" 2I = [ "żółw"; "x🧑🏼‍💻y" ] // Adjacent separators yield empty pieces, with a ZWJ separator. - Stdlib.String.splitN "🧑🏼‍💻🧑🏼‍💻x" "🧑🏼‍💻" 3L = [ ""; ""; "x" ] + Stdlib.String.splitN "🧑🏼‍💻🧑🏼‍💻x" "🧑🏼‍💻" 3I = [ ""; ""; "x" ] module ToLowercase = @@ -701,56 +701,56 @@ module Reverse = module DropFirst = - Stdlib.String.dropFirst_v0 "abcd" -3L = "abcd" - Stdlib.String.dropFirst_v0 "abcd" 0L = "abcd" - Stdlib.String.dropFirst_v0 "abcd" 3L = "d" - Stdlib.String.dropFirst_v0 "" 3L = "" - Stdlib.String.dropFirst_v0 "abcd" 3L = "d" - Stdlib.String.dropFirst_v0 "🍏🍒🍒" 1L = "🍒🍒" - Stdlib.String.dropFirst_v0 "🍏🍒🍍" 2L = "🍍" - Stdlib.String.dropFirst_v0 "🍏a🍒b🍍c" 2L = "🍒b🍍c" - Stdlib.String.dropFirst_v0 "żółw🧑🏽‍🦰🧑🏻‍🍼✋✋🏻✋🏿" 5L = "🧑🏻‍🍼✋✋🏻✋🏿" - Stdlib.String.dropFirst_v0 "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇" 1L = "ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇" - Stdlib.String.dropFirst_v0 "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇" 2L = "lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇" - Stdlib.String.dropFirst_v0 "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇" 3L = "ǧ̗͚̚o̙̔ͮ̇͐̇" - Stdlib.String.dropFirst_v0 "﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽" 1L = "﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽" - Stdlib.String.dropFirst_v0 "👱👱🏻👱🏼👱🏽👱🏾👱🏿" 1L = "👱🏻👱🏼👱🏽👱🏾👱🏿" - Stdlib.String.dropFirst_v0 "🧟‍♀️🧟‍♂️" 20L = "" - Stdlib.String.dropFirst_v0 "👨‍❤️‍💋‍👨👩‍👩‍👧‍👦🏳️‍⚧️‍️🇵🇷" 3L = "🇵🇷" + Stdlib.String.dropFirst_v0 "abcd" -3I = "abcd" + Stdlib.String.dropFirst_v0 "abcd" 0I = "abcd" + Stdlib.String.dropFirst_v0 "abcd" 3I = "d" + Stdlib.String.dropFirst_v0 "" 3I = "" + Stdlib.String.dropFirst_v0 "abcd" 3I = "d" + Stdlib.String.dropFirst_v0 "🍏🍒🍒" 1I = "🍒🍒" + Stdlib.String.dropFirst_v0 "🍏🍒🍍" 2I = "🍍" + Stdlib.String.dropFirst_v0 "🍏a🍒b🍍c" 2I = "🍒b🍍c" + Stdlib.String.dropFirst_v0 "żółw🧑🏽‍🦰🧑🏻‍🍼✋✋🏻✋🏿" 5I = "🧑🏻‍🍼✋✋🏻✋🏿" + Stdlib.String.dropFirst_v0 "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇" 1I = "ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇" + Stdlib.String.dropFirst_v0 "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇" 2I = "lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇" + Stdlib.String.dropFirst_v0 "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇" 3I = "ǧ̗͚̚o̙̔ͮ̇͐̇" + Stdlib.String.dropFirst_v0 "﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽" 1I = "﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽" + Stdlib.String.dropFirst_v0 "👱👱🏻👱🏼👱🏽👱🏾👱🏿" 1I = "👱🏻👱🏼👱🏽👱🏾👱🏿" + Stdlib.String.dropFirst_v0 "🧟‍♀️🧟‍♂️" 20I = "" + Stdlib.String.dropFirst_v0 "👨‍❤️‍💋‍👨👩‍👩‍👧‍👦🏳️‍⚧️‍️🇵🇷" 3I = "🇵🇷" module DropLast = - Stdlib.String.dropLast_v0 "abcd" -3L = "abcd" - Stdlib.String.dropLast_v0 "abcd" 0L = "abcd" - Stdlib.String.dropLast_v0 "abcd" 3L = "a" - Stdlib.String.dropLast_v0 "" 3L = "" - Stdlib.String.dropLast_v0 "🍏🍒🍒" 1L = "🍏🍒" - Stdlib.String.dropLast_v0 "🍏🍒🍍" 2L = "🍏" - Stdlib.String.dropLast_v0 "🍏a🍒b🍍c" 2L = "🍏a🍒b" - Stdlib.String.dropLast_v0 "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇" 2L = "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫ" - Stdlib.String.dropLast_v0 "﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽" 10L = "﷽﷽﷽﷽﷽﷽" - Stdlib.String.dropLast_v0 "👱👱🏻👱🏼👱🏽👱🏾👱🏿" 3L = "👱👱🏻👱🏼" - Stdlib.String.dropLast_v0 "🧟‍♀️🧟‍♂️" 20L = "" - Stdlib.String.dropLast_v0 "👨‍❤️‍💋‍👨👩‍👩‍👧‍👦🏳️‍⚧️‍️🇵🇷" 2L = "👨‍❤️‍💋‍👨👩‍👩‍👧‍👦" - Stdlib.String.dropLast_v0 "żółw🧑🏽‍🦰🧑🏻‍🍼✋✋🏻✋🏿" 4L = "żółw🧑🏽‍🦰" + Stdlib.String.dropLast_v0 "abcd" -3I = "abcd" + Stdlib.String.dropLast_v0 "abcd" 0I = "abcd" + Stdlib.String.dropLast_v0 "abcd" 3I = "a" + Stdlib.String.dropLast_v0 "" 3I = "" + Stdlib.String.dropLast_v0 "🍏🍒🍒" 1I = "🍏🍒" + Stdlib.String.dropLast_v0 "🍏🍒🍍" 2I = "🍏" + Stdlib.String.dropLast_v0 "🍏a🍒b🍍c" 2I = "🍏a🍒b" + Stdlib.String.dropLast_v0 "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇" 2I = "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫ" + Stdlib.String.dropLast_v0 "﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽" 10I = "﷽﷽﷽﷽﷽﷽" + Stdlib.String.dropLast_v0 "👱👱🏻👱🏼👱🏽👱🏾👱🏿" 3I = "👱👱🏻👱🏼" + Stdlib.String.dropLast_v0 "🧟‍♀️🧟‍♂️" 20I = "" + Stdlib.String.dropLast_v0 "👨‍❤️‍💋‍👨👩‍👩‍👧‍👦🏳️‍⚧️‍️🇵🇷" 2I = "👨‍❤️‍💋‍👨👩‍👩‍👧‍👦" + Stdlib.String.dropLast_v0 "żółw🧑🏽‍🦰🧑🏻‍🍼✋✋🏻✋🏿" 4I = "żółw🧑🏽‍🦰" module Last = - Stdlib.String.last_v0 "żółw🧑🏽‍🦰🧑🏻‍🍼✋✋🏻✋🏿" 4L = "🧑🏻‍🍼✋✋🏻✋🏿" - Stdlib.String.last_v0 "abcd" -3L = "" - Stdlib.String.last_v0 "abcd" 0L = "" - Stdlib.String.last_v0 "" 7L = "" - Stdlib.String.last_v0 "abcd" 1L = "d" - Stdlib.String.last_v0 "abcd" 2L = "cd" - Stdlib.String.last_v0 "abcd" 3L = "bcd" - Stdlib.String.last_v0 "🍍🍍🍏" 1L = "🍏" - Stdlib.String.last_v0 "🍊🍍🍏" 2L = "🍍🍏" - Stdlib.String.last_v0 "🧑🏽‍🦰🧑🏻‍🍼✋✋🏻✋🏿🧑🏻‍🍼" 1L = "🧑🏻‍🍼" - Stdlib.String.last_v0 "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇" 2L = "ǧ̗͚̚o̙̔ͮ̇͐̇" - Stdlib.String.last_v0 "﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽" 2L = "﷽﷽" - Stdlib.String.last_v0 "👱👱🏻👱🏼👱🏽👱🏾👱🏿" 3L = "👱🏽👱🏾👱🏿" - Stdlib.String.last_v0 "🧟‍♀️🧟‍♂️" 1L = "🧟‍♂️" - Stdlib.String.last_v0 "👨‍❤️‍💋‍👨👩‍👩‍👧‍👦🏳️‍⚧️‍️🇵🇷" 1L = "🇵🇷" + Stdlib.String.last_v0 "żółw🧑🏽‍🦰🧑🏻‍🍼✋✋🏻✋🏿" 4I = "🧑🏻‍🍼✋✋🏻✋🏿" + Stdlib.String.last_v0 "abcd" -3I = "" + Stdlib.String.last_v0 "abcd" 0I = "" + Stdlib.String.last_v0 "" 7I = "" + Stdlib.String.last_v0 "abcd" 1I = "d" + Stdlib.String.last_v0 "abcd" 2I = "cd" + Stdlib.String.last_v0 "abcd" 3I = "bcd" + Stdlib.String.last_v0 "🍍🍍🍏" 1I = "🍏" + Stdlib.String.last_v0 "🍊🍍🍏" 2I = "🍍🍏" + Stdlib.String.last_v0 "🧑🏽‍🦰🧑🏻‍🍼✋✋🏻✋🏿🧑🏻‍🍼" 1I = "🧑🏻‍🍼" + Stdlib.String.last_v0 "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇" 2I = "ǧ̗͚̚o̙̔ͮ̇͐̇" + Stdlib.String.last_v0 "﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽" 2I = "﷽﷽" + Stdlib.String.last_v0 "👱👱🏻👱🏼👱🏽👱🏾👱🏿" 3I = "👱🏽👱🏾👱🏿" + Stdlib.String.last_v0 "🧟‍♀️🧟‍♂️" 1I = "🧟‍♂️" + Stdlib.String.last_v0 "👨‍❤️‍💋‍👨👩‍👩‍👧‍👦🏳️‍⚧️‍️🇵🇷" 1I = "🇵🇷" module Contains = @@ -766,92 +766,92 @@ module Contains = module Slice = - Stdlib.String.slice_v0 "abcd" -2L 4L = "cd" - Stdlib.String.slice_v0 "abcd" -5L -6L = "" - Stdlib.String.slice_v0 "abcd" -5L 1L = "a" - Stdlib.String.slice_v0 "abcd" 0L -1L = "abc" - Stdlib.String.slice_v0 "abcd" 2L 3L = "c" - Stdlib.String.slice_v0 "abcd" 2L 6L = "cd" - Stdlib.String.slice_v0 "abcd" 3L 2L = "" - Stdlib.String.slice_v0 "abcd" 5L 6L = "" - Stdlib.String.slice_v0 "🧑🏽‍🦰🧑🏻‍🍼✋✋🏻✋🏿" 2L 10L = "✋✋🏻✋🏿" - Stdlib.String.slice_v0 "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇" 1L 3L = "ä͖̭̈̇lͮ̒ͫ" - Stdlib.String.slice_v0 "﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽" 2L 6L = "﷽﷽﷽﷽" - Stdlib.String.slice_v0 "👱👱🏻👱🏼👱🏽👱🏾👱🏿" 2L 6L = "👱🏼👱🏽👱🏾👱🏿" - Stdlib.String.slice_v0 "🧟‍♀️🧟‍♂️" 2L 4L = "" - Stdlib.String.slice_v0 "👨‍❤️‍💋‍👨👩‍👩‍👧‍👦🏳️‍⚧️‍️🇵🇷" 2L 10L = "🏳️‍⚧️‍️🇵🇷" - Stdlib.String.slice_v0 "abc" 0L 4503599627370498L = "abc" + Stdlib.String.slice_v0 "abcd" -2I 4I = "cd" + Stdlib.String.slice_v0 "abcd" -5I -6I = "" + Stdlib.String.slice_v0 "abcd" -5I 1I = "a" + Stdlib.String.slice_v0 "abcd" 0I -1I = "abc" + Stdlib.String.slice_v0 "abcd" 2I 3I = "c" + Stdlib.String.slice_v0 "abcd" 2I 6I = "cd" + Stdlib.String.slice_v0 "abcd" 3I 2I = "" + Stdlib.String.slice_v0 "abcd" 5I 6I = "" + Stdlib.String.slice_v0 "🧑🏽‍🦰🧑🏻‍🍼✋✋🏻✋🏿" 2I 10I = "✋✋🏻✋🏿" + Stdlib.String.slice_v0 "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇" 1I 3I = "ä͖̭̈̇lͮ̒ͫ" + Stdlib.String.slice_v0 "﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽" 2I 6I = "﷽﷽﷽﷽" + Stdlib.String.slice_v0 "👱👱🏻👱🏼👱🏽👱🏾👱🏿" 2I 6I = "👱🏼👱🏽👱🏾👱🏿" + Stdlib.String.slice_v0 "🧟‍♀️🧟‍♂️" 2I 4I = "" + Stdlib.String.slice_v0 "👨‍❤️‍💋‍👨👩‍👩‍👧‍👦🏳️‍⚧️‍️🇵🇷" 2I 10I = "🏳️‍⚧️‍️🇵🇷" + Stdlib.String.slice_v0 "abc" 0I 4503599627370498I = "abc" module First = - Stdlib.String.first_v0 "abcd" -3L = "" - Stdlib.String.first_v0 "abcd" 0L = "" - Stdlib.String.first_v0 "abcd" 1L = "a" - Stdlib.String.first_v0 "abcd" 2L = "ab" - Stdlib.String.first_v0 "abcd" 3L = "abc" - Stdlib.String.first_v0 "abcd" 3000000000000000L = "abcd" - Stdlib.String.first_v0 "" 7L = "" - Stdlib.String.first_v0 "🍊🍍🍏" 1L = "🍊" - Stdlib.String.first_v0 "🍊🍍🍏" 2L = "🍊🍍" - Stdlib.String.first_v0 "🍊🍍🍏" 3L = "🍊🍍🍏" - Stdlib.String.first_v0 "🧑🏽‍🦰🧑🏻‍🍼✋✋🏻✋🏿" 1L = "🧑🏽‍🦰" - Stdlib.String.first_v0 "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇" 10L = "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇" - Stdlib.String.first_v0 "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇" 2L = "Z̤͔ͧ̑̓ä͖̭̈̇" - Stdlib.String.first_v0 "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇" 3L = "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫ" - Stdlib.String.first_v0 "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇" 4L = "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚" - Stdlib.String.first_v0 "﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽" 1L = "﷽" - Stdlib.String.first_v0 "👱👱🏻👱🏼👱🏽👱🏾👱🏿" 2L = "👱👱🏻" - Stdlib.String.first_v0 "🧟‍♀️🧟‍♂️" 1L = "🧟‍♀️" - Stdlib.String.first_v0 "👨‍❤️‍💋‍👨👩‍👩‍👧‍👦🏳️‍⚧️‍️🇵🇷" 3L = "👨‍❤️‍💋‍👨👩‍👩‍👧‍👦🏳️‍⚧️‍️" + Stdlib.String.first_v0 "abcd" -3I = "" + Stdlib.String.first_v0 "abcd" 0I = "" + Stdlib.String.first_v0 "abcd" 1I = "a" + Stdlib.String.first_v0 "abcd" 2I = "ab" + Stdlib.String.first_v0 "abcd" 3I = "abc" + Stdlib.String.first_v0 "abcd" 3000000000000000I = "abcd" + Stdlib.String.first_v0 "" 7I = "" + Stdlib.String.first_v0 "🍊🍍🍏" 1I = "🍊" + Stdlib.String.first_v0 "🍊🍍🍏" 2I = "🍊🍍" + Stdlib.String.first_v0 "🍊🍍🍏" 3I = "🍊🍍🍏" + Stdlib.String.first_v0 "🧑🏽‍🦰🧑🏻‍🍼✋✋🏻✋🏿" 1I = "🧑🏽‍🦰" + Stdlib.String.first_v0 "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇" 10I = "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇" + Stdlib.String.first_v0 "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇" 2I = "Z̤͔ͧ̑̓ä͖̭̈̇" + Stdlib.String.first_v0 "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇" 3I = "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫ" + Stdlib.String.first_v0 "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇" 4I = "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚" + Stdlib.String.first_v0 "﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽" 1I = "﷽" + Stdlib.String.first_v0 "👱👱🏻👱🏼👱🏽👱🏾👱🏿" 2I = "👱👱🏻" + Stdlib.String.first_v0 "🧟‍♀️🧟‍♂️" 1I = "🧟‍♀️" + Stdlib.String.first_v0 "👨‍❤️‍💋‍👨👩‍👩‍👧‍👦🏳️‍⚧️‍️🇵🇷" 3I = "👨‍❤️‍💋‍👨👩‍👩‍👧‍👦🏳️‍⚧️‍️" module PadStart = - Stdlib.String.padStart_v0 "123" "0" 3L = Stdlib.Result.Result.Ok "123" - Stdlib.String.padStart_v0 "123" "0" -3L = Stdlib.Result.Result.Ok "123" - Stdlib.String.padStart_v0 "123" "0" 6L = Stdlib.Result.Result.Ok "000123" - Stdlib.String.padStart_v0 "" "0" 0L = Stdlib.Result.Result.Ok "" - Stdlib.String.padStart_v0 "123🍊🍊" "0" 3L = Stdlib.Result.Result.Ok "123🍊🍊" - Stdlib.String.padStart_v0 "🍍🍍🍊🍊" "0" 7L = Stdlib.Result.Result.Ok "000🍍🍍🍊🍊" - Stdlib.String.padStart_v0 "żółw🧑🏽‍🦰🧑🏻‍🍼✋✋🏻✋🏿" "0" 10L = Stdlib.Result.Result.Ok "0żółw🧑🏽‍🦰🧑🏻‍🍼✋✋🏻✋🏿" - Stdlib.String.padStart_v0 "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇" "0" 10L = Stdlib.Result.Result.Ok "00000Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇" - Stdlib.String.padStart_v0 "﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽" "0" 20L = Stdlib.Result.Result.Ok "0000﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽" - Stdlib.String.padStart_v0 "👱👱🏻👱🏼👱🏽👱🏾👱🏿" "0" 10L = Stdlib.Result.Result.Ok "0000👱👱🏻👱🏼👱🏽👱🏾👱🏿" - Stdlib.String.padStart_v0 "🧟‍♀️🧟‍♂️" "0" 5L = Stdlib.Result.Result.Ok "000🧟‍♀️🧟‍♂️" - Stdlib.String.padStart_v0 "👨‍❤️‍💋‍👨👩‍👩‍👧‍👦🏳️‍⚧️🇵🇷" "0" 10L = Stdlib.Result.Result.Ok "000000👨‍❤️‍💋‍👨👩‍👩‍👧‍👦🏳️‍⚧️🇵🇷" - Stdlib.String.padStart_v0 "鷝" "觌഻" 0L = Stdlib.Result.Result.Ok "鷝" - - Stdlib.String.padStart_v0 "123" "_-" 4L = Stdlib.Result.Result.Error "Expected `padWith` to be 1 character long, but it was `\"_-\"`" - Stdlib.String.padStart_v0 "123" "" 10L = Stdlib.Result.Result.Error "Expected `padWith` to be 1 character long, but it was `\"\"`" + Stdlib.String.padStart_v0 "123" "0" 3I = Stdlib.Result.Result.Ok "123" + Stdlib.String.padStart_v0 "123" "0" -3I = Stdlib.Result.Result.Ok "123" + Stdlib.String.padStart_v0 "123" "0" 6I = Stdlib.Result.Result.Ok "000123" + Stdlib.String.padStart_v0 "" "0" 0I = Stdlib.Result.Result.Ok "" + Stdlib.String.padStart_v0 "123🍊🍊" "0" 3I = Stdlib.Result.Result.Ok "123🍊🍊" + Stdlib.String.padStart_v0 "🍍🍍🍊🍊" "0" 7I = Stdlib.Result.Result.Ok "000🍍🍍🍊🍊" + Stdlib.String.padStart_v0 "żółw🧑🏽‍🦰🧑🏻‍🍼✋✋🏻✋🏿" "0" 10I = Stdlib.Result.Result.Ok "0żółw🧑🏽‍🦰🧑🏻‍🍼✋✋🏻✋🏿" + Stdlib.String.padStart_v0 "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇" "0" 10I = Stdlib.Result.Result.Ok "00000Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇" + Stdlib.String.padStart_v0 "﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽" "0" 20I = Stdlib.Result.Result.Ok "0000﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽" + Stdlib.String.padStart_v0 "👱👱🏻👱🏼👱🏽👱🏾👱🏿" "0" 10I = Stdlib.Result.Result.Ok "0000👱👱🏻👱🏼👱🏽👱🏾👱🏿" + Stdlib.String.padStart_v0 "🧟‍♀️🧟‍♂️" "0" 5I = Stdlib.Result.Result.Ok "000🧟‍♀️🧟‍♂️" + Stdlib.String.padStart_v0 "👨‍❤️‍💋‍👨👩‍👩‍👧‍👦🏳️‍⚧️🇵🇷" "0" 10I = Stdlib.Result.Result.Ok "000000👨‍❤️‍💋‍👨👩‍👩‍👧‍👦🏳️‍⚧️🇵🇷" + Stdlib.String.padStart_v0 "鷝" "觌഻" 0I = Stdlib.Result.Result.Ok "鷝" + + Stdlib.String.padStart_v0 "123" "_-" 4I = Stdlib.Result.Result.Error "Expected `padWith` to be 1 character long, but it was `\"_-\"`" + Stdlib.String.padStart_v0 "123" "" 10I = Stdlib.Result.Result.Error "Expected `padWith` to be 1 character long, but it was `\"\"`" module PadEnd = - Stdlib.String.padEnd_v0 "" "0" 0L = Stdlib.Result.Result.Ok "" - Stdlib.String.padEnd_v0 "123" "0" 3L = Stdlib.Result.Result.Ok "123" - Stdlib.String.padEnd_v0 "123" "0" 6L = Stdlib.Result.Result.Ok "123000" - Stdlib.String.padEnd_v0 "123" "0" -3L = Stdlib.Result.Result.Ok "123" - Stdlib.String.padEnd_v0 "123🍊🍊" "0" 8L = Stdlib.Result.Result.Ok "123🍊🍊000" - Stdlib.String.padEnd_v0 "żółw🧑🏽‍🦰🧑🏻‍🍼✋✋🏻✋🏿" "0" 10L = Stdlib.Result.Result.Ok "żółw🧑🏽‍🦰🧑🏻‍🍼✋✋🏻✋🏿0" - Stdlib.String.padEnd_v0 "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇" "0" 10L = Stdlib.Result.Result.Ok "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇00000" - Stdlib.String.padEnd_v0 "﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽" "0" 20L = Stdlib.Result.Result.Ok "﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽0000" - Stdlib.String.padEnd_v0 "👱👱🏻👱🏼👱🏽👱🏾👱🏿" "0" 10L = Stdlib.Result.Result.Ok "👱👱🏻👱🏼👱🏽👱🏾👱🏿0000" - Stdlib.String.padEnd_v0 "🧟‍♀️🧟‍♂️" "0" 5L = Stdlib.Result.Result.Ok "🧟‍♀️🧟‍♂️000" - Stdlib.String.padEnd_v0 "👨‍❤️‍💋‍👨👩‍👩‍👧‍👦🏳️‍⚧️🇵🇷" "0" 10L = Stdlib.Result.Result.Ok "👨‍❤️‍💋‍👨👩‍👩‍👧‍👦🏳️‍⚧️🇵🇷000000" - Stdlib.String.padEnd_v0 "鷝" "觌഻" 0L = Stdlib.Result.Result.Ok "鷝" - - Stdlib.String.padEnd_v0 "123" "_-" 3L = Stdlib.Result.Result.Error "Expected `padWith` to be 1 character long, but it was `\"_-\"`" - Stdlib.String.padEnd_v0 "123" "" 10L = Stdlib.Result.Result.Error "Expected `padWith` to be 1 character long, but it was `\"\"`" + Stdlib.String.padEnd_v0 "" "0" 0I = Stdlib.Result.Result.Ok "" + Stdlib.String.padEnd_v0 "123" "0" 3I = Stdlib.Result.Result.Ok "123" + Stdlib.String.padEnd_v0 "123" "0" 6I = Stdlib.Result.Result.Ok "123000" + Stdlib.String.padEnd_v0 "123" "0" -3I = Stdlib.Result.Result.Ok "123" + Stdlib.String.padEnd_v0 "123🍊🍊" "0" 8I = Stdlib.Result.Result.Ok "123🍊🍊000" + Stdlib.String.padEnd_v0 "żółw🧑🏽‍🦰🧑🏻‍🍼✋✋🏻✋🏿" "0" 10I = Stdlib.Result.Result.Ok "żółw🧑🏽‍🦰🧑🏻‍🍼✋✋🏻✋🏿0" + Stdlib.String.padEnd_v0 "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇" "0" 10I = Stdlib.Result.Result.Ok "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇00000" + Stdlib.String.padEnd_v0 "﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽" "0" 20I = Stdlib.Result.Result.Ok "﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽﷽0000" + Stdlib.String.padEnd_v0 "👱👱🏻👱🏼👱🏽👱🏾👱🏿" "0" 10I = Stdlib.Result.Result.Ok "👱👱🏻👱🏼👱🏽👱🏾👱🏿0000" + Stdlib.String.padEnd_v0 "🧟‍♀️🧟‍♂️" "0" 5I = Stdlib.Result.Result.Ok "🧟‍♀️🧟‍♂️000" + Stdlib.String.padEnd_v0 "👨‍❤️‍💋‍👨👩‍👩‍👧‍👦🏳️‍⚧️🇵🇷" "0" 10I = Stdlib.Result.Result.Ok "👨‍❤️‍💋‍👨👩‍👩‍👧‍👦🏳️‍⚧️🇵🇷000000" + Stdlib.String.padEnd_v0 "鷝" "觌഻" 0I = Stdlib.Result.Result.Ok "鷝" + + Stdlib.String.padEnd_v0 "123" "_-" 3I = Stdlib.Result.Result.Error "Expected `padWith` to be 1 character long, but it was `\"_-\"`" + Stdlib.String.padEnd_v0 "123" "" 10I = Stdlib.Result.Result.Error "Expected `padWith` to be 1 character long, but it was `\"\"`" module IndexOf = - Stdlib.String.indexOf_v0 "hello world" "world" = Stdlib.Option.Option.Some 6L + Stdlib.String.indexOf_v0 "hello world" "world" = Stdlib.Option.Option.Some 6I Stdlib.String.indexOf_v0 "hello world" "earth" = Stdlib.Option.Option.None - Stdlib.String.indexOf_v0 "" "" = Stdlib.Option.Option.Some 0L - Stdlib.String.indexOf_v0 "hello" "" = Stdlib.Option.Option.Some 0L + Stdlib.String.indexOf_v0 "" "" = Stdlib.Option.Option.Some 0I + Stdlib.String.indexOf_v0 "hello" "" = Stdlib.Option.Option.Some 0I Stdlib.String.indexOf_v0 "" "hello" = Stdlib.Option.Option.None - Stdlib.String.indexOf_v0 "👱👱🏻👱🏼👱🏽👱🏾👱🏿" "👱🏼👱🏽" = Stdlib.Option.Option.Some 6L + Stdlib.String.indexOf_v0 "👱👱🏻👱🏼👱🏽👱🏾👱🏿" "👱🏼👱🏽" = Stdlib.Option.Option.Some 6I Stdlib.String.indexOf_v0 "👱👱🏻👱🏼👱🏽👱🏾👱🏿" "👱🏼👱🏿" = Stdlib.Option.Option.None - Stdlib.String.indexOf_v0 "👨‍❤️‍💋‍👨👩‍👩‍👧‍👦🏳️‍⚧️‍️🇵🇷" "👩‍👩‍👧‍👦" = Stdlib.Option.Option.Some 11L - Stdlib.String.indexOf_v0 "żółw🧑🏽‍🦰🧑🏻‍🍼✋✋🏻✋🏿" "🧑🏽‍🦰" = Stdlib.Option.Option.Some 4L + Stdlib.String.indexOf_v0 "👨‍❤️‍💋‍👨👩‍👩‍👧‍👦🏳️‍⚧️‍️🇵🇷" "👩‍👩‍👧‍👦" = Stdlib.Option.Option.Some 11I + Stdlib.String.indexOf_v0 "żółw🧑🏽‍🦰🧑🏻‍🍼✋✋🏻✋🏿" "🧑🏽‍🦰" = Stdlib.Option.Option.Some 4I Stdlib.String.indexOf_v0 "żółw🧑🏽‍🦰🧑🏻‍🍼✋✋🏻✋🏿" "👱🏽" = Stdlib.Option.Option.None Stdlib.String.indexOf_v0 "👨‍❤️‍💋‍👨👩‍👩‍👧‍👦🏳️‍⚧️‍️🇵🇷" "🧑🏻‍🍼" = Stdlib.Option.Option.None @@ -859,59 +859,59 @@ module IndexOf = module IndexOfEgc = // Mirror of the IndexOf module above, but in EGC units. Pair with first / // dropFirst / slice / length for correct emoji-safe slicing. - Stdlib.String.indexOfEgc "hello world" "world" = Stdlib.Option.Option.Some 6L + Stdlib.String.indexOfEgc "hello world" "world" = Stdlib.Option.Option.Some 6I Stdlib.String.indexOfEgc "hello world" "earth" = Stdlib.Option.Option.None - Stdlib.String.indexOfEgc "" "" = Stdlib.Option.Option.Some 0L - Stdlib.String.indexOfEgc "hello" "" = Stdlib.Option.Option.Some 0L + Stdlib.String.indexOfEgc "" "" = Stdlib.Option.Option.Some 0I + Stdlib.String.indexOfEgc "hello" "" = Stdlib.Option.Option.Some 0I Stdlib.String.indexOfEgc "" "hello" = Stdlib.Option.Option.None // "👱👱🏻" is 2 EGCs, "👨‍❤️‍💋‍👨" is 1 EGC, "żółw" is 4 EGCs. - Stdlib.String.indexOfEgc "👱👱🏻👱🏼👱🏽👱🏾👱🏿" "👱🏼👱🏽" = Stdlib.Option.Option.Some 2L + Stdlib.String.indexOfEgc "👱👱🏻👱🏼👱🏽👱🏾👱🏿" "👱🏼👱🏽" = Stdlib.Option.Option.Some 2I Stdlib.String.indexOfEgc "👱👱🏻👱🏼👱🏽👱🏾👱🏿" "👱🏼👱🏿" = Stdlib.Option.Option.None - Stdlib.String.indexOfEgc "👨‍❤️‍💋‍👨👩‍👩‍👧‍👦🏳️‍⚧️‍️🇵🇷" "👩‍👩‍👧‍👦" = Stdlib.Option.Option.Some 1L - Stdlib.String.indexOfEgc "żółw🧑🏽‍🦰🧑🏻‍🍼✋✋🏻✋🏿" "🧑🏽‍🦰" = Stdlib.Option.Option.Some 4L + Stdlib.String.indexOfEgc "👨‍❤️‍💋‍👨👩‍👩‍👧‍👦🏳️‍⚧️‍️🇵🇷" "👩‍👩‍👧‍👦" = Stdlib.Option.Option.Some 1I + Stdlib.String.indexOfEgc "żółw🧑🏽‍🦰🧑🏻‍🍼✋✋🏻✋🏿" "🧑🏽‍🦰" = Stdlib.Option.Option.Some 4I // Matches must align to EGC boundaries on both sides. Searching for a partial // grapheme inside a full one returns None: 🧑 is not a complete EGC of 🧑🏼‍💻. Stdlib.String.indexOfEgc "🧑🏼‍💻" "🧑" = Stdlib.Option.Option.None // Standalone 🧑 at EGC index 0 is matchable when it stands on its own. - Stdlib.String.indexOfEgc "🧑🧑🏼‍💻" "🧑" = Stdlib.Option.Option.Some 0L + Stdlib.String.indexOfEgc "🧑🧑🏼‍💻" "🧑" = Stdlib.Option.Option.Some 0I module LastIndexOfEgc = // Basic ASCII: last occurrence wins. - Stdlib.String.lastIndexOfEgc "hello world hello" "hello" = Stdlib.Option.Option.Some 12L + Stdlib.String.lastIndexOfEgc "hello world hello" "hello" = Stdlib.Option.Option.Some 12I Stdlib.String.lastIndexOfEgc "hello world" "earth" = Stdlib.Option.Option.None Stdlib.String.lastIndexOfEgc "" "hello" = Stdlib.Option.Option.None // Empty-string searches return string length in EGCs. - Stdlib.String.lastIndexOfEgc "" "" = Stdlib.Option.Option.Some 0L - Stdlib.String.lastIndexOfEgc "hello" "" = Stdlib.Option.Option.Some 5L + Stdlib.String.lastIndexOfEgc "" "" = Stdlib.Option.Option.Some 0I + Stdlib.String.lastIndexOfEgc "hello" "" = Stdlib.Option.Option.Some 5I // "👱👱🏻" is 2 EGCs even though it's 4 UTF-16 code units. - Stdlib.String.lastIndexOfEgc "👱👱🏻" "" = Stdlib.Option.Option.Some 2L + Stdlib.String.lastIndexOfEgc "👱👱🏻" "" = Stdlib.Option.Option.Some 2I // EGC offsets across multi-codepoint graphemes. - Stdlib.String.lastIndexOfEgc "👱👱🏻👱🏼👱🏽👱🏾👱🏿" "👱🏼" = Stdlib.Option.Option.Some 2L - Stdlib.String.lastIndexOfEgc "a🧑🏼‍💻b🧑🏼‍💻c" "🧑🏼‍💻" = Stdlib.Option.Option.Some 3L - Stdlib.String.lastIndexOfEgc "żółw🧑🏽‍🦰🧑🏻‍🍼" "🧑🏻‍🍼" = Stdlib.Option.Option.Some 5L + Stdlib.String.lastIndexOfEgc "👱👱🏻👱🏼👱🏽👱🏾👱🏿" "👱🏼" = Stdlib.Option.Option.Some 2I + Stdlib.String.lastIndexOfEgc "a🧑🏼‍💻b🧑🏼‍💻c" "🧑🏼‍💻" = Stdlib.Option.Option.Some 3I + Stdlib.String.lastIndexOfEgc "żółw🧑🏽‍🦰🧑🏻‍🍼" "🧑🏻‍🍼" = Stdlib.Option.Option.Some 5I // Partial-grapheme search returns None on both sides (start and end must // align to EGC boundaries). Stdlib.String.lastIndexOfEgc "🧑🏼‍💻🧑🏼‍💻" "🧑" = Stdlib.Option.Option.None // Standalone 🧑 at the end is matchable when it stands on its own. - Stdlib.String.lastIndexOfEgc "🧑🏼‍💻🧑" "🧑" = Stdlib.Option.Option.Some 1L + Stdlib.String.lastIndexOfEgc "🧑🏼‍💻🧑" "🧑" = Stdlib.Option.Option.Some 1I module Ellipsis = - Stdlib.String.ellipsis_v0 "hello world" 5L = "hello..." - Stdlib.String.ellipsis_v0 "hello world" 9L = "hello wor..." - Stdlib.String.ellipsis_v0 "hello world" 11L = "hello world" - Stdlib.String.ellipsis_v0 "hello world" 12L = "hello world" - Stdlib.String.ellipsis_v0 "👱👱🏻👱🏼👱🏽👱🏾👱🏿" 5L = "👱👱🏻👱🏼👱🏽👱🏾..." - Stdlib.String.ellipsis_v0 "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇" 3L = "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫ..." - Stdlib.String.ellipsis_v0 "👩‍👩‍👧‍👦" 2L = "👩‍👩‍👧‍👦" - - Stdlib.String.ellipsis_v0 "👨‍❤️‍💋‍👨👩‍👩‍👧‍👦🏳️‍⚧️‍️🇵🇷✋✋🏻✋🏿" 4L = "👨‍❤️‍💋‍👨👩‍👩‍👧‍👦🏳️‍⚧️‍️🇵🇷..." + Stdlib.String.ellipsis_v0 "hello world" 5I = "hello..." + Stdlib.String.ellipsis_v0 "hello world" 9I = "hello wor..." + Stdlib.String.ellipsis_v0 "hello world" 11I = "hello world" + Stdlib.String.ellipsis_v0 "hello world" 12I = "hello world" + Stdlib.String.ellipsis_v0 "👱👱🏻👱🏼👱🏽👱🏾👱🏿" 5I = "👱👱🏻👱🏼👱🏽👱🏾..." + Stdlib.String.ellipsis_v0 "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫǧ̗͚̚o̙̔ͮ̇͐̇" 3I = "Z̤͔ͧ̑̓ä͖̭̈̇lͮ̒ͫ..." + Stdlib.String.ellipsis_v0 "👩‍👩‍👧‍👦" 2I = "👩‍👩‍👧‍👦" + + Stdlib.String.ellipsis_v0 "👨‍❤️‍💋‍👨👩‍👩‍👧‍👦🏳️‍⚧️‍️🇵🇷✋✋🏻✋🏿" 4I = "👨‍❤️‍💋‍👨👩‍👩‍👧‍👦🏳️‍⚧️‍️🇵🇷..." module Head = Stdlib.String.head "hello world" = Stdlib.Option.Option.Some 'h' diff --git a/packages/darklang/cli/ai/agent.dark b/packages/darklang/cli/ai/agent.dark index 05a0eb9695..acd289e577 100644 --- a/packages/darklang/cli/ai/agent.dark +++ b/packages/darklang/cli/ai/agent.dark @@ -100,7 +100,8 @@ let systemPrompt : String = ## Critical Syntax - Whitespace-sensitive (like Python) -- No nested function definitions +- Nested function definitions need typed params and a return type: + `let helper (x: Int64) : Int64 = ...`; no mutual recursion - Lists use semicolons: [1L; 2L; 3L] - String concat: ++ (not +) - Pipe needs parens for complex LHS: (expr) |> fn @@ -201,7 +202,7 @@ let runCliCommand if Stdlib.String.startsWith (Stdlib.String.trim output) "Error:" then Stdlib.Result.Result.Error (Stdlib.String.trim output) else - let preview = if (Stdlib.String.length output) > 100L then (Stdlib.String.slice output 0L 100L) ++ "..." else output + let preview = if (Stdlib.String.length output) > 100I then (Stdlib.String.slice output 0I 100I) ++ "..." else output Stdlib.printLine (Colors.dimText (" -> " ++ preview)) Stdlib.Result.Result.Ok (Darklang.LLM.Agent.ToolOutput.text output) | exitCode -> @@ -406,7 +407,7 @@ let help (state: Cli.AppState) : Cli.AppState = let lines = Stdlib.List.map subcommands (fun s -> let padded = - match Stdlib.String.padEnd s.usage " " 40L with + match Stdlib.String.padEnd s.usage " " 40I with | Ok p -> p | Error _ -> s.usage $" {padded} - {s.description}") diff --git a/packages/darklang/cli/apps/command.dark b/packages/darklang/cli/apps/command.dark index 1ce383b597..ac79075a0b 100644 --- a/packages/darklang/cli/apps/command.dark +++ b/packages/darklang/cli/apps/command.dark @@ -264,7 +264,7 @@ let complete // A single help line: " cmd description", padded for a clean column. let helpLine (usage: String) (desc: String) : String = - let pad = Stdlib.Result.withDefault (Stdlib.String.padEnd usage " " 26L) usage + let pad = Stdlib.Result.withDefault (Stdlib.String.padEnd usage " " 26I) usage " " ++ pad ++ Colors.dimText desc let help (state: Cli.AppState) : Cli.AppState = diff --git a/packages/darklang/cli/apps/editor.dark b/packages/darklang/cli/apps/editor.dark index 8727ca7385..467e99b043 100644 --- a/packages/darklang/cli/apps/editor.dark +++ b/packages/darklang/cli/apps/editor.dark @@ -28,10 +28,10 @@ let selectedApp (state: State) : Stdlib.Option.Option = // `s` cut to `maxLen` display columns, with a trailing ellipsis when it doesn't fit. let private truncate (s: String) (maxLen: Int64) : String = - if Stdlib.String.length s <= maxLen then + if (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length s))) <= maxLen then s else - (Stdlib.String.slice s 0L (maxLen - 1L)) ++ "…" + (Stdlib.String.slice s 0I (Stdlib.Int.fromInt64 (maxLen - 1L))) ++ "…" let private appRow (state: State) (idx: Int64) (app: Model.App) : String = @@ -64,9 +64,9 @@ let private appRow (state: State) (idx: Int64) (app: Model.App) : String = else if isRunning then Colors.colorize Colors.green rawState else if isStale then Colors.colorize Colors.yellow rawState else Colors.dimText rawState - let stateWidth = if rawState == "" then 0L else (Stdlib.String.length rawState) + 3L + let stateWidth = if rawState == "" then 0L else (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length rawState))) + 3L - let name = Stdlib.Result.withDefault (Stdlib.String.padEnd app.name " " 26L) app.name + let name = Stdlib.Result.withDefault (Stdlib.String.padEnd app.name " " 26I) app.name let w = Darklang.Cli.Terminal.getWidth () let width = if w <= 0L then 80L else w // prefix (▸ + install glyph + run glyph + space) = 5 cols, name column = 26, gap before description = 2 diff --git a/packages/darklang/cli/apps/views/ai-chats.dark b/packages/darklang/cli/apps/views/ai-chats.dark index 0729f2e1bc..24607a7d0a 100644 --- a/packages/darklang/cli/apps/views/ai-chats.dark +++ b/packages/darklang/cli/apps/views/ai-chats.dark @@ -87,9 +87,9 @@ let thinHr () : String = Darklang.Cli.Colors.dimText (Stdlib.String.repeat "╌" (Stdlib.Int.fromInt64 cols)) let padRight (s: String) (width: Int64) : String = - let len = Stdlib.String.length s + let len = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length s)) if len >= width then - Stdlib.String.slice s 0L width + Stdlib.String.slice s 0I (Stdlib.Int.fromInt64 width) else s ++ (Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (width - len))) diff --git a/packages/darklang/cli/apps/views/package-stats.dark b/packages/darklang/cli/apps/views/package-stats.dark index 948a1b0ce3..cd4586eb7e 100644 --- a/packages/darklang/cli/apps/views/package-stats.dark +++ b/packages/darklang/cli/apps/views/package-stats.dark @@ -19,16 +19,16 @@ let demoStats () : List = let padRight (s: String) (width: Int64) : String = - let len = Stdlib.String.length s + let len = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length s)) if len >= width then - Stdlib.String.slice s 0L width + Stdlib.String.slice s 0I (Stdlib.Int.fromInt64 width) else s ++ (Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (width - len))) let padLeft (s: String) (width: Int64) : String = - let len = Stdlib.String.length s + let len = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length s)) if len >= width then - Stdlib.String.slice s 0L width + Stdlib.String.slice s 0I (Stdlib.Int.fromInt64 width) else (Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (width - len))) ++ s diff --git a/packages/darklang/cli/caps/command.dark b/packages/darklang/cli/caps/command.dark index 8b14e76544..de9e864de7 100644 --- a/packages/darklang/cli/caps/command.dark +++ b/packages/darklang/cli/caps/command.dark @@ -222,7 +222,7 @@ let execute (state: Cli.AppState) (args: List) : Cli.AppState = "Capability profiles — `caps profile ` REPLACES the grant with that posture:" Stdlib.List.iter Command.profiles (fun (name, specs) -> let label = - match Stdlib.String.padEnd name " " 12L with + match Stdlib.String.padEnd name " " 12I with | Ok r -> r | Error _ -> name Stdlib.printLine $" {label}{Colors.dimText (PrettyPrinter.Capabilities.compact specs)}") diff --git a/packages/darklang/cli/caps/lineInput.dark b/packages/darklang/cli/caps/lineInput.dark index 39a75015bd..b44c938f74 100644 --- a/packages/darklang/cli/caps/lineInput.dark +++ b/packages/darklang/cli/caps/lineInput.dark @@ -6,28 +6,28 @@ module Darklang.Cli.Caps.LineInput type State = { text: String; cursor: Int64 } let make (text: String) : State = - State { text = text; cursor = Stdlib.String.length text } + State { text = text; cursor = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length text)) } let empty : State = State { text = ""; cursor = 0L } let insert (state: State) (ch: String) : State = - let before = Stdlib.String.slice state.text 0L state.cursor - let after = Stdlib.String.dropFirst state.text state.cursor - State { text = before ++ ch ++ after; cursor = state.cursor + Stdlib.String.length ch } + let before = Stdlib.String.slice state.text 0I (Stdlib.Int.fromInt64 state.cursor) + let after = Stdlib.String.dropFirst state.text (Stdlib.Int.fromInt64 state.cursor) + State { text = before ++ ch ++ after; cursor = state.cursor + (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length ch))) } let backspace (state: State) : State = if state.cursor == 0L then state else - let before = Stdlib.String.slice state.text 0L (state.cursor - 1L) - let after = Stdlib.String.dropFirst state.text state.cursor + let before = Stdlib.String.slice state.text 0I (Stdlib.Int.fromInt64 (state.cursor - 1L)) + let after = Stdlib.String.dropFirst state.text (Stdlib.Int.fromInt64 state.cursor) State { text = before ++ after; cursor = state.cursor - 1L } let left (state: State) : State = if state.cursor > 0L then { state with cursor = state.cursor - 1L } else state let right (state: State) : State = - if state.cursor < Stdlib.String.length state.text then + if state.cursor < (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length state.text))) then { state with cursor = state.cursor + 1L } else state @@ -51,16 +51,16 @@ let handleKey /// Render the field. When focused, shows a reverse-video cursor; unfocused + empty shows `placeholder`. let render (state: State) (focused: Bool) (placeholder: String) : String = if focused then - let before = Stdlib.String.slice state.text 0L state.cursor + let before = Stdlib.String.slice state.text 0I (Stdlib.Int.fromInt64 state.cursor) let cursorChar = - if state.cursor < Stdlib.String.length state.text then - Stdlib.String.slice state.text state.cursor (state.cursor + 1L) + if state.cursor < (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length state.text))) then + Stdlib.String.slice state.text (Stdlib.Int.fromInt64 state.cursor) (Stdlib.Int.fromInt64 (state.cursor + 1L)) else " " let cursorDisplay = Darklang.Cli.Colors.colorize Darklang.Cli.Colors.reverse cursorChar let after = - if state.cursor < Stdlib.String.length state.text then - Stdlib.String.dropFirst state.text (state.cursor + 1L) + if state.cursor < (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length state.text))) then + Stdlib.String.dropFirst state.text (Stdlib.Int.fromInt64 (state.cursor + 1L)) else "" before ++ cursorDisplay ++ after diff --git a/packages/darklang/cli/core.dark b/packages/darklang/cli/core.dark index b5307da11f..1ab51fb7be 100644 --- a/packages/darklang/cli/core.dark +++ b/packages/darklang/cli/core.dark @@ -184,7 +184,7 @@ module StatusBar = let branchPart = Colors.colorize (Colors.grayBg ++ Colors.white) branchText - let leftLen = Stdlib.String.length leftText + Stdlib.String.length branchText + let leftLen = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length leftText + Stdlib.String.length branchText)) let paddingLen = terminalWidth - leftLen let padding = @@ -726,7 +726,7 @@ let runInteractiveLoop (state: AppState) : Int64 = else Registry.getCompletionHint state state.prompt.text if state.telemetryEnabled then - Telemetry.logWithContext "completionHint" tHint [("inputLen", Stdlib.Int64.toString (Stdlib.String.length state.prompt.text)); ("cached", Stdlib.Bool.toString hintCached)] + Telemetry.logWithContext "completionHint" tHint [("inputLen", Stdlib.Int.toString (Stdlib.String.length state.prompt.text)); ("cached", Stdlib.Bool.toString hintCached)] let promptOutput = Prompt.Display.formatPromptWithInput location state.prompt.text hint @@ -736,7 +736,7 @@ let runInteractiveLoop (state: AppState) : Int64 = if w <= 0L then 80L else w // Visual length (0-based char count; inputStartColumn is 1-based so subtract 1) let visualLength = - (inputStartColumn - 1L) + (Stdlib.String.length state.prompt.text) + (Stdlib.String.length hint) + (inputStartColumn - 1L) + (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length state.prompt.text))) + (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length hint))) let renderedRows = if visualLength <= terminalWidth then 1L else (Stdlib.Int64.divide (visualLength - 1L) terminalWidth) + 1L diff --git a/packages/darklang/cli/installation/download.dark b/packages/darklang/cli/installation/download.dark index f2196a82ba..84e8fd4365 100644 --- a/packages/darklang/cli/installation/download.dark +++ b/packages/darklang/cli/installation/download.dark @@ -43,7 +43,7 @@ let installOrUpdateLatestRelease let extractedExecutablePath = if Stdlib.String.endsWith assetName ".gz" then - $"{executableDir}{assetName |> Stdlib.String.dropLast 3L}" + $"{executableDir}{assetName |> Stdlib.String.dropLast 3I}" else // TODO: error here better Stdlib.Result.Result.Error "Asset is not a .gz file" @@ -82,7 +82,7 @@ let installOrUpdateLatestRelease // unzip the .gz file let extractedExecutablePath = if Stdlib.String.endsWith assetName ".gz" then - $"{executableDir}{assetName |> Stdlib.String.dropLast 3L}" + $"{executableDir}{assetName |> Stdlib.String.dropLast 3I}" else // TODO: error here better Stdlib.Result.Result.Error "Asset is not a .gz file" diff --git a/packages/darklang/cli/outliner/main.dark b/packages/darklang/cli/outliner/main.dark index 694df9f1b4..0ced905f03 100644 --- a/packages/darklang/cli/outliner/main.dark +++ b/packages/darklang/cli/outliner/main.dark @@ -213,7 +213,7 @@ let renderTitleBar (titleText: String) (modeText: String) (modeColor: String) (r Darklang.Cli.UI.Layout.printAt region 0L 0L (title ++ " " ++ modeIndicator) let renderHelpBar (helpText: String) (region: Darklang.Cli.UI.Layout.Region) : Unit = - let helpLen = Stdlib.String.length helpText + let helpLen = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length helpText)) let helpPadding = if region.cols > helpLen then Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (region.cols - helpLen)) else "" diff --git a/packages/darklang/cli/outliner/markdown.dark b/packages/darklang/cli/outliner/markdown.dark index 22529f7771..0bc944a534 100644 --- a/packages/darklang/cli/outliner/markdown.dark +++ b/packages/darklang/cli/outliner/markdown.dark @@ -22,7 +22,7 @@ let import (markdown: String) : Document = match Stdlib.List.head lines with | Some first -> if Stdlib.String.startsWith first "# " then - Stdlib.String.dropFirst first 2L + Stdlib.String.dropFirst first 2I else "Imported" | None -> "Imported" @@ -45,12 +45,12 @@ let import (markdown: String) : Document = let trimmed = Stdlib.String.trim line let text = if Stdlib.String.startsWith trimmed "- " then - Stdlib.String.dropFirst trimmed 2L + Stdlib.String.dropFirst trimmed 2I else trimmed let indentChars = (Stdlib.String.length line) - (Stdlib.String.length (Stdlib.String.trimStart line)) - let depth = Stdlib.Int64.divide indentChars 2L + let depth = Stdlib.Int.divide indentChars 2I let id = outline.nextId let o1 = addNode outline id text let newStack = diff --git a/packages/darklang/cli/outliner/outline-editor.dark b/packages/darklang/cli/outliner/outline-editor.dark index 47c805f68e..3f0433a0dc 100644 --- a/packages/darklang/cli/outliner/outline-editor.dark +++ b/packages/darklang/cli/outliner/outline-editor.dark @@ -325,7 +325,7 @@ let renderTitleBar (title: String) (isEditing: Bool) (region: Darklang.Cli.UI.La Darklang.Cli.UI.Layout.printAt region 0L 0L (titleText ++ " " ++ modeIndicator) let renderHelpBar (helpText: String) (region: Darklang.Cli.UI.Layout.Region) : Unit = - let helpLen = Stdlib.String.length helpText + let helpLen = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length helpText)) let helpPadding = if region.cols > helpLen then Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (region.cols - helpLen)) else "" diff --git a/packages/darklang/cli/outliner/text-editor.dark b/packages/darklang/cli/outliner/text-editor.dark index 36fe1b52c9..c5884c4b6a 100644 --- a/packages/darklang/cli/outliner/text-editor.dark +++ b/packages/darklang/cli/outliner/text-editor.dark @@ -13,7 +13,7 @@ let empty : State = State { text = ""; cursor = 0L } let fromText (text: String) : State = - State { text = text; cursor = Stdlib.String.length text } + State { text = text; cursor = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length text)) } let handleKey (state: State) @@ -28,8 +28,8 @@ let handleKey if state.cursor == 0L then Result.Editing state else - let before = Stdlib.String.slice state.text 0L (state.cursor - 1L) - let after = Stdlib.String.dropFirst state.text state.cursor + let before = Stdlib.String.slice state.text 0I (Stdlib.Int.fromInt64 (state.cursor - 1L)) + let after = Stdlib.String.dropFirst state.text (Stdlib.Int.fromInt64 state.cursor) Result.Editing (State { text = before ++ after; cursor = state.cursor - 1L }) | LeftArrow -> if state.cursor > 0L then @@ -37,7 +37,7 @@ let handleKey else Result.Editing state | RightArrow -> - let textLen = Stdlib.String.length state.text + let textLen = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length state.text)) if state.cursor < textLen then Result.Editing ({ state with cursor = state.cursor + 1L }) else @@ -45,23 +45,23 @@ let handleKey | _ -> match keyChar with | Some ch -> - let before = Stdlib.String.slice state.text 0L state.cursor - let after = Stdlib.String.dropFirst state.text state.cursor + let before = Stdlib.String.slice state.text 0I (Stdlib.Int.fromInt64 state.cursor) + let after = Stdlib.String.dropFirst state.text (Stdlib.Int.fromInt64 state.cursor) Result.Editing (State { text = before ++ ch ++ after; cursor = state.cursor + 1L }) | None -> Result.Editing state /// Render text with a visible cursor. Returns a styled string, does not print. let renderInline (state: State) : String = - let before = Stdlib.String.slice state.text 0L state.cursor + let before = Stdlib.String.slice state.text 0I (Stdlib.Int.fromInt64 state.cursor) let cursorChar = - if state.cursor < (Stdlib.String.length state.text) then - Stdlib.String.slice state.text state.cursor (state.cursor + 1L) + if state.cursor < (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length state.text))) then + Stdlib.String.slice state.text (Stdlib.Int.fromInt64 state.cursor) (Stdlib.Int.fromInt64 (state.cursor + 1L)) else " " let cursorDisplay = Darklang.Cli.Colors.colorize Darklang.Cli.Colors.reverse cursorChar let afterCursor = - if state.cursor < (Stdlib.String.length state.text) then - Stdlib.String.dropFirst state.text (state.cursor + 1L) + if state.cursor < (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length state.text))) then + Stdlib.String.dropFirst state.text (Stdlib.Int.fromInt64 (state.cursor + 1L)) else "" before ++ cursorDisplay ++ afterCursor diff --git a/packages/darklang/cli/packages/db.dark b/packages/darklang/cli/packages/db.dark index 969b42f311..19466b319d 100644 --- a/packages/darklang/cli/packages/db.dark +++ b/packages/darklang/cli/packages/db.dark @@ -93,7 +93,7 @@ let listDBs (state: Cli.AppState) : Cli.AppState = // Print table header let nameHeader = - (Stdlib.String.padEnd "Name" " " 20L) |> Builtin.unwrap + (Stdlib.String.padEnd "Name" " " 20I) |> Builtin.unwrap let typeHeader = "Type" @@ -106,7 +106,7 @@ let listDBs (state: Cli.AppState) : Cli.AppState = let (name, typeName) = db let nameCol = - (Stdlib.String.padEnd name " " 20L) |> Builtin.unwrap + (Stdlib.String.padEnd name " " 20I) |> Builtin.unwrap Stdlib.printLine $"{nameCol}{typeName}") @@ -155,12 +155,12 @@ let viewDB (state: Cli.AppState) (dbName: String) : Cli.AppState = // Print header let keyHeader = - (Stdlib.String.padEnd "Key" " " colWidth) |> Builtin.unwrap + (Stdlib.String.padEnd "Key" " " (Stdlib.Int.fromInt64 colWidth)) |> Builtin.unwrap let fieldHeaders = fieldNames |> Stdlib.List.map (fun name -> - (Stdlib.String.padEnd name " " colWidth) |> Builtin.unwrap) + (Stdlib.String.padEnd name " " (Stdlib.Int.fromInt64 colWidth)) |> Builtin.unwrap) |> Stdlib.String.join "" Stdlib.printLine $"{keyHeader}{fieldHeaders}" @@ -185,7 +185,7 @@ let viewDB (state: Cli.AppState) (dbName: String) : Cli.AppState = let formatted = parts |> Stdlib.List.map (fun part -> - (Stdlib.String.padEnd part " " colWidth) |> Builtin.unwrap) + (Stdlib.String.padEnd part " " (Stdlib.Int.fromInt64 colWidth)) |> Builtin.unwrap) |> Stdlib.String.join "" Stdlib.printLine formatted) diff --git a/packages/darklang/cli/packages/location.dark b/packages/darklang/cli/packages/location.dark index 02e6220b81..f91375fc0f 100644 --- a/packages/darklang/cli/packages/location.dark +++ b/packages/darklang/cli/packages/location.dark @@ -16,7 +16,7 @@ let parseRelativeTo let parts = if isAbsolute then // Remove leading slash and split - let withoutSlash = Stdlib.String.dropFirst location 1L + let withoutSlash = Stdlib.String.dropFirst location 1I Stdlib.String.split withoutSlash "." else // Relative path - combine current path with relative path diff --git a/packages/darklang/cli/packages/navInteractive.dark b/packages/darklang/cli/packages/navInteractive.dark index fe4eb8b8f7..51760f31c5 100644 --- a/packages/darklang/cli/packages/navInteractive.dark +++ b/packages/darklang/cli/packages/navInteractive.dark @@ -410,8 +410,8 @@ let handleSearchKeys | Backspace -> let newQuery = - if Stdlib.String.length navState.searchQuery > 0L then - Stdlib.String.dropLast navState.searchQuery 1L + if Stdlib.String.length navState.searchQuery > 0I then + Stdlib.String.dropLast navState.searchQuery 1I else "" let newNavState = { navState with searchQuery = newQuery } diff --git a/packages/darklang/cli/packages/tree.dark b/packages/darklang/cli/packages/tree.dark index 3689b37994..5de71d5ec9 100644 --- a/packages/darklang/cli/packages/tree.dark +++ b/packages/darklang/cli/packages/tree.dark @@ -128,7 +128,7 @@ let execute (state: AppState) (args: List): AppState = let maxDepth = match Stdlib.List.findFirst args (fun arg -> Stdlib.String.startsWith arg "--depth=") with | Some depthArg -> - let depthStr = Stdlib.String.dropFirst depthArg 8L // Remove "--depth=" + let depthStr = Stdlib.String.dropFirst depthArg 8I // Remove "--depth=" match Stdlib.Int64.parse depthStr with | Ok depth -> if depth > 0L && depth <= 10L then depth else 2L // Limit to reasonable range diff --git a/packages/darklang/cli/packages/view.dark b/packages/darklang/cli/packages/view.dark index d7724d8f73..507fb33b2d 100644 --- a/packages/darklang/cli/packages/view.dark +++ b/packages/darklang/cli/packages/view.dark @@ -61,7 +61,7 @@ let viewEntity (branchId: Uuid) (location: PackageLocation) : Unit = let locationStr = Packages.formatLocation location Stdlib.printLine locationStr - Stdlib.printLine (Stdlib.String.repeat "=" (Stdlib.Int.fromInt64 (Stdlib.String.length locationStr))) + Stdlib.printLine (Stdlib.String.repeat "=" (Stdlib.String.length locationStr)) Stdlib.printLine "" // Display submodules diff --git a/packages/darklang/cli/prompt.dark b/packages/darklang/cli/prompt.dark index c948e9bb04..5fb0e396be 100644 --- a/packages/darklang/cli/prompt.dark +++ b/packages/darklang/cli/prompt.dark @@ -20,20 +20,20 @@ let initState () : State = module Editing = /// Insert text at cursor position let insertAtCursor (state: State) (char: String) : State = - let beforeCursor = Stdlib.String.slice state.text 0L state.cursorPosition - let afterCursor = Stdlib.String.dropFirst state.text state.cursorPosition + let beforeCursor = Stdlib.String.slice state.text 0I (Stdlib.Int.fromInt64 state.cursorPosition) + let afterCursor = Stdlib.String.dropFirst state.text (Stdlib.Int.fromInt64 state.cursorPosition) let newText = beforeCursor ++ char ++ afterCursor { state with text = newText - cursorPosition = state.cursorPosition + (Stdlib.String.length char) + cursorPosition = state.cursorPosition + (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length char))) historyIndex = -1L savedPrompt = "" } /// Delete character before cursor (backspace) let deleteBeforeCursor (state: State) : State = if state.cursorPosition > 0L then - let beforeCursor = Stdlib.String.slice state.text 0L (state.cursorPosition - 1L) - let afterCursor = Stdlib.String.dropFirst state.text state.cursorPosition + let beforeCursor = Stdlib.String.slice state.text 0I (Stdlib.Int.fromInt64 (state.cursorPosition - 1L)) + let afterCursor = Stdlib.String.dropFirst state.text (Stdlib.Int.fromInt64 state.cursorPosition) let newText = beforeCursor ++ afterCursor { state with text = newText @@ -44,11 +44,11 @@ module Editing = /// Delete character at cursor (delete key) let deleteAtCursor (state: State) : State = - let textLength = Stdlib.String.length state.text + let textLength = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length state.text)) if state.cursorPosition < textLength then - let beforeCursor = Stdlib.String.slice state.text 0L state.cursorPosition - let afterCursor = Stdlib.String.dropFirst state.text (state.cursorPosition + 1L) + let beforeCursor = Stdlib.String.slice state.text 0I (Stdlib.Int.fromInt64 state.cursorPosition) + let afterCursor = Stdlib.String.dropFirst state.text (Stdlib.Int.fromInt64 (state.cursorPosition + 1L)) let newText = beforeCursor ++ afterCursor { state with text = newText; historyIndex = -1L } else @@ -61,7 +61,7 @@ module Editing = /// Move cursor right let moveCursorRight (state: State) : State = - let textLength = Stdlib.String.length state.text + let textLength = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length state.text)) let newCursorPos = Stdlib.Int64.min textLength (state.cursorPosition + 1L) { state with cursorPosition = newCursorPos } @@ -71,7 +71,7 @@ module Editing = /// Move cursor to end of line let moveCursorEnd (state: State) : State = - let textLength = Stdlib.String.length state.text + let textLength = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length state.text)) { state with cursorPosition = textLength } /// Clear the prompt text @@ -83,7 +83,7 @@ module Editing = /// Set the prompt text and move cursor to end let setText (state: State) (text: String) : State = - let textLength = Stdlib.String.length text + let textLength = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length text)) { state with text = text; cursorPosition = textLength } @@ -113,7 +113,7 @@ module History = state.historyIndex // Stay at oldest command match Stdlib.List.getAt state.commandHistory (Stdlib.Int.fromInt64 newIndex) with | Some command -> - let commandLength = Stdlib.String.length command + let commandLength = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length command)) let newSavedPrompt = if state.historyIndex == -1L then state.text @@ -138,7 +138,7 @@ module History = else -1L // Go back to empty prompt if newIndex == -1L then - let restoredPromptLength = Stdlib.String.length state.savedPrompt + let restoredPromptLength = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length state.savedPrompt)) { state with text = state.savedPrompt cursorPosition = restoredPromptLength @@ -146,7 +146,7 @@ module History = else match Stdlib.List.getAt state.commandHistory (Stdlib.Int.fromInt64 newIndex) with | Some command -> - let commandLength = Stdlib.String.length command + let commandLength = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length command)) { state with text = command cursorPosition = commandLength @@ -181,8 +181,8 @@ module Display = if Stdlib.String.isEmpty locationStr then 0L else - (Stdlib.String.length locationStr) + 1L // +1 for the space after path + (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length locationStr))) + 1L // +1 for the space after path locationLength - + (Stdlib.String.length "> ") + + (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length "> "))) + 1L diff --git a/packages/darklang/cli/scm/commit.dark b/packages/darklang/cli/scm/commit.dark index a93f560d46..1ba39be484 100644 --- a/packages/darklang/cli/scm/commit.dark +++ b/packages/darklang/cli/scm/commit.dark @@ -177,7 +177,7 @@ let execute (state: AppState) (args: List) : AppState = SCM.PackageOps.commitOpIds accountId branchId message opIds with | Ok commitHash -> - let shortId = Stdlib.String.first commitHash 8L + let shortId = Stdlib.String.first commitHash 8I Stdlib.printLine (Colors.success $"Created commit {shortId}") state | Error e -> diff --git a/packages/darklang/cli/scm/showCommit.dark b/packages/darklang/cli/scm/showCommit.dark index e68571d70f..5d1773d5d2 100644 --- a/packages/darklang/cli/scm/showCommit.dark +++ b/packages/darklang/cli/scm/showCommit.dark @@ -12,7 +12,7 @@ let execute (state: AppState) (args: List) : AppState = | [ commitHashStr ] -> // Allow partial commit IDs (prefix matching) let fullIdStr = - if Stdlib.String.length commitHashStr < 64L then + if Stdlib.String.length commitHashStr < 64I then // Try to find a matching commit (search current branch and ancestors) let commits = SCM.PackageOps.getCommitsWithAncestors branchId 100L @@ -37,7 +37,7 @@ let execute (state: AppState) (args: List) : AppState = if Stdlib.List.isEmpty ops then Stdlib.printLine "Commit not found or has no ops." else - let shortId = Stdlib.String.first fullIdStr 8L + let shortId = Stdlib.String.first fullIdStr 8I Stdlib.printLine $"Commit {Cli.Colors.cyan}{shortId}{Cli.Colors.reset}:" Stdlib.printLine "" diff --git a/packages/darklang/cli/ui/components/button.dark b/packages/darklang/cli/ui/components/button.dark index ce6ad72f04..75d6b888e9 100644 --- a/packages/darklang/cli/ui/components/button.dark +++ b/packages/darklang/cli/ui/components/button.dark @@ -9,7 +9,7 @@ type ButtonModel = let createButton (text: String) (color: Core.Types.Color) (action: Unit -> Unit) : Core.Types.Component = let model = ButtonModel { text = text; color = color; size = Core.Types.Size.Normal; disabled = false; action = action } - let textWidth = Stdlib.String.length text + let textWidth = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length text)) let buttonWidth = textWidth + 4L // 2 for borders + 2 for padding let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = buttonWidth; height = 3L } } Core.Types.Component @@ -26,7 +26,7 @@ let renderButton (component: Core.Types.Component) (context: Core.T // Calculate padding based on raw text length (before ANSI codes) let innerWidth = component.bounds.dimensions.width - 2L - let textLen = Stdlib.String.length model.text + let textLen = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length model.text)) let totalPadding = innerWidth - textLen let leftPad = Stdlib.Int64.divide totalPadding 2L let rightPad = totalPadding - leftPad diff --git a/packages/darklang/cli/ui/components/card.dark b/packages/darklang/cli/ui/components/card.dark index 4dbd456a25..d4573b4657 100644 --- a/packages/darklang/cli/ui/components/card.dark +++ b/packages/darklang/cli/ui/components/card.dark @@ -58,7 +58,7 @@ let renderCard (component: Core.Types.Component) (context: Core.Types "" else // Calculate padding based on raw text, then apply styling - let titleLen = Stdlib.String.length model.title + let titleLen = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length model.title)) let rightPad = if innerWidth > titleLen then Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (innerWidth - titleLen)) else "" let styledTitle = Core.Rendering.colorize model.headerColor (Core.Rendering.bold model.title) left ++ " " ++ styledTitle ++ rightPad ++ " " ++ right diff --git a/packages/darklang/cli/ui/components/dropdown.dark b/packages/darklang/cli/ui/components/dropdown.dark index c6078d5e2d..6d45cf1730 100644 --- a/packages/darklang/cli/ui/components/dropdown.dark +++ b/packages/darklang/cli/ui/components/dropdown.dark @@ -23,9 +23,9 @@ let createDropdown (placeholder: String) (items: List) : Core.Type items |> Stdlib.List.map (fun item -> Stdlib.String.length item.label) |> Stdlib.List.append [Stdlib.String.length placeholder] - |> Stdlib.List.fold 20L (fun acc len -> if len > acc then len else acc) + |> Stdlib.List.fold 20I (fun acc len -> if len > acc then len else acc) let height = if model.isOpen then Stdlib.Int64.min model.maxHeight ((Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length items))) + 2L) else 1L - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = maxWidth + 4L; height = height } } + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = (Builtin.unwrap (Stdlib.Int.toInt64 maxWidth)) + 4L; height = height } } Core.Types.Component { id = "dropdown" model = model @@ -127,9 +127,9 @@ let createMultiSelect (placeholder: String) (items: List) (maxSele items |> Stdlib.List.map (fun item -> Stdlib.String.length item.label) |> Stdlib.List.append [Stdlib.String.length placeholder] - |> Stdlib.List.fold 25L (fun acc len -> if len > acc then len else acc) + |> Stdlib.List.fold 25I (fun acc len -> if len > acc then len else acc) let height = if model.isOpen then Stdlib.Int64.min model.maxHeight ((Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length items))) + 2L) else 1L - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = maxWidth + 4L; height = height } } + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = (Builtin.unwrap (Stdlib.Int.toInt64 maxWidth)) + 4L; height = height } } Core.Types.Component { id = "multiselect" model = model @@ -218,10 +218,10 @@ let createContextMenu (items: List) : Core.Types.Component Stdlib.List.map (fun item -> Stdlib.String.length item.label + 4L) - |> Stdlib.List.fold 15L (fun acc len -> if len > acc then len else acc) + |> Stdlib.List.map (fun item -> Stdlib.String.length item.label + 4I) + |> Stdlib.List.fold 15I (fun acc len -> if len > acc then len else acc) let height = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length items))) + 2L - let bounds = Core.Types.Bounds { position = model.position; dimensions = Core.Types.Dimensions { width = maxWidth; height = height } } + let bounds = Core.Types.Bounds { position = model.position; dimensions = Core.Types.Dimensions { width = Builtin.unwrap (Stdlib.Int.toInt64 maxWidth); height = height } } Core.Types.Component { id = "contextmenu" model = model diff --git a/packages/darklang/cli/ui/components/forms.dark b/packages/darklang/cli/ui/components/forms.dark index fce64863f7..218f5c68e1 100644 --- a/packages/darklang/cli/ui/components/forms.dark +++ b/packages/darklang/cli/ui/components/forms.dark @@ -29,14 +29,14 @@ let renderTextInput (component: Core.Types.Component) (context: // Calculate padding based on raw text length let (rawValue, styledValue) = if model.password then - let masked = Stdlib.String.repeat "*" (Stdlib.Int.fromInt64 (Stdlib.String.length model.value)) + let masked = Stdlib.String.repeat "*" (Stdlib.String.length model.value) (masked, masked) else if Stdlib.String.isEmpty model.value then (model.placeholder, Core.Rendering.dim model.placeholder) else (model.value, model.value) - let textLen = Stdlib.String.length rawValue + let textLen = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length rawValue)) let rightPad = if innerWidth > textLen then Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (innerWidth - textLen)) else "" let cursor = if hasFocus then "│" else " " let focusIndicator = if hasFocus then "► " else " " @@ -51,14 +51,14 @@ let updateTextInput (component: Core.Types.Component) (event: Co let model = component.model (match keyEvent with | Character char -> - if Stdlib.String.length model.value < model.maxLength then + if (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length model.value))) < model.maxLength then let newValue = model.value ++ char { component with model = { model with value = newValue; cursorPosition = model.cursorPosition + 1L } } else component | Backspace -> if model.cursorPosition > 0L then - let newValue = Stdlib.String.slice model.value 0L (model.cursorPosition - 1L) + let newValue = Stdlib.String.slice model.value 0I (Stdlib.Int.fromInt64 (model.cursorPosition - 1L)) { component with model = { model with value = newValue; cursorPosition = model.cursorPosition - 1L } } else component @@ -66,7 +66,7 @@ let updateTextInput (component: Core.Types.Component) (event: Co let newPos = if model.cursorPosition > 0L then model.cursorPosition - 1L else 0L { component with model = { model with cursorPosition = newPos } } | Right -> - let maxPos = Stdlib.String.length model.value + let maxPos = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length model.value)) let newPos = if model.cursorPosition < maxPos then model.cursorPosition + 1L else maxPos { component with model = { model with cursorPosition = newPos } } | _ -> component) @@ -81,7 +81,7 @@ type CheckboxModel = let createCheckbox (label: String) (checked: Bool) : Core.Types.Component = let model = CheckboxModel { checked = checked; label = label; disabled = false } - let labelLength = Stdlib.String.length label + let labelLength = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length label)) let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = labelLength + 6L; height = 1L } } Core.Types.Component { id = "checkbox-" ++ label @@ -123,7 +123,7 @@ let createRadioGroup (options: List) (selectedIndex: Int64) : Core.Types let model = RadioModel { options = options; selectedIndex = selectedIndex; disabled = false } let maxWidth = options - |> Stdlib.List.map (fun opt -> Stdlib.String.length opt + 6L) + |> Stdlib.List.map (fun opt -> (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length opt))) + 6L) |> Stdlib.List.fold 20L (fun acc len -> if len > acc then len else acc) let height = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length options)) let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = maxWidth; height = height } } @@ -171,7 +171,7 @@ let createSelect (options: List) (selectedIndex: Int64) : Core.Types.Com let model = SelectModel { options = options; selectedIndex = selectedIndex; isOpen = false; disabled = false } let maxWidth = options - |> Stdlib.List.map Stdlib.String.length + |> Stdlib.List.map (fun opt -> Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length opt))) |> Stdlib.List.fold 10L (fun acc len -> if len > acc then len else acc) let baseHeight = if model.isOpen then (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length options))) + 2L else 1L let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = maxWidth + 4L; height = baseHeight } } diff --git a/packages/darklang/cli/ui/components/label.dark b/packages/darklang/cli/ui/components/label.dark index b0a5e27b9e..f2089c83b7 100644 --- a/packages/darklang/cli/ui/components/label.dark +++ b/packages/darklang/cli/ui/components/label.dark @@ -8,7 +8,7 @@ type LabelModel = let createLabel (text: String) (color: Core.Types.Color) : Core.Types.Component = let model = LabelModel { text = text; color = color; size = Core.Types.Size.Normal; bold = false } - let textLength = Stdlib.String.length text + let textLength = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length text)) let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = textLength; height = 1L } } Core.Types.Component { id = "label-" ++ text @@ -31,7 +31,7 @@ let renderLabel (component: Core.Types.Component) (context: Core.Typ let setLabelText (component: Core.Types.Component) (text: String) : Core.Types.Component = let model = component.model - let textLength = Stdlib.String.length text + let textLength = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length text)) let newBounds = Core.Types.Bounds { position = component.bounds.position; dimensions = Core.Types.Dimensions { width = textLength; height = 1L } } { component with model = { model with text = text } diff --git a/packages/darklang/cli/ui/components/layout.dark b/packages/darklang/cli/ui/components/layout.dark index bc9fe56c31..ec4836fcd5 100644 --- a/packages/darklang/cli/ui/components/layout.dark +++ b/packages/darklang/cli/ui/components/layout.dark @@ -47,7 +47,7 @@ let createPanel (title: String) (content: List) (color: Core.Types.Color let contentHeight = if model.collapsed then 1L else (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length content))) + 2L let maxWidth = (Stdlib.List.push content title) - |> Stdlib.List.map Stdlib.String.length + |> Stdlib.List.map (fun s -> Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length s))) |> Stdlib.List.fold 20L (fun acc len -> if len > acc then len else acc) let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = maxWidth + 4L; height = contentHeight } } Core.Types.Component diff --git a/packages/darklang/cli/ui/components/listview.dark b/packages/darklang/cli/ui/components/listview.dark index d443cddfa4..784d90b6e1 100644 --- a/packages/darklang/cli/ui/components/listview.dark +++ b/packages/darklang/cli/ui/components/listview.dark @@ -43,7 +43,7 @@ let renderListView (component: Core.Types.Component) (context: Co let globalIndex = model.scrollOffset + (Builtin.unwrap (Stdlib.Int.toInt64 i)) let marker = if globalIndex == model.selectedIndex then "▶ " else " " let rawText = marker ++ item.text - let textLen = Stdlib.String.length rawText + let textLen = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length rawText)) let rightPad = if innerWidth > textLen then Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (innerWidth - textLen)) else "" // Style after calculating padding diff --git a/packages/darklang/cli/ui/components/message.dark b/packages/darklang/cli/ui/components/message.dark index 1f6d6edf98..9a7fabdbe6 100644 --- a/packages/darklang/cli/ui/components/message.dark +++ b/packages/darklang/cli/ui/components/message.dark @@ -40,10 +40,10 @@ let renderMessage (component: Core.Types.Component) (context: Core let titleLine = let dismissButton = if model.isDismissible then "✕" else "" - let dismissLen = Stdlib.String.length dismissButton + let dismissLen = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length dismissButton)) // Calculate padding based on raw text (without ANSI codes) let rawTitle = typeIcon ++ " " ++ model.title - let rawTitleLen = Stdlib.String.length rawTitle + let rawTitleLen = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length rawTitle)) let innerWidth = model.width - 4L // borders and padding let paddingNeeded = innerWidth - rawTitleLen - dismissLen let rightPad = if paddingNeeded > 0L then Stdlib.String.repeat " " (Stdlib.Int.fromInt64 paddingNeeded) else "" @@ -83,7 +83,7 @@ type ToastModel = let createToast (message: String) (toastType: Core.Types.Color) (duration: Int64) : Core.Types.Component = let model = ToastModel { message = message; toastType = toastType; duration = duration; isVisible = true; position = Core.Types.Position { x = 0L; y = 0L } } // Width = borders (2) + padding (2) + icon (1) + space (1) + message - let width = Stdlib.String.length message + 6L + let width = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length message))) + 6L let height = 3L let bounds = Core.Types.Bounds { position = model.position; dimensions = Core.Types.Dimensions { width = width; height = height } } Core.Types.Component @@ -110,7 +110,7 @@ let renderToast (component: Core.Types.Component) (context: Core.Typ // Calculate padding based on raw text length (without ANSI codes) let rawText = typeIcon ++ " " ++ model.message let innerWidth = component.bounds.dimensions.width - 4L - let textLen = Stdlib.String.length rawText + let textLen = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length rawText)) let rightPad = if innerWidth > textLen then Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (innerWidth - textLen)) else "" // Style the content diff --git a/packages/darklang/cli/ui/components/modal.dark b/packages/darklang/cli/ui/components/modal.dark index d62fd7852f..314c961796 100644 --- a/packages/darklang/cli/ui/components/modal.dark +++ b/packages/darklang/cli/ui/components/modal.dark @@ -47,7 +47,7 @@ let renderModal (component: Core.Types.Component) (context: Core.Typ let titleLine = let closeButton = if model.hasCloseButton then " ✕" else "" - let availableWidth = model.width - 4L - Stdlib.String.length closeButton + let availableWidth = model.width - 4L - (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length closeButton))) let paddedTitle = Core.Rendering.padText model.title availableWidth Core.Types.Alignment.Center let titleColor = if hasFocus then Core.Types.Color.Primary else Core.Types.Color.Default "║ " ++ Core.Rendering.colorize titleColor (Core.Rendering.bold paddedTitle) ++ closeButton ++ " ║" diff --git a/packages/darklang/cli/ui/components/navigation.dark b/packages/darklang/cli/ui/components/navigation.dark index 89ff8a6bf0..51ba42e489 100644 --- a/packages/darklang/cli/ui/components/navigation.dark +++ b/packages/darklang/cli/ui/components/navigation.dark @@ -21,7 +21,7 @@ let createMenu (title: String) (items: List) : Core.Types.Component Stdlib.List.map (fun item -> Stdlib.String.length item.label + Stdlib.String.length item.shortcut + 4L) + |> Stdlib.List.map (fun item -> (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length item.label + Stdlib.String.length item.shortcut))) + 4L) |> Stdlib.List.fold 20L (fun acc len -> if len > acc then len else acc) let height = if model.isOpen then (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length items))) + 2L else 1L let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = maxWidth; height = height } } @@ -52,7 +52,7 @@ let renderMenu (component: Core.Types.Component) (context: Core.Types else if isSelected then Core.Types.Color.Primary else Core.Types.Color.Default - let label = Core.Rendering.padText item.label (component.bounds.dimensions.width - 6L - Stdlib.String.length item.shortcut) Core.Types.Alignment.Left + let label = Core.Rendering.padText item.label (component.bounds.dimensions.width - 6L - (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length item.shortcut)))) Core.Types.Alignment.Left let shortcut = if Stdlib.String.isEmpty item.shortcut then "" else "[" ++ item.shortcut ++ "]" let styledItem = Core.Rendering.colorize itemColor (prefix ++ " " ++ label ++ " " ++ shortcut) "│" ++ styledItem ++ "│") @@ -190,8 +190,8 @@ type NavBarModel = let createNavBar (title: String) (items: List) : Core.Types.Component = let model = NavBarModel { items = items; selectedIndex = 0L; title = title } let totalWidth = - (Stdlib.String.length title + 4L) + - (items |> Stdlib.List.map (fun item -> Stdlib.String.length item.label + 4L) |> Stdlib.List.fold 0L (fun acc len -> acc + len)) + ((Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length title))) + 4L) + + (items |> Stdlib.List.map (fun item -> (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length item.label))) + 4L) |> Stdlib.List.fold 0L (fun acc len -> acc + len)) let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = totalWidth; height = 1L } } Core.Types.Component { id = "navbar-" ++ title diff --git a/packages/darklang/cli/ui/components/spinner.dark b/packages/darklang/cli/ui/components/spinner.dark index aefb8812b6..39bd446c2c 100644 --- a/packages/darklang/cli/ui/components/spinner.dark +++ b/packages/darklang/cli/ui/components/spinner.dark @@ -36,7 +36,7 @@ let createSpinner (message: String) (style: SpinnerStyle) : Core.Types.Component let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L } - dimensions = Core.Types.Dimensions { width = Stdlib.String.length message + 4L; height = 1L } } + dimensions = Core.Types.Dimensions { width = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length message))) + 4L; height = 1L } } Core.Types.Component { id = "spinner" diff --git a/packages/darklang/cli/ui/components/statusbar.dark b/packages/darklang/cli/ui/components/statusbar.dark index 24c72a5008..c403810b3e 100644 --- a/packages/darklang/cli/ui/components/statusbar.dark +++ b/packages/darklang/cli/ui/components/statusbar.dark @@ -24,9 +24,9 @@ let createStatusBar (leftText: String) (rightText: String) (width: Int64) : Core let renderStatusBar (component: Core.Types.Component) (context: Core.Types.RenderContext) : List = let model = component.model - let leftLen = Stdlib.String.length model.leftText - let rightLen = Stdlib.String.length model.rightText - let centerLen = Stdlib.String.length model.centerText + let leftLen = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length model.leftText)) + let rightLen = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length model.rightText)) + let centerLen = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length model.centerText)) let line = if Stdlib.String.isEmpty model.centerText then @@ -40,7 +40,7 @@ let renderStatusBar (component: Core.Types.Component) (context: else let totalContentLen = leftLen + centerLen + rightLen if totalContentLen >= model.width then - Stdlib.String.slice (model.leftText ++ model.centerText ++ model.rightText) 0L model.width + Stdlib.String.slice (model.leftText ++ model.centerText ++ model.rightText) 0I (Stdlib.Int.fromInt64 model.width) else let leftPadding = Stdlib.Int64.divide (model.width - centerLen) 2L - leftLen let rightPadding = model.width - leftLen - centerLen - leftPadding diff --git a/packages/darklang/cli/ui/components/textblock.dark b/packages/darklang/cli/ui/components/textblock.dark index 92b1d46f27..325b0dac00 100644 --- a/packages/darklang/cli/ui/components/textblock.dark +++ b/packages/darklang/cli/ui/components/textblock.dark @@ -12,7 +12,7 @@ let createTextBlock (lines: List) (color: Core.Types.Color) (alignment: let model = TextBlockModel { lines = lines; color = color; alignment = alignment; wordWrap = false } let maxWidth = lines - |> Stdlib.List.map Stdlib.String.length + |> Stdlib.List.map (fun s -> Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length s))) |> Stdlib.List.fold 0L (fun acc len -> if len > acc then len else acc) let height = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length lines)) let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = maxWidth; height = height } } @@ -35,7 +35,7 @@ let setTextBlockLines (component: Core.Types.Component) (lines: let model = component.model let maxWidth = lines - |> Stdlib.List.map Stdlib.String.length + |> Stdlib.List.map (fun s -> Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length s))) |> Stdlib.List.fold 0L (fun acc len -> if len > acc then len else acc) let height = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length lines)) let newBounds = Core.Types.Bounds { position = component.bounds.position; dimensions = Core.Types.Dimensions { width = maxWidth; height = height } } diff --git a/packages/darklang/cli/ui/core/rendering.dark b/packages/darklang/cli/ui/core/rendering.dark index 5873ad71e1..d311d87d54 100644 --- a/packages/darklang/cli/ui/core/rendering.dark +++ b/packages/darklang/cli/ui/core/rendering.dark @@ -98,7 +98,9 @@ let drawBoxWithStyle (bounds: Types.Bounds) (title: String) (content: List Stdlib.List.map (fun line -> - let lineLength = Stdlib.String.length line + let lineLength = + Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length line)) let padding = if lineLength < innerWidth - 1L then Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (innerWidth - 1L - lineLength)) else "" vert ++ " " ++ line ++ padding ++ vert) @@ -120,9 +123,10 @@ let drawBox (bounds: Types.Bounds) (title: String) (content: List) : Lis drawBoxWithStyle bounds title content BoxStyle.Single let padText (text: String) (width: Int64) (alignment: Types.Alignment) : String = - let textLength = Stdlib.String.length text + let textLength = + Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length text)) if textLength >= width then - Stdlib.String.slice text 0L width + Stdlib.String.slice text 0I (Stdlib.Int.fromInt64 width) else let padding = width - textLength match alignment with @@ -135,10 +139,10 @@ let padText (text: String) (width: Int64) (alignment: Types.Alignment) : String | Justify -> text ++ Stdlib.String.repeat " " (Stdlib.Int.fromInt64 padding) let truncateText (text: String) (maxWidth: Int64) : String = - if Stdlib.String.length text <= maxWidth then + if Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length text)) <= maxWidth then text else - Stdlib.String.slice text 0L (maxWidth - 3L) ++ "..." + Stdlib.String.slice text 0I (Stdlib.Int.fromInt64 (maxWidth - 3L)) ++ "..." // Focus indicators let addFocusIndicator (text: String) (hasFocus: Bool) : String = diff --git a/packages/darklang/cli/ui/layout.dark b/packages/darklang/cli/ui/layout.dark index 81e077c513..370bc376e6 100644 --- a/packages/darklang/cli/ui/layout.dark +++ b/packages/darklang/cli/ui/layout.dark @@ -32,8 +32,8 @@ let printAt (region: Region) (row: Int64) (col: Int64) (text: String) : Unit = let absCol = region.left + col let maxLen = Stdlib.Int64.max 0L (region.cols - col) let truncated = - if (Stdlib.String.length text) > maxLen then - Stdlib.String.slice text 0L maxLen + if (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length text))) > maxLen then + Stdlib.String.slice text 0I (Stdlib.Int.fromInt64 maxLen) else text Stdlib.print (Darklang.Cli.Colors.moveCursorTo absRow absCol) diff --git a/packages/darklang/cli/utils/completion.dark b/packages/darklang/cli/utils/completion.dark index 787523fd20..e35ef1eb2e 100644 --- a/packages/darklang/cli/utils/completion.dark +++ b/packages/darklang/cli/utils/completion.dark @@ -81,7 +81,7 @@ let getMatchedSegmentSuffix (completion: String) (partial: String) : String = let rest = Stdlib.String.dropFirst completion afterMatch // Find end of current segment (next "." or end of string) match Stdlib.String.indexOf rest "." with - | Some dotPos -> Stdlib.String.slice rest 0L dotPos + | Some dotPos -> Stdlib.String.slice rest 0I dotPos | None -> rest @@ -126,14 +126,14 @@ let commandNamesCompletion (_state: AppState) (args: List) : List= maxLen then index else - let char1 = Stdlib.String.slice str1 index (index + 1L) - let char2 = Stdlib.String.slice str2 index (index + 1L) + let char1 = Stdlib.String.slice str1 index (index + 1I) + let char2 = Stdlib.String.slice str2 index (index + 1I) if char1 == char2 then - findCommonLength str1 str2 (index + 1L) maxLen + findCommonLength str1 str2 (index + 1I) maxLen else index @@ -143,9 +143,9 @@ let findCommonPrefix (strings: List) : String = | [single] -> single | first :: rest -> Stdlib.List.fold rest first (fun acc next -> - let maxLen = Stdlib.Int64.min (Stdlib.String.length acc) (Stdlib.String.length next) - let commonLen = findCommonLength acc next 0L maxLen - Stdlib.String.slice acc 0L commonLen) + let maxLen = Stdlib.Int.min (Stdlib.String.length acc) (Stdlib.String.length next) + let commonLen = findCommonLength acc next 0I maxLen + Stdlib.String.slice acc 0I commonLen) // Filesystem completion helpers @@ -171,8 +171,8 @@ let completeFilesystemPath (partialArg: String) : List = else if Stdlib.String.contains partialArg "/" then match Stdlib.String.lastIndexOf partialArg "/" with | Some idx -> - let dirPart = Stdlib.String.slice partialArg 0L (idx + 1L) - let filePart = Stdlib.String.dropFirst partialArg (idx + 1L) + let dirPart = Stdlib.String.slice partialArg 0I (idx + 1I) + let filePart = Stdlib.String.dropFirst partialArg (idx + 1I) let fullPath = if Stdlib.String.startsWith dirPart "/" then diff --git a/packages/darklang/cli/utils/logo.dark b/packages/darklang/cli/utils/logo.dark index 25abe81d3a..a6ebd057ea 100644 --- a/packages/darklang/cli/utils/logo.dark +++ b/packages/darklang/cli/utils/logo.dark @@ -46,7 +46,7 @@ let combineLogoAndText (logoStr: String) (textLines: List) (color: Strin let maxLogoWidth = logoLines |> Stdlib.List.map Stdlib.String.length - |> Stdlib.List.fold 0L (fun acc len -> if len > acc then len else acc) + |> Stdlib.List.fold 0I (fun acc len -> if len > acc then len else acc) // Pad logo lines to same width let paddedLogoLines = diff --git a/packages/darklang/cli/utils/syntaxHighlighting.dark b/packages/darklang/cli/utils/syntaxHighlighting.dark index 75036399e8..48e60450f4 100644 --- a/packages/darklang/cli/utils/syntaxHighlighting.dark +++ b/packages/darklang/cli/utils/syntaxHighlighting.dark @@ -50,9 +50,11 @@ let highlightLine (line: String) (lineTokens: List Stdlib.List.fold line (fun currentLine (pos, colorCode) -> // validate insertion position is within current line bounds - if pos >= 0L && pos <= Stdlib.String.length currentLine then - let before = Stdlib.String.slice currentLine 0L pos // everything before the position - let after = Stdlib.String.dropFirst currentLine pos // everything after the position + // pos comes from Int64 source-position fields; bridge to Int for String fns + let posInt = Stdlib.Int.fromInt64 pos + if posInt >= 0I && posInt <= Stdlib.String.length currentLine then + let before = Stdlib.String.slice currentLine 0I posInt // everything before the position + let after = Stdlib.String.dropFirst currentLine posInt // everything after the position // insert color code at the position before ++ colorCode ++ after else diff --git a/packages/darklang/github.dark b/packages/darklang/github.dark index 33e2342c59..bd3a87110d 100644 --- a/packages/darklang/github.dark +++ b/packages/darklang/github.dark @@ -65,7 +65,7 @@ module Releases = match Stdlib.List.getAt parts 2I with | Some hash -> // Return in same format as CLI version (first 7 chars) - Stdlib.Result.Result.Ok $"alpha-{Stdlib.String.slice hash 0L 7L}" + Stdlib.Result.Result.Ok $"alpha-{Stdlib.String.slice hash 0I 7I}" | None -> // Fallback to tag name if we can't parse hash Stdlib.Result.Result.Ok latestRelease.tag_name diff --git a/packages/darklang/languageTools/capabilities.dark b/packages/darklang/languageTools/capabilities.dark index c05adb903f..8be4e6f8ff 100644 --- a/packages/darklang/languageTools/capabilities.dark +++ b/packages/darklang/languageTools/capabilities.dark @@ -189,7 +189,7 @@ let parseUrl (pattern: String) : LanguageTools.Capabilities.UrlScope = [ LanguageTools.Capabilities.HostMatch.AnyHost ] else if Stdlib.String.startsWith hostStr "*." then [ LanguageTools.Capabilities.HostMatch.Subdomain( - Stdlib.String.toLowercase (Stdlib.String.dropFirst hostStr 2L)) ] + Stdlib.String.toLowercase (Stdlib.String.dropFirst hostStr 2I)) ] else [ LanguageTools.Capabilities.HostMatch.ExactHost(Stdlib.String.toLowercase hostStr) ] let ports = diff --git a/packages/darklang/languageTools/lsp-server/completions.dark b/packages/darklang/languageTools/lsp-server/completions.dark index e78e80a036..4d2e3ed817 100644 --- a/packages/darklang/languageTools/lsp-server/completions.dark +++ b/packages/darklang/languageTools/lsp-server/completions.dark @@ -39,7 +39,7 @@ let createCompletionItem let getCompletionText (name: String) (currentPrefix: String) : String = let prefixLength = Stdlib.String.length currentPrefix let nameLength = Stdlib.String.length name - if prefixLength == 0L then + if prefixLength == 0I then name // if the completion string starts exactly with the prefix typed by the user, we just return the remaining part else if Stdlib.String.startsWith name currentPrefix then @@ -91,10 +91,10 @@ let createCompletions let (modulePath, searchText) = match wordUnderCursor |> Stdlib.String.lastIndexOf "." with | Some i -> - let moduleString = Stdlib.String.slice wordUnderCursor 0L i + let moduleString = Stdlib.String.slice wordUnderCursor 0I i let modules = if moduleString == "" then [] else Stdlib.String.split moduleString "." let searchStr = - wordUnderCursor |> Stdlib.String.dropFirst (i + 1L) + wordUnderCursor |> Stdlib.String.dropFirst (i + 1I) (modules, searchStr) @@ -119,7 +119,7 @@ let createCompletions let currentPrefix = match wordUnderCursor |> Stdlib.String.lastIndexOf "." with - | Some i -> Stdlib.String.slice wordUnderCursor 0L (i + 1L) + | Some i -> Stdlib.String.slice wordUnderCursor 0I (i + 1I) | None -> "" let types = diff --git a/packages/darklang/languageTools/lsp-server/cursorPosition.dark b/packages/darklang/languageTools/lsp-server/cursorPosition.dark index f5e263afdd..86d1190aef 100644 --- a/packages/darklang/languageTools/lsp-server/cursorPosition.dark +++ b/packages/darklang/languageTools/lsp-server/cursorPosition.dark @@ -54,7 +54,8 @@ let wordUnderCursor |> Stdlib.List.getAt (Stdlib.Int.fromInt64 line) |> Stdlib.Option.withDefault "" - let lineToCursor = currentLine |> Stdlib.String.slice 0L character + let lineToCursor = + currentLine |> Stdlib.String.slice 0I (Stdlib.Int.fromInt64 character) lineToCursor |> Stdlib.String.split " " diff --git a/packages/darklang/languageTools/lsp-server/docSync.dark b/packages/darklang/languageTools/lsp-server/docSync.dark index 179e3c22fa..0c784fb293 100644 --- a/packages/darklang/languageTools/lsp-server/docSync.dark +++ b/packages/darklang/languageTools/lsp-server/docSync.dark @@ -49,8 +49,8 @@ let parseAndReportDiagnostics let pathPart = // TODO: remove magic requestUri - |> Stdlib.String.dropFirst 8L // Remove "darkfs:/" - |> Stdlib.String.dropLast 5L // Remove ".dark" + |> Stdlib.String.dropFirst 8I // Remove "darkfs:/" + |> Stdlib.String.dropLast 5I // Remove ".dark" if Stdlib.String.startsWith pathPart "script/" then ("LSP", "scriptName") diff --git a/packages/darklang/languageTools/lsp-server/fileSystemProvider.dark b/packages/darklang/languageTools/lsp-server/fileSystemProvider.dark index 54944090b5..7947096530 100644 --- a/packages/darklang/languageTools/lsp-server/fileSystemProvider.dark +++ b/packages/darklang/languageTools/lsp-server/fileSystemProvider.dark @@ -30,8 +30,8 @@ module ReadFile = let nameForLookup = // TODO: remove magic params.uri - |> Stdlib.String.dropFirst 8L // Drop "darkfs:/" - |> Stdlib.String.dropLast 5L // Drop ".dark" + |> Stdlib.String.dropFirst 8I // Drop "darkfs:/" + |> Stdlib.String.dropLast 5I // Drop ".dark" let location = ProgramTypes.parsePackageLocation nameForLookup @@ -42,7 +42,7 @@ module ReadFile = if Stdlib.String.startsWith nameForLookup "script/" then let scriptName = nameForLookup - |> Stdlib.String.dropFirst 7L // Drop "script/" + |> Stdlib.String.dropFirst 7I // Drop "script/" match Builtin.pmScriptsGet scriptName with | Some script -> script.text @@ -240,13 +240,13 @@ module WriteFile = let nameForLookup = // TODO: remove magic params.uri - |> Stdlib.String.dropFirst 8L // Drop "darkfs:/" - |> Stdlib.String.dropLast 5L // Drop ".dark" + |> Stdlib.String.dropFirst 8I // Drop "darkfs:/" + |> Stdlib.String.dropLast 5I // Drop ".dark" if Stdlib.String.startsWith nameForLookup "script/" then let scriptName = nameForLookup - |> Stdlib.String.dropFirst 7L // Drop "script/" + |> Stdlib.String.dropFirst 7I // Drop "script/" // Update the script content match Builtin.pmScriptsUpdate scriptName content with diff --git a/packages/darklang/languageTools/lsp-server/hover.dark b/packages/darklang/languageTools/lsp-server/hover.dark index 9c3c76daf6..3d743b270d 100644 --- a/packages/darklang/languageTools/lsp-server/hover.dark +++ b/packages/darklang/languageTools/lsp-server/hover.dark @@ -15,7 +15,7 @@ let getTextAtRange match textLines with | Some line -> line - |> Stdlib.String.slice startColumn endColumn + |> Stdlib.String.slice (Stdlib.Int.fromInt64 startColumn) (Stdlib.Int.fromInt64 endColumn) |> Stdlib.Option.Option.Some | None -> Stdlib.Option.Option.None @@ -59,8 +59,8 @@ let handleHoverRequest let pathPart = // TODO: remove magic params.textDocument.uri - |> Stdlib.String.dropFirst 8L // Remove "darkfs:/" - |> Stdlib.String.dropLast 5L // Remove ".dark" + |> Stdlib.String.dropFirst 8I // Remove "darkfs:/" + |> Stdlib.String.dropLast 5I // Remove ".dark" if Stdlib.String.startsWith pathPart "script/" then ("LspHover", "") diff --git a/packages/darklang/languageTools/lsp-server/lsp-server.dark b/packages/darklang/languageTools/lsp-server/lsp-server.dark index cbcd6b3464..095bd454cf 100644 --- a/packages/darklang/languageTools/lsp-server/lsp-server.dark +++ b/packages/darklang/languageTools/lsp-server/lsp-server.dark @@ -199,7 +199,7 @@ let tryReadHeader if line == "" then contentLength |> Stdlib.Option.toResult "No Content-Length header found" else if Stdlib.String.startsWith line "Content-Length: " then - let lengthStr = Stdlib.String.dropFirst line 16L + let lengthStr = Stdlib.String.dropFirst line 16I match Stdlib.Int64.parse lengthStr with | Ok length -> tryReadHeader (Stdlib.Option.Option.Some length) diff --git a/packages/darklang/languageTools/lsp.dark b/packages/darklang/languageTools/lsp.dark index 681778b106..eeb24cf873 100644 --- a/packages/darklang/languageTools/lsp.dark +++ b/packages/darklang/languageTools/lsp.dark @@ -58,7 +58,8 @@ let getDiagnostics (uri: String) (text: String) : String = let lastLineLength = match lines |> Stdlib.List.last with - | Some lastLine -> Stdlib.String.length lastLine + | Some lastLine -> + Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length lastLine)) | None -> 0L Position diff --git a/packages/darklang/languageTools/parser/core.dark b/packages/darklang/languageTools/parser/core.dark index adb58e00de..f9674e2fd3 100644 --- a/packages/darklang/languageTools/parser/core.dark +++ b/packages/darklang/languageTools/parser/core.dark @@ -271,7 +271,7 @@ let extractDocComments (node: ParsedNode) : String = |> Stdlib.List.map (fun docComment -> // Remove the "///" prefix and any leading space docComment.text - |> Stdlib.String.dropFirst 3L + |> Stdlib.String.dropFirst 3I |> Stdlib.String.trimStart) |> Stdlib.String.join "\n" @@ -411,7 +411,7 @@ let baseParseDict findAndParseRequired dictPairNode "key" (fun node -> match node.typ with | "double_backtick_identifier" -> - let key = node.text |> Stdlib.String.slice 2L -2L + let key = node.text |> Stdlib.String.slice 2I -2I (node.range, key) |> Stdlib.Result.Result.Ok | _ -> (node.range, nameOrBlank (Parser.getText node)) diff --git a/packages/darklang/languageTools/parser/expr.dark b/packages/darklang/languageTools/parser/expr.dark index 1aefdc0bfb..ce7be01a41 100644 --- a/packages/darklang/languageTools/parser/expr.dark +++ b/packages/darklang/languageTools/parser/expr.dark @@ -91,7 +91,7 @@ let parseFloatLiteral let (sign, whole, remainder) = let (sign, unsignedFloat) = if Stdlib.String.startsWith floatStr "-" then - (Sign.Negative, Stdlib.String.dropFirst floatStr 1L) + (Sign.Negative, Stdlib.String.dropFirst floatStr 1I) else (Sign.Positive, floatStr) diff --git a/packages/darklang/languageTools/parser/matchPattern.dark b/packages/darklang/languageTools/parser/matchPattern.dark index c173d88d39..916e6958df 100644 --- a/packages/darklang/languageTools/parser/matchPattern.dark +++ b/packages/darklang/languageTools/parser/matchPattern.dark @@ -93,7 +93,7 @@ let parseMPFloat let (sign, whole, remainder) = let (sign, unsignedFloat) = if Stdlib.String.startsWith floatStr "-" then - (Sign.Negative, Stdlib.String.dropFirst floatStr 1L) + (Sign.Negative, Stdlib.String.dropFirst floatStr 1I) else (Sign.Positive, floatStr) diff --git a/packages/darklang/languageTools/programTypes.dark b/packages/darklang/languageTools/programTypes.dark index 38f6983956..920a757dc0 100644 --- a/packages/darklang/languageTools/programTypes.dark +++ b/packages/darklang/languageTools/programTypes.dark @@ -373,7 +373,7 @@ let hashToString (hash: Hash) : String = /// First 8 hex chars, for human-readable display let hashToShort (hash: Hash) : String = let h = hashToString hash - Stdlib.String.first h 8L + Stdlib.String.first h 8I /// A package entity paired with its location type LocatedItem<'entity> = diff --git a/packages/darklang/llm/tools/file-system.dark b/packages/darklang/llm/tools/file-system.dark index 8237415d30..b83a8bef08 100644 --- a/packages/darklang/llm/tools/file-system.dark +++ b/packages/darklang/llm/tools/file-system.dark @@ -32,7 +32,7 @@ let resolveSafePath (path: String) : Stdlib.Result.Result = if path == "." then "" else if Stdlib.String.startsWith path "./" then - Stdlib.String.dropFirst path 2L + Stdlib.String.dropFirst path 2I else path diff --git a/packages/darklang/modelContextProtocol/resources/resources.dark b/packages/darklang/modelContextProtocol/resources/resources.dark index 301e72641f..1d05067241 100644 --- a/packages/darklang/modelContextProtocol/resources/resources.dark +++ b/packages/darklang/modelContextProtocol/resources/resources.dark @@ -213,8 +213,8 @@ module Helpers = // Extract the variable name (remove the {}) let varName = templateSeg - |> Stdlib.String.dropFirst 1L - |> Stdlib.String.dropLast 1L + |> Stdlib.String.dropFirst 1I + |> Stdlib.String.dropLast 1I Stdlib.Option.Option.Some (varName, uriSeg) else if uriSeg == templateSeg then diff --git a/packages/darklang/modelContextProtocol/serverBuilder/io.dark b/packages/darklang/modelContextProtocol/serverBuilder/io.dark index 6488ab5a93..c439fdbeea 100644 --- a/packages/darklang/modelContextProtocol/serverBuilder/io.dark +++ b/packages/darklang/modelContextProtocol/serverBuilder/io.dark @@ -4,7 +4,7 @@ module Darklang.ModelContextProtocol.ServerBuilder /// Read a message from the client using line-based stdio let readMessageFromClientWithPath (logFilePath: String) : String = let message = Builtin.stdinReadLine () - logWithPath logFilePath $"Got message from stdin, length: {(Stdlib.String.length message) |> Stdlib.Int64.toString}" + logWithPath logFilePath $"Got message from stdin, length: {(Stdlib.String.length message) |> Stdlib.Int.toString}" if message == "" then logWithPath logFilePath "Message is empty" diff --git a/packages/darklang/prettyPrinter/capabilities.dark b/packages/darklang/prettyPrinter/capabilities.dark index 4097f4636b..9ac56ef422 100644 --- a/packages/darklang/prettyPrinter/capabilities.dark +++ b/packages/darklang/prettyPrinter/capabilities.dark @@ -8,7 +8,7 @@ module Darklang.PrettyPrinter.Capabilities let methodLabel (m: String) : String = if m == "*" then "any" else m -let pad (s: String) (goal: Int64) : String = +let pad (s: String) (goal: Int) : String = match Stdlib.String.padEnd s " " goal with | Ok r -> r | Error _ -> s @@ -49,7 +49,7 @@ let line (spec: String) : String = if det == "" then PrettyPrinter.Capabilities.domainOf spec else - $"{PrettyPrinter.Capabilities.pad (PrettyPrinter.Capabilities.domainOf spec) 14L}{det}" + $"{PrettyPrinter.Capabilities.pad (PrettyPrinter.Capabilities.domainOf spec) 14I}{det}" /// The multi-line view: one aligned line per spec. let lines (specs: List) : List = diff --git a/packages/darklang/prettyPrinter/common.dark b/packages/darklang/prettyPrinter/common.dark index 5e1789176f..cba2c15c94 100644 --- a/packages/darklang/prettyPrinter/common.dark +++ b/packages/darklang/prettyPrinter/common.dark @@ -31,8 +31,8 @@ let sign (s: LanguageTools.Sign) : String = | Negative -> "-" // One-hex-digit (0-15) to its source character. -let hexDigitChar (n: Int64) : String = - Stdlib.String.slice "0123456789ABCDEF" n (n + 1L) +let hexDigitChar (n: Int) : String = + Stdlib.String.slice "0123456789ABCDEF" n (n + 1I) // Encode one Char to its source-form. ASCII control characters and the // backslash get an escape; everything else (printable ASCII, non-ASCII @@ -41,20 +41,17 @@ let encodeChar (c: Char) : String = match Stdlib.Char.toAsciiCode c with | None -> Stdlib.Char.toString c | Some code -> - // CLEANUP drop this bridge once String.slice / hexDigitChar move to Int - let code = Builtin.unwrap (Stdlib.Int.toInt64 code) - - if code == 92L then "\\\\" - else if code == 7L then "\\a" - else if code == 8L then "\\b" - else if code == 9L then "\\t" - else if code == 10L then "\\n" - else if code == 11L then "\\v" - else if code == 12L then "\\f" - else if code == 13L then "\\r" - else if code < 32L || code == 127L then - let hi = Stdlib.Int64.divide code 16L - let lo = code % 16L + if code == 92I then "\\\\" + else if code == 7I then "\\a" + else if code == 8I then "\\b" + else if code == 9I then "\\t" + else if code == 10I then "\\n" + else if code == 11I then "\\v" + else if code == 12I then "\\f" + else if code == 13I then "\\r" + else if code < 32I || code == 127I then + let hi = Stdlib.Int.divide code 16I + let lo = code % 16I $"\\x{hexDigitChar hi}{hexDigitChar lo}" else Stdlib.Char.toString c @@ -79,6 +76,6 @@ let escapeCharLiteral (s: String) : String = let processRemainder (remainder: String) : String = match $".{remainder}" |> Stdlib.Float.parse with | Ok floatValue -> - floatValue |> Stdlib.Float.toString |> Stdlib.String.dropFirst 2L + floatValue |> Stdlib.Float.toString |> Stdlib.String.dropFirst 2I | Error _ -> remainder \ No newline at end of file diff --git a/packages/darklang/prettyPrinter/programTypes.dark b/packages/darklang/prettyPrinter/programTypes.dark index 043ad0a4c0..7ea557900b 100644 --- a/packages/darklang/prettyPrinter/programTypes.dark +++ b/packages/darklang/prettyPrinter/programTypes.dark @@ -89,7 +89,7 @@ let packageNameWithContext Stdlib.String.dropFirst fullName (Stdlib.String.length prefix) else if owner == "Darklang" then // For Darklang packages, drop the "Darklang." prefix for brevity - let withoutDarklang = Stdlib.String.dropFirst fullName 9L // "Darklang.".length + let withoutDarklang = Stdlib.String.dropFirst fullName 9I // "Darklang.".length withoutDarklang else fullName diff --git a/packages/darklang/prettyPrinter/runtimeError.dark b/packages/darklang/prettyPrinter/runtimeError.dark index 6a2fb15692..8e57c48d14 100644 --- a/packages/darklang/prettyPrinter/runtimeError.dark +++ b/packages/darklang/prettyPrinter/runtimeError.dark @@ -110,7 +110,7 @@ module RuntimeError = | InlineValue dv -> // CLEANUP for strings that are cut off, the closing `"` is missing. (dval branchId dv) - |> Stdlib.String.ellipsis 10L + |> Stdlib.String.ellipsis 10I |> Stdlib.String.splitOnNewline |> Stdlib.String.join "" | FullValue dv -> dval branchId dv diff --git a/packages/darklang/prettyPrinter/runtimeTypes.dark b/packages/darklang/prettyPrinter/runtimeTypes.dark index 7534b53f85..84d3aabb38 100644 --- a/packages/darklang/prettyPrinter/runtimeTypes.dark +++ b/packages/darklang/prettyPrinter/runtimeTypes.dark @@ -411,7 +411,7 @@ module Dval = let short = Stdlib.String.join parts ", " - if Stdlib.String.length short <= 80L then + if Stdlib.String.length short <= 80I then $"({short})" else let long = Stdlib.String.join parts $"{inl}, " @@ -427,7 +427,7 @@ module Dval = Stdlib.List.map l (fun item -> withIndent branchId indent item) let short = Stdlib.String.join parts ", " - if Stdlib.String.length short <= 80L then + if Stdlib.String.length short <= 80I then $"[{short}]" else let long = Stdlib.String.join parts $",{inl}" @@ -447,7 +447,7 @@ module Dval = let short = Stdlib.String.join strs ", " - if Stdlib.String.length short <= 80L then + if Stdlib.String.length short <= 80I then "{ " ++ short ++ " }" else let long = Stdlib.String.join strs $",{inl}" @@ -456,7 +456,7 @@ module Dval = // Don't fetch the bytes for rendering — payloads can be many MB. | DBlobPersistent(hash, length) -> - let short = Stdlib.String.first hash 8L + let short = Stdlib.String.first hash 8I $"" | DBlobEphemeral _ -> "" @@ -483,7 +483,7 @@ module Dval = let typeStr = RuntimeTypes.typeName branchId typeName $"{typeStr}{typeArgsPart}.{caseName}{fieldStr}" - if Stdlib.String.length short <= 80L then + if Stdlib.String.length short <= 80I then short else let fieldStr = @@ -518,7 +518,7 @@ module Dval = let short = Stdlib.String.join strs ", " - if Stdlib.String.length short <= 80L then + if Stdlib.String.length short <= 80I then typeStr ++ typeArgsPart ++ " { " ++ short ++ " }" else let long = Stdlib.String.join strs $",{inl}" diff --git a/packages/darklang/stdlib/cli/file.dark b/packages/darklang/stdlib/cli/file.dark index f27068ebd7..5f5e9b12d5 100644 --- a/packages/darklang/stdlib/cli/file.dark +++ b/packages/darklang/stdlib/cli/file.dark @@ -310,7 +310,7 @@ let glob (basePath: String) (pattern: String) : Result.Result, Posi |> Stdlib.Result.map (fun allPaths -> allPaths |> Stdlib.List.filter (fun fullPath -> - let rel = Stdlib.String.dropFirst fullPath ((Stdlib.String.length cleanBase) + 1L) + let rel = Stdlib.String.dropFirst fullPath ((Stdlib.String.length cleanBase) + 1I) let pathSegs = Stdlib.String.split rel "/" globMatchSegments patternSegs pathSegs)) diff --git a/packages/darklang/stdlib/cli/fileSystem.dark b/packages/darklang/stdlib/cli/fileSystem.dark index 135797fafb..c133a561e1 100644 --- a/packages/darklang/stdlib/cli/fileSystem.dark +++ b/packages/darklang/stdlib/cli/fileSystem.dark @@ -32,7 +32,7 @@ let getDirectoryContents (path: String) : List = // Normalize path by removing leading "./" if present let normalizedPath = if Stdlib.String.startsWith path "./" then - Stdlib.String.dropFirst path 2L + Stdlib.String.dropFirst path 2I else path $"{currentDir}/{normalizedPath}" @@ -56,7 +56,7 @@ let isDirectoryAtPath (dirPath: String) (fileName: String) : Bool = if Stdlib.String.startsWith dirPath "/" then dirPath else if Stdlib.String.startsWith dirPath "./" then - let withoutDot = Stdlib.String.dropFirst dirPath 2L + let withoutDot = Stdlib.String.dropFirst dirPath 2I $"{currentDir}/{withoutDot}" else $"{currentDir}/{dirPath}" diff --git a/packages/darklang/stdlib/cli/path.dark b/packages/darklang/stdlib/cli/path.dark index 5de148d74d..a61903a72b 100644 --- a/packages/darklang/stdlib/cli/path.dark +++ b/packages/darklang/stdlib/cli/path.dark @@ -3,8 +3,8 @@ module Darklang.Stdlib.Cli.Path /// Strip trailing slashes from a path (preserving root "/"). let stripTrailing (path: String) : String = - if (Stdlib.String.length path) > 1L && (Stdlib.String.endsWith path "/") then - stripTrailing (Stdlib.String.dropLast path 1L) + if (Stdlib.String.length path) > 1I && (Stdlib.String.endsWith path "/") then + stripTrailing (Stdlib.String.dropLast path 1I) else path @@ -32,8 +32,8 @@ let parent (path: String) : String = let p = stripTrailing path match Stdlib.String.lastIndexOf p "/" with - | Some 0L -> "/" - | Some i -> Stdlib.String.slice p 0L i + | Some 0I -> "/" + | Some i -> Stdlib.String.slice p 0I i | None -> "." @@ -45,7 +45,7 @@ let basename (path: String) : String = let p = stripTrailing path match Stdlib.String.lastIndexOf p "/" with - | Some i -> Stdlib.String.dropFirst p (i + 1L) + | Some i -> Stdlib.String.dropFirst p (i + 1I) | None -> p @@ -58,7 +58,7 @@ let extension (path: String) : Stdlib.Option.Option = let name = basename path match Stdlib.String.lastIndexOf name "." with - | Some 0L -> Stdlib.Option.Option.None + | Some 0I -> Stdlib.Option.Option.None | Some i -> Stdlib.Option.Option.Some(Stdlib.String.dropFirst name i) | None -> Stdlib.Option.Option.None @@ -72,8 +72,8 @@ let withExtension (path: String) (ext: String) : String = let stem = match Stdlib.String.lastIndexOf name "." with - | Some 0L -> name - | Some i -> Stdlib.String.slice name 0L i + | Some 0I -> name + | Some i -> Stdlib.String.slice name 0I i | None -> name let newName = $"{stem}{ext}" diff --git a/packages/darklang/stdlib/cli/ui/table.dark b/packages/darklang/stdlib/cli/ui/table.dark index b428e18550..9a096d1963 100644 --- a/packages/darklang/stdlib/cli/ui/table.dark +++ b/packages/darklang/stdlib/cli/ui/table.dark @@ -13,19 +13,19 @@ let print (columns: List) (rows: List>) : Unit = let maxCellLen = rows - |> Stdlib.List.fold 0L (fun mx row -> + |> Stdlib.List.fold 0I (fun mx row -> match Stdlib.List.getAt row i with - | Some cell -> Stdlib.Int64.max mx (Stdlib.String.length cell) + | Some cell -> Stdlib.Int.max mx (Stdlib.String.length cell) | None -> mx) - Stdlib.Int64.max headerLen maxCellLen) + Stdlib.Int.max headerLen maxCellLen) // Pad a string to a given width with spaces let pad = (fun s width -> let padding = width - (Stdlib.String.length s) - if padding <= 0L then s - else s ++ (Stdlib.String.repeat " " (Stdlib.Int.fromInt64 padding))) + if padding <= 0I then s + else s ++ (Stdlib.String.repeat " " padding)) // Print header row let headerLine = @@ -41,7 +41,7 @@ let print (columns: List) (rows: List>) : Unit = // Print separator let sepLine = colWidths - |> Stdlib.List.map (fun w -> Stdlib.String.repeat "-" (Stdlib.Int.fromInt64 w)) + |> Stdlib.List.map (fun w -> Stdlib.String.repeat "-" w) |> Stdlib.String.join " " Builtin.printLine sepLine diff --git a/packages/darklang/stdlib/duration.dark b/packages/darklang/stdlib/duration.dark index 90b74cc504..1490f3e692 100644 --- a/packages/darklang/stdlib/duration.dark +++ b/packages/darklang/stdlib/duration.dark @@ -7,12 +7,12 @@ module Darklang.Stdlib.Duration /// Bare numbers are rejected — every duration must end with a unit. let parse (s: String) : Stdlib.Result.Result = let len = Stdlib.String.length s - if len < 2L then + if len < 2I then Stdlib.Result.Result.Error $"Duration too short: '{s}'; need a number + unit (s/m/h/d), e.g. 5m" else - let unit = Stdlib.String.last s 1L - let numPart = Stdlib.String.dropLast s 1L + let unit = Stdlib.String.last s 1I + let numPart = Stdlib.String.dropLast s 1I match Stdlib.Int.parse numPart with | Error _ -> Stdlib.Result.Result.Error diff --git a/packages/darklang/stdlib/http.dark b/packages/darklang/stdlib/http.dark index 4403de3e79..bd1a90e59d 100644 --- a/packages/darklang/stdlib/http.dark +++ b/packages/darklang/stdlib/http.dark @@ -32,6 +32,78 @@ let parseQueryString (url: String) : Dict = |> Stdlib.Dict.fromListOverwritingDuplicates +/// Decode one ASCII byte as a hex digit (0-9, A-F, a-f) → 0..15. +let urlDecodeHexDigit (b: UInt8) : Stdlib.Option.Option = + let ge48 = Stdlib.UInt8.greaterThanOrEqualTo b 48uy + let le57 = Stdlib.UInt8.lessThanOrEqualTo b 57uy + let ge65 = Stdlib.UInt8.greaterThanOrEqualTo b 65uy + let le70 = Stdlib.UInt8.lessThanOrEqualTo b 70uy + let ge97 = Stdlib.UInt8.greaterThanOrEqualTo b 97uy + let le102 = Stdlib.UInt8.lessThanOrEqualTo b 102uy + if ge48 && le57 then + Stdlib.Option.Option.Some(Stdlib.UInt8.subtract b 48uy) + else if ge65 && le70 then + Stdlib.Option.Option.Some(Stdlib.UInt8.subtract b 55uy) + else if ge97 && le102 then + Stdlib.Option.Option.Some(Stdlib.UInt8.subtract b 87uy) + else + Stdlib.Option.Option.None + + +/// Inner recursion for [[urlDecode]]. `acc` accumulates decoded bytes at +/// the front (via `List.push`) and is reversed when [bytes] is empty. +// +// Walks bytes (not chars) so multi-byte UTF-8 round-trips. Falls back to +// passing the literal `%` through if a `%` isn't followed by two hex digits, +// matching browser behaviour. +let rec urlDecodeGo (bytes: List) (acc: List) : List = + match bytes with + | [] -> Stdlib.List.reverse acc + | 43uy :: tail -> + // '+' → ' ' + urlDecodeGo tail (Stdlib.List.push acc 32uy) + | 37uy :: h1 :: h2 :: tail -> + // '%XX' + match (Stdlib.Http.urlDecodeHexDigit h1, Stdlib.Http.urlDecodeHexDigit h2) with + | (Some hi, Some lo) -> + let byte = Stdlib.UInt8.add (Stdlib.UInt8.multiply hi 16uy) lo + urlDecodeGo tail (Stdlib.List.push acc byte) + | _ -> + urlDecodeGo + (Stdlib.List.push (Stdlib.List.push tail h2) h1) + (Stdlib.List.push acc 37uy) + | b :: tail -> urlDecodeGo tail (Stdlib.List.push acc b) + + +/// Decode a percent-encoded string (URL or form encoding). `+` becomes a +/// space; `%XX` sequences are decoded as UTF-8 bytes. +let urlDecode (s: String) : String = + let bytes = Stdlib.Blob.toList (Stdlib.String.toBlob s) + Stdlib.String.fromBytesWithReplacement (Stdlib.Http.urlDecodeGo bytes []) + + +/// Parse an `application/x-www-form-urlencoded` body (e.g. from an HTML +/// `
`) into a Dict. Keys and values are percent-decoded. +/// Duplicates resolve last-wins. +let parseFormBody (body: Blob) : Dict = + body + |> Stdlib.String.fromBlobWithReplacement + |> Stdlib.String.split "&" + |> Stdlib.List.filterMap (fun param -> + if param == "" then + Stdlib.Option.Option.None + else + match Stdlib.String.split param "=" with + | [ key ] -> + Stdlib.Option.Option.Some((Stdlib.Http.urlDecode key, "")) + | key :: rest -> + let value = Stdlib.String.join rest "=" + Stdlib.Option.Option.Some( + (Stdlib.Http.urlDecode key, Stdlib.Http.urlDecode value)) + | [] -> Stdlib.Option.Option.None) + |> Stdlib.Dict.fromListOverwritingDuplicates + + /// Parse a string of HTTP header lines (one `Name: value` per line, CR/LF or /// LF separated) into a Dict. Duplicates resolve to the last-wins value. /// Header names are kept verbatim — case-insensitive lookup is the caller's diff --git a/packages/darklang/stdlib/httpclient.dark b/packages/darklang/stdlib/httpclient.dark index f1a16bfae3..db0434624a 100644 --- a/packages/darklang/stdlib/httpclient.dark +++ b/packages/darklang/stdlib/httpclient.dark @@ -198,13 +198,13 @@ module Sse = match Stdlib.String.indexOf line ":" with | None -> (line, "") | Some idx -> - let field = Stdlib.String.slice line 0L idx + let field = Stdlib.String.slice line 0I idx let afterColon = - Stdlib.String.slice line (idx + 1L) (Stdlib.String.length line) + Stdlib.String.slice line (idx + 1I) (Stdlib.String.length line) let value = if Stdlib.String.startsWith afterColon " " then - Stdlib.String.dropFirst afterColon 1L + Stdlib.String.dropFirst afterColon 1I else afterColon diff --git a/packages/darklang/stdlib/httpserver.dark b/packages/darklang/stdlib/httpserver.dark index 5c66555172..ad1ba12843 100644 --- a/packages/darklang/stdlib/httpserver.dark +++ b/packages/darklang/stdlib/httpserver.dark @@ -31,9 +31,9 @@ let parseRouteSegments (route: String) : List = if String.isEmpty seg then Option.Option.None else if String.startsWith seg ":" then - Option.Option.Some(RouteSegment.Variable (String.dropFirst seg 1L)) + Option.Option.Some(RouteSegment.Variable (String.dropFirst seg 1I)) else if String.startsWith seg "*" then - Option.Option.Some(RouteSegment.Wildcard (String.dropFirst seg 1L)) + Option.Option.Some(RouteSegment.Wildcard (String.dropFirst seg 1I)) else Option.Option.Some(RouteSegment.Literal seg)) diff --git a/packages/darklang/stdlib/string.dark b/packages/darklang/stdlib/string.dark index 27b4e48da7..4925fd16a5 100644 --- a/packages/darklang/stdlib/string.dark +++ b/packages/darklang/stdlib/string.dark @@ -7,9 +7,9 @@ let newline = "\n" /// Truncates the string to the specified and appends an ellipsis ("...") /// to it if the original string exceeds the given length. Otherwise, returns the original string. -let ellipsis (s: String) (length: Int64) : String = +let ellipsis (s: String) (length: Int) : String = if String.length s > length then - (String.slice_v0 s 0L length) ++ "..." + (String.slice_v0 s 0I length) ++ "..." else s @@ -23,10 +23,10 @@ let articleFor (nextWord: String) : String = | None -> "" | Some c -> if - String.length nextWord > 1L + String.length nextWord > 1I && (Bool.not (Char.isASCIILetter c)) then - articleFor (String.dropFirst nextWord 1L) + articleFor (String.dropFirst nextWord 1I) else if List.``member`` vowels c then "an" else @@ -62,7 +62,7 @@ let toLowercase (s: String) : String = Builtin.stringToLowercase s // TODO: UInt? /// Returns the length of the string -let length (s: String) : Int64 = Builtin.stringLength s +let length (s: String) : Int = Builtin.stringLength s /// Concatenates the two strings by appending to and returns the joined string. @@ -119,9 +119,9 @@ let splitFirst let splitN (string: String) (separator: String) - (n: Int64) + (n: Int) : List = - if n <= 1L || separator == "" then + if n <= 1I || separator == "" then [ string ] else // indexOfEgc (not indexOf) because first / dropFirst / length are EGC-indexed. @@ -130,7 +130,7 @@ let splitN | Some i -> let before = String.first string i let rest = String.dropFirst string (i + String.length separator) - List.push (String.splitN rest separator (n - 1L)) before + List.push (String.splitN rest separator (n - 1I)) before /// Combines a list of strings with the provided separator @@ -199,8 +199,9 @@ let random (length: Int) : Result.Result = let randomChar = fun _ -> (let index = - Int64.random 0L ((String.length characters) - 1L) - String.slice characters index (index + 1L)) + Stdlib.Int.fromInt64 + (Int64.random 0L (Builtin.unwrap (Stdlib.Int.toInt64 ((String.length characters) - 1I)))) + String.slice characters index (index + 1I)) let result = (List.range 0I (length - 1I)) @@ -231,24 +232,23 @@ let htmlEscape (html: String) : String = /// Checks if contains . // -// Calls the underlying builtin directly (rather than going through the -// `indexOf` wrapper) so this fn stays SQL-queryable: the query compiler -// routes the builtin via SqlCallback2 → INSTR. Wrapping in a -// match-on-Option breaks queryability and trips `DB.queryAll` callers. +// Uses the dedicated `stringContains` builtin (returns Bool, compiles to +// `INSTR(...) > 0`) rather than `indexOf != -1`, so it stays SQL-queryable +// independent of `indexOf`'s now arbitrary-precision `Int` return. let contains (lookingIn: String) (searchingFor: String) : Bool = - Builtin.stringIndexOf lookingIn searchingFor != -1L + Builtin.stringContains lookingIn searchingFor /// Returns the substring of between the and indices. /// Negative indices start counting from the end of . -let slice (string: String) (from: Int64) (``to``: Int64) : String = +let slice (string: String) (from: Int) (``to``: Int) : String = let len = String.length string let normalize = (fun i -> - (if i < 0L then len + i else i) - |> Int64.min len - |> Int64.max 0L) + (if i < 0I then len + i else i) + |> Int.min len + |> Int.max 0I) let f = normalize from let l = normalize ``to`` @@ -260,20 +260,20 @@ let slice (string: String) (from: Int64) (``to``: Int64) : String = /// Returns the first characters of , as a Builtin.String. /// If is longer than , returns . /// If is negative, returns the empty string." -let first (string: String) (characterCount: Int64) : String = - if characterCount < 0L then +let first (string: String) (characterCount: Int) : String = + if characterCount < 0I then "" else if characterCount > String.length string then string else - String.slice_v0 string 0L characterCount + String.slice_v0 string 0I characterCount /// Returns the last characters of , as a Builtin.String. /// If is longer than , returns . /// If is negative, returns the empty string. -let last (string: String) (characterCount: Int64) : String = - if characterCount < 0L then +let last (string: String) (characterCount: Int) : String = + if characterCount < 0I then "" else if characterCount > String.length string then string @@ -287,23 +287,23 @@ let last (string: String) (characterCount: Int64) : String = /// Returns all but the last characters of , as a Builtin.String. /// If is longer than , returns the empty string. /// If is negative, returns . -let dropLast (string: String) (characterCount: Int64) : String = - if characterCount < 0L then +let dropLast (string: String) (characterCount: Int) : String = + if characterCount < 0I then string else if characterCount > String.length string then "" else String.slice_v0 string - 0L + 0I (String.length string - characterCount) /// Returns all but the first characters of , as a . /// If is longer than , returns the empty string. /// If is negative, returns . -let dropFirst (string: String) (characterCount: Int64) : String = - if characterCount < 0L then +let dropFirst (string: String) (characterCount: Int) : String = + if characterCount < 0I then string else if characterCount > String.length string then "" @@ -318,16 +318,16 @@ let dropFirst (string: String) (characterCount: Int64) : String = let padStart (string: String) (padWith: String) - (goalLength: Int64) + (goalLength: Int) : Result.Result = - if String.length padWith != 1L then + if String.length padWith != 1I then Result.Result.Error $"Expected `padWith` to be 1 character long, but it was `\"{padWith}\"`" else if String.length string >= goalLength then Result.Result.Ok string else let padCount = goalLength - String.length string - let pad = String.repeat padWith (Stdlib.Int.fromInt64 padCount) + let pad = String.repeat padWith padCount Result.Result.Ok(pad ++ string) @@ -338,16 +338,16 @@ let padStart let padEnd (string: String) (padWith: String) - (goalLength: Int64) + (goalLength: Int) : Result.Result = - if String.length padWith != 1L then + if String.length padWith != 1I then Result.Result.Error $"Expected `padWith` to be 1 character long, but it was `\"{padWith}\"`" else if String.length string >= goalLength then Result.Result.Ok string else let padCount = goalLength - String.length string - let pad = String.repeat padWith (Stdlib.Int.fromInt64 padCount) + let pad = String.repeat padWith padCount Result.Result.Ok(string ++ pad) @@ -410,7 +410,7 @@ let fromBlob (blob: Blob) : Option.Option = Builtin.stringFromBlob blob /// Checks if starts with let startsWith (subject: String) (prefix: String) : Bool = - String.slice_v0 subject 0L (String.length prefix) == prefix + String.slice_v0 subject 0I (String.length prefix) == prefix /// Checks if ends with @@ -426,9 +426,9 @@ let endsWith (subject: String) (suffix: String) : Bool = /// measured in UTF-16 code units. Returns {{Nothing}} if does not occur. /// The returned index is **not** suitable for arithmetic with {{first}}, {{dropFirst}}, /// or {{slice}}, which are all EGC-indexed — for that, use {{indexOfEgc}}. -let indexOf (str: String) (searchFor: String) : Option.Option = +let indexOf (str: String) (searchFor: String) : Option.Option = let idx = Builtin.stringIndexOf str searchFor - if idx == -1L then Option.Option.None else Option.Option.Some idx + if idx == -1I then Option.Option.None else Option.Option.Some idx /// Returns {{Just index}} of the first occurrence of in , @@ -436,9 +436,9 @@ let indexOf (str: String) (searchFor: String) : Option.Option = /// {{first}}, and {{dropFirst}}). Returns {{Nothing}} if does not occur. /// The match must begin and end on EGC boundaries — searching for a partial grapheme /// (e.g. a base codepoint inside a ZWJ sequence) will not match. -let indexOfEgc (str: String) (searchFor: String) : Option.Option = +let indexOfEgc (str: String) (searchFor: String) : Option.Option = let idx = Builtin.stringIndexOfEgc str searchFor - if idx == -1L then Option.Option.None else Option.Option.Some idx + if idx == -1I then Option.Option.None else Option.Option.Some idx /// Returns {{Just index}} of the last occurrence of in , @@ -447,10 +447,10 @@ let indexOfEgc (str: String) (searchFor: String) : Option.Option = let lastIndexOf (str: String) (searchFor: String) - : Option.Option = + : Option.Option = let lastIndex = Builtin.stringLastIndexOf str searchFor - if lastIndex == -1L then + if lastIndex == -1I then Option.Option.None else Option.Option.Some(lastIndex) @@ -462,10 +462,10 @@ let lastIndexOf let lastIndexOfEgc (str: String) (searchFor: String) - : Option.Option = + : Option.Option = let lastIndex = Builtin.stringLastIndexOfEgc str searchFor - if lastIndex == -1L then + if lastIndex == -1I then Option.Option.None else Option.Option.Some(lastIndex) diff --git a/packages/darklang/stdlib/valueSearch.dark b/packages/darklang/stdlib/valueSearch.dark index d5ac9f1b4a..5f96f0ff9a 100644 --- a/packages/darklang/stdlib/valueSearch.dark +++ b/packages/darklang/stdlib/valueSearch.dark @@ -9,7 +9,7 @@ type FoundValue<'a> = /// Parse namespace string into parts (non-generic helper) let parseNamespace (targetNamespace: String) : List = - if (Stdlib.String.length targetNamespace) == 0L then + if (Stdlib.String.length targetNamespace) == 0I then [] else Stdlib.String.split targetNamespace "." diff --git a/packages/darklang/tracing/format.dark b/packages/darklang/tracing/format.dark index c13dd756a2..bd034071e3 100644 --- a/packages/darklang/tracing/format.dark +++ b/packages/darklang/tracing/format.dark @@ -10,7 +10,7 @@ module Darklang.Tracing.Format /// width). let padNum (n: Int64) (width: Int64) : String = let s = Stdlib.Int64.toString n - match Stdlib.String.padStart s " " width with + match Stdlib.String.padStart s " " (Stdlib.Int.fromInt64 width) with | Ok r -> r | Error _ -> s diff --git a/packages/darklang/wip/ai/anthropic/integration-tests.dark b/packages/darklang/wip/ai/anthropic/integration-tests.dark index 6af4a37020..5af7e78a21 100644 --- a/packages/darklang/wip/ai/anthropic/integration-tests.dark +++ b/packages/darklang/wip/ai/anthropic/integration-tests.dark @@ -46,7 +46,7 @@ module DirectApiTests = match Chat.Request.send apiKey req with | Ok response -> let text = Response.getText response - if Stdlib.String.length text > 0L then + if Stdlib.String.length text > 0I then TestResult.Pass else TestResult.Fail "Empty response text" @@ -263,7 +263,7 @@ module ServerToolTests = TestResult.Pass else // Code execution might not always be triggered - if Stdlib.String.length text > 0L then + if Stdlib.String.length text > 0I then TestResult.Pass else TestResult.Fail "No tool use and no response" @@ -289,7 +289,7 @@ module ServerToolTests = | Ok response -> let hasToolUse = Response.hasToolUse response let text = Response.getText response - if hasToolUse || Stdlib.String.length text > 0L then + if hasToolUse || Stdlib.String.length text > 0I then TestResult.Pass else TestResult.Fail "No tool use and no response" @@ -320,7 +320,7 @@ module ServerToolTests = | Ok response -> let hasToolUse = Response.hasToolUse response let text = Response.getText response - if hasToolUse || Stdlib.String.length text > 0L then + if hasToolUse || Stdlib.String.length text > 0I then TestResult.Pass else TestResult.Fail "No tool use and no response" @@ -364,7 +364,7 @@ module WebFetchTests = let hasToolUse = Response.hasToolUse response let text = Response.getText response // Either tool was called or we got a text response - if hasToolUse || Stdlib.String.length text > 0L then + if hasToolUse || Stdlib.String.length text > 0I then TestResult.Pass else TestResult.Fail "No tool use and no response" @@ -390,7 +390,7 @@ module WebFetchTests = | Ok response -> // Verify we get a response let hasContent = - Stdlib.String.length (Response.getText response) > 0L || + Stdlib.String.length (Response.getText response) > 0I || Response.hasToolUse response if hasContent then // If citations are present, verify they're typed correctly @@ -404,7 +404,7 @@ module WebFetchTests = match firstCitation with | Some c -> // Check that cited_text field exists (proves it's a typed Citation) - if Stdlib.String.length c.cited_text >= 0L then + if Stdlib.String.length c.cited_text >= 0I then TestResult.Pass else TestResult.Fail "Citation missing cited_text" @@ -455,7 +455,7 @@ module VisionTests = TestResult.Pass else // Any response is acceptable for vision test - if Stdlib.String.length text > 0L then + if Stdlib.String.length text > 0I then TestResult.Pass else TestResult.Fail $"Unexpected response: {text}" @@ -487,7 +487,7 @@ module VisionTests = TestResult.Pass else // URL might not be accessible, any response is ok - if Stdlib.String.length text > 0L then + if Stdlib.String.length text > 0I then TestResult.Pass else TestResult.Fail $"No response: {text}" @@ -523,7 +523,7 @@ module VisionTests = TestResult.Pass else // Any response is acceptable for PDF test - if Stdlib.String.length text > 0L then + if Stdlib.String.length text > 0I then TestResult.Pass else TestResult.Fail $"Empty response: {text}" @@ -553,7 +553,7 @@ module VisionTests = match Chat.Request.send apiKey req with | Ok response -> let text = Response.getText response - if Stdlib.String.length text > 0L then + if Stdlib.String.length text > 0I then TestResult.Pass else TestResult.Fail "Empty response for PDF URL" @@ -592,7 +592,7 @@ module VisionTests = match Chat.Request.send apiKey req with | Ok response -> let text = Response.getText response - if Stdlib.String.length text > 0L then + if Stdlib.String.length text > 0I then TestResult.Pass else TestResult.Fail "Empty response" @@ -643,7 +643,7 @@ module AdaptiveThinkingTests = TestResult.Pass else // Any non-empty response is acceptable - if Stdlib.String.length text > 0L then + if Stdlib.String.length text > 0I then TestResult.Pass else TestResult.Fail $"Unexpected response: {text}" @@ -679,7 +679,7 @@ module ServiceTierTests = match Chat.Request.send apiKey req with | Ok response -> - if Stdlib.String.length (Response.getText response) > 0L then + if Stdlib.String.length (Response.getText response) > 0I then TestResult.Pass else TestResult.Fail "Empty response" @@ -700,7 +700,7 @@ module ServiceTierTests = match Chat.Request.send apiKey req with | Ok response -> - if Stdlib.String.length (Response.getText response) > 0L then + if Stdlib.String.length (Response.getText response) > 0I then TestResult.Pass else TestResult.Fail "Empty response" @@ -732,7 +732,7 @@ module SamplingParameterTests = match Chat.Request.send apiKey req with | Ok response -> - if Stdlib.String.length (Response.getText response) > 0L then + if Stdlib.String.length (Response.getText response) > 0I then TestResult.Pass else TestResult.Fail "Empty response" @@ -753,7 +753,7 @@ module SamplingParameterTests = match Chat.Request.send apiKey req with | Ok response -> - if Stdlib.String.length (Response.getText response) > 0L then + if Stdlib.String.length (Response.getText response) > 0I then TestResult.Pass else TestResult.Fail "Empty response" @@ -775,7 +775,7 @@ module SamplingParameterTests = match Chat.Request.send apiKey req with | Ok response -> - if Stdlib.String.length (Response.getText response) > 0L then + if Stdlib.String.length (Response.getText response) > 0I then TestResult.Pass else TestResult.Fail "Empty response" @@ -808,7 +808,7 @@ module MetadataTests = match Chat.Request.send apiKey req with | Ok response -> - if Stdlib.String.length (Response.getText response) > 0L then + if Stdlib.String.length (Response.getText response) > 0I then TestResult.Pass else TestResult.Fail "Empty response" @@ -1048,8 +1048,8 @@ module PromptCachingTests = TestResult.Pass else // Caching might not always work (depends on API), pass if we got responses - if Stdlib.String.length (Response.getText response1) > 0L && - Stdlib.String.length (Response.getText response2) > 0L then + if Stdlib.String.length (Response.getText response1) > 0I && + Stdlib.String.length (Response.getText response2) > 0I then TestResult.Pass else TestResult.Fail "No cache activity detected and empty responses" diff --git a/packages/stachu/darklangParser.dark b/packages/stachu/darklangParser.dark index 2ab22ff66c..6f53d91d07 100644 --- a/packages/stachu/darklangParser.dark +++ b/packages/stachu/darklangParser.dark @@ -311,7 +311,7 @@ let floatLiteral () : P = let withoutSign = if hasSign then - Stdlib.String.dropFirst s 1L + Stdlib.String.dropFirst s 1I else s diff --git a/packages/stachu/parser.dark b/packages/stachu/parser.dark index 161a21f8dd..892d76e0af 100644 --- a/packages/stachu/parser.dark +++ b/packages/stachu/parser.dark @@ -134,7 +134,7 @@ let charWhere (predicate: Char -> Bool) (description: String) : Parser = match Stdlib.String.head input with | Some c -> if predicate c then - let remaining = Stdlib.String.dropFirst input 1L + let remaining = Stdlib.String.dropFirst input 1I ParseResult.Success(c, remaining) else ParseResult.Failure("Expected: " ++ description) From e80f21fe0498956396dd7cf68bb85cc7de6f9cef Mon Sep 17 00:00:00 2001 From: OceanOak Date: Wed, 17 Jun 2026 11:36:04 +0000 Subject: [PATCH 14/61] Migrate CLI UI numeric layer (terminal dims, layout, selection/cursor state) from Int64 to Int --- .../Builtins/Builtins.Cli/Libs/Terminal.fs | 36 ++-- packages/darklang/cli/apps/editor.dark | 32 ++-- .../darklang/cli/apps/views/ai-chats.dark | 38 ++-- packages/darklang/cli/apps/views/app.dark | 28 +-- .../cli/apps/views/package-stats.dark | 98 +++++----- packages/darklang/cli/core.dark | 44 ++--- .../darklang/cli/outliner/list-picker.dark | 31 ++-- packages/darklang/cli/outliner/main.dark | 28 +-- .../darklang/cli/outliner/outline-editor.dark | 53 +++--- packages/darklang/cli/outliner/tests.dark | 12 +- .../darklang/cli/outliner/text-editor.dark | 38 ++-- packages/darklang/cli/prompt.dark | 94 +++++----- packages/darklang/cli/scm/review/app.dark | 167 +++++++++--------- packages/darklang/cli/scm/review/core.dark | 42 ++--- .../darklang/cli/ui/components/button.dark | 18 +- packages/darklang/cli/ui/components/card.dark | 74 ++++---- .../darklang/cli/ui/components/divider.dark | 12 +- .../darklang/cli/ui/components/dropdown.dark | 82 ++++----- .../darklang/cli/ui/components/forms.dark | 132 +++++++------- .../darklang/cli/ui/components/label.dark | 8 +- .../darklang/cli/ui/components/layout.dark | 56 +++--- .../darklang/cli/ui/components/listview.dark | 36 ++-- .../darklang/cli/ui/components/message.dark | 50 +++--- .../darklang/cli/ui/components/modal.dark | 68 +++---- .../cli/ui/components/navigation.dark | 74 ++++---- .../cli/ui/components/pagination.dark | 118 ++++++------- .../darklang/cli/ui/components/panel.dark | 94 +++++----- .../darklang/cli/ui/components/progress.dark | 26 +-- .../darklang/cli/ui/components/scrollbar.dark | 54 +++--- .../darklang/cli/ui/components/spinner.dark | 20 +-- .../darklang/cli/ui/components/statusbar.dark | 28 +-- .../darklang/cli/ui/components/table.dark | 44 ++--- .../darklang/cli/ui/components/textblock.dark | 14 +- packages/darklang/cli/ui/core/rendering.dark | 42 ++--- packages/darklang/cli/ui/core/types.dark | 8 +- packages/darklang/cli/ui/demo.dark | 50 +++--- packages/darklang/cli/ui/layout.dark | 65 ++++--- packages/darklang/cli/utils/colors.dark | 8 +- packages/darklang/cli/utils/terminal.dark | 16 +- 39 files changed, 967 insertions(+), 971 deletions(-) diff --git a/backend/src/Builtins/Builtins.Cli/Libs/Terminal.fs b/backend/src/Builtins/Builtins.Cli/Libs/Terminal.fs index 44b082f5cf..3d745c0a43 100644 --- a/backend/src/Builtins/Builtins.Cli/Libs/Terminal.fs +++ b/backend/src/Builtins/Builtins.Cli/Libs/Terminal.fs @@ -86,19 +86,19 @@ let fns () : List = [ { name = fn "cliGetTerminalHeight" 0 typeParams = [] parameters = [ Param.make "unit" TUnit "" ] - returnType = TInt64 + returnType = TInt description = "Get the current terminal viewport height in number of lines" fn = (function | _, _, [], [ DUnit ] -> - DInt64( - getDimension - "LINES" - (fun () -> System.Console.WindowHeight) - "lines" - 24 - &cachedHeight - ) + getDimension + "LINES" + (fun () -> System.Console.WindowHeight) + "lines" + 24 + &cachedHeight + |> bigint + |> Dval.int |> Ply | _ -> incorrectArgs ()) sqlSpec = NotQueryable @@ -110,19 +110,19 @@ let fns () : List = { name = fn "cliGetTerminalWidth" 0 typeParams = [] parameters = [ Param.make "unit" TUnit "" ] - returnType = TInt64 + returnType = TInt description = "Get the current terminal viewport width in number of columns" fn = (function | _, _, [], [ DUnit ] -> - DInt64( - getDimension - "COLUMNS" - (fun () -> System.Console.WindowWidth) - "cols" - 80 - &cachedWidth - ) + getDimension + "COLUMNS" + (fun () -> System.Console.WindowWidth) + "cols" + 80 + &cachedWidth + |> bigint + |> Dval.int |> Ply | _ -> incorrectArgs ()) sqlSpec = NotQueryable diff --git a/packages/darklang/cli/apps/editor.dark b/packages/darklang/cli/apps/editor.dark index 467e99b043..ce97213c74 100644 --- a/packages/darklang/cli/apps/editor.dark +++ b/packages/darklang/cli/apps/editor.dark @@ -7,7 +7,7 @@ module Darklang.Cli.Apps.Editor type State = { /// the full catalog, ordered daemons-first (so selection indices line up with the grouped display) apps: List - selected: Int64 + selected: Int /// last action feedback, shown near the footer message: String /// when true, show the selected app's detail (slug + target, and for daemons recent logs) below the list @@ -21,20 +21,20 @@ type Action = let selectedApp (state: State) : Stdlib.Option.Option = - Stdlib.List.getAt state.apps (Stdlib.Int.fromInt64 state.selected) + Stdlib.List.getAt state.apps state.selected // ── rendering ── // `s` cut to `maxLen` display columns, with a trailing ellipsis when it doesn't fit. -let private truncate (s: String) (maxLen: Int64) : String = - if (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length s))) <= maxLen then +let private truncate (s: String) (maxLen: Int) : String = + if (Stdlib.String.length s) <= maxLen then s else - (Stdlib.String.slice s 0I (Stdlib.Int.fromInt64 (maxLen - 1L))) ++ "…" + (Stdlib.String.slice s 0I (maxLen - 1I)) ++ "…" -let private appRow (state: State) (idx: Int64) (app: Model.App) : String = +let private appRow (state: State) (idx: Int) (app: Model.App) : String = let pointer = if idx == state.selected then Colors.colorize (Colors.bold ++ Colors.cyan) "▸ " @@ -64,13 +64,13 @@ let private appRow (state: State) (idx: Int64) (app: Model.App) : String = else if isRunning then Colors.colorize Colors.green rawState else if isStale then Colors.colorize Colors.yellow rawState else Colors.dimText rawState - let stateWidth = if rawState == "" then 0L else (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length rawState))) + 3L + let stateWidth = if rawState == "" then 0I else (Stdlib.String.length rawState) + 3I let name = Stdlib.Result.withDefault (Stdlib.String.padEnd app.name " " 26I) app.name let w = Darklang.Cli.Terminal.getWidth () - let width = if w <= 0L then 80L else w + let width = if w <= 0I then 80I else w // prefix (▸ + install glyph + run glyph + space) = 5 cols, name column = 26, gap before description = 2 - let descBudget = Stdlib.Int64.max (width - 5L - 26L - 2L - stateWidth) 8L + let descBudget = Stdlib.Int.max (width - 5I - 26I - 2I - stateWidth) 8I let desc = truncate app.description descBudget let trailing = if stateText == "" then "" else " " ++ stateText @@ -79,7 +79,7 @@ let private appRow (state: State) (idx: Int64) (app: Model.App) : String = // A titled group of rows (nothing if the group is empty). `rows` carries each app's catalog index so the // selection highlight stays correct across the split. -let private printSection (state: State) (title: String) (rows: List<(Int64 * Model.App)>) : Unit = +let private printSection (state: State) (title: String) (rows: List<(Int * Model.App)>) : Unit = if Stdlib.List.isEmpty rows then () else @@ -100,7 +100,7 @@ let render (state: State) : Unit = if Stdlib.List.isEmpty state.apps then Stdlib.printLine (Colors.dimText " No apps in the catalog.") else - let indexed = state.apps |> Stdlib.List.indexedMap (fun i a -> (Builtin.unwrap (Stdlib.Int.toInt64 i), a)) + let indexed = state.apps |> Stdlib.List.indexedMap (fun i a -> (i, a)) let daemons = indexed @@ -225,15 +225,15 @@ let handleKey (_modifiers: Stdlib.Cli.Stdin.Modifiers.Modifiers) (keyChar: Stdlib.Option.Option) : Action = - let count = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length state.apps))) + let count = Stdlib.List.length state.apps match key with | Escape -> Action.Exit state | UpArrow -> - let s = if state.selected > 0L then state.selected - 1L else 0L + let s = if state.selected > 0I then state.selected - 1I else 0I Action.Continue ({ state with selected = s }) | DownArrow -> - let maxIdx = count - 1L - let s = if state.selected < maxIdx then state.selected + 1L else maxIdx + let maxIdx = count - 1I + let s = if state.selected < maxIdx then state.selected + 1I else maxIdx Action.Continue ({ state with selected = s }) | Enter -> activate state | _ -> @@ -272,7 +272,7 @@ let launch (cliState: Cli.AppState) : Cli.AppState = let state = Editor.State { apps = ordered - selected = 0L + selected = 0I message = "" showDetail = false } diff --git a/packages/darklang/cli/apps/views/ai-chats.dark b/packages/darklang/cli/apps/views/ai-chats.dark index 24607a7d0a..8f362b4185 100644 --- a/packages/darklang/cli/apps/views/ai-chats.dark +++ b/packages/darklang/cli/apps/views/ai-chats.dark @@ -80,36 +80,36 @@ let statusBadge (status: String) : String = let hr () : String = let cols = Darklang.Cli.Terminal.getWidth () - Darklang.Cli.Colors.dimText (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 cols)) + Darklang.Cli.Colors.dimText (Stdlib.String.repeat "─" cols) let thinHr () : String = let cols = Darklang.Cli.Terminal.getWidth () - Darklang.Cli.Colors.dimText (Stdlib.String.repeat "╌" (Stdlib.Int.fromInt64 cols)) + Darklang.Cli.Colors.dimText (Stdlib.String.repeat "╌" cols) -let padRight (s: String) (width: Int64) : String = - let len = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length s)) +let padRight (s: String) (width: Int) : String = + let len = Stdlib.String.length s if len >= width then - Stdlib.String.slice s 0I (Stdlib.Int.fromInt64 width) + Stdlib.String.slice s 0I width else - s ++ (Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (width - len))) + s ++ (Stdlib.String.repeat " " (width - len)) let renderThread (thread: Thread) : Unit = let idStr = Darklang.Cli.Colors.colorize (Darklang.Cli.Colors.bold ++ Darklang.Cli.Colors.cyan) ("#" ++ Stdlib.Int64.toString thread.id) let badge = statusBadge thread.status let topicStr = if thread.status == "done" then - Darklang.Cli.Colors.colorize (Darklang.Cli.Colors.bold ++ Darklang.Cli.Colors.dim) (padRight thread.topic 40L) + Darklang.Cli.Colors.colorize (Darklang.Cli.Colors.bold ++ Darklang.Cli.Colors.dim) (padRight thread.topic 40I) else - Darklang.Cli.Colors.boldText (padRight thread.topic 40L) - let branchStr = Darklang.Cli.Colors.dimText (padRight thread.branch 10L) + Darklang.Cli.Colors.boldText (padRight thread.topic 40I) + let branchStr = Darklang.Cli.Colors.dimText (padRight thread.branch 10I) let costColor = match thread.status with | "running" -> Darklang.Cli.Colors.green | "review" -> Darklang.Cli.Colors.yellow | _ -> Darklang.Cli.Colors.dim - let costStr = Darklang.Cli.Colors.colorize costColor (padRight thread.cost 10L) - let tokensStr = Darklang.Cli.Colors.dimText (padRight thread.tokens 10L) - let timeStr = Darklang.Cli.Colors.dimText (padRight thread.time 8L) + let costStr = Darklang.Cli.Colors.colorize costColor (padRight thread.cost 10I) + let tokensStr = Darklang.Cli.Colors.dimText (padRight thread.tokens 10I) + let timeStr = Darklang.Cli.Colors.dimText (padRight thread.time 8I) Stdlib.printLine (" " ++ idStr ++ " " ++ badge ++ " " ++ topicStr ++ " " ++ branchStr ++ " " ++ costStr ++ " " ++ tokensStr ++ " " ++ timeStr) @@ -148,19 +148,19 @@ let render () : Unit = // Column headers let headerLine = " " - ++ Darklang.Cli.Colors.colorize (Darklang.Cli.Colors.bold ++ Darklang.Cli.Colors.dim) (padRight "ID" 4L) + ++ Darklang.Cli.Colors.colorize (Darklang.Cli.Colors.bold ++ Darklang.Cli.Colors.dim) (padRight "ID" 4I) ++ " " - ++ Darklang.Cli.Colors.colorize (Darklang.Cli.Colors.bold ++ Darklang.Cli.Colors.dim) (padRight "STATUS" 10L) + ++ Darklang.Cli.Colors.colorize (Darklang.Cli.Colors.bold ++ Darklang.Cli.Colors.dim) (padRight "STATUS" 10I) ++ " " - ++ Darklang.Cli.Colors.colorize (Darklang.Cli.Colors.bold ++ Darklang.Cli.Colors.dim) (padRight "TOPIC" 40L) + ++ Darklang.Cli.Colors.colorize (Darklang.Cli.Colors.bold ++ Darklang.Cli.Colors.dim) (padRight "TOPIC" 40I) ++ " " - ++ Darklang.Cli.Colors.colorize (Darklang.Cli.Colors.bold ++ Darklang.Cli.Colors.dim) (padRight "BRANCH" 10L) + ++ Darklang.Cli.Colors.colorize (Darklang.Cli.Colors.bold ++ Darklang.Cli.Colors.dim) (padRight "BRANCH" 10I) ++ " " - ++ Darklang.Cli.Colors.colorize (Darklang.Cli.Colors.bold ++ Darklang.Cli.Colors.dim) (padRight "COST" 10L) + ++ Darklang.Cli.Colors.colorize (Darklang.Cli.Colors.bold ++ Darklang.Cli.Colors.dim) (padRight "COST" 10I) ++ " " - ++ Darklang.Cli.Colors.colorize (Darklang.Cli.Colors.bold ++ Darklang.Cli.Colors.dim) (padRight "TOKENS" 10L) + ++ Darklang.Cli.Colors.colorize (Darklang.Cli.Colors.bold ++ Darklang.Cli.Colors.dim) (padRight "TOKENS" 10I) ++ " " - ++ Darklang.Cli.Colors.colorize (Darklang.Cli.Colors.bold ++ Darklang.Cli.Colors.dim) (padRight "TIME" 8L) + ++ Darklang.Cli.Colors.colorize (Darklang.Cli.Colors.bold ++ Darklang.Cli.Colors.dim) (padRight "TIME" 8I) Stdlib.printLine headerLine Stdlib.printLine (hr ()) diff --git a/packages/darklang/cli/apps/views/app.dark b/packages/darklang/cli/apps/views/app.dark index 7d80c7540a..3a98e07268 100644 --- a/packages/darklang/cli/apps/views/app.dark +++ b/packages/darklang/cli/apps/views/app.dark @@ -1,8 +1,8 @@ module Darklang.Cli.Apps.Views.App type Screen = - | ViewList of selected: Int64 - | ViewDisplay of viewIndex: Int64 + | ViewList of selected: Int + | ViewDisplay of viewIndex: Int type State = { screen: Screen @@ -11,7 +11,7 @@ type State = // ── Rendering ── -let renderViewList (state: State) (selected: Int64) : Unit = +let renderViewList (state: State) (selected: Int) : Unit = let termWidth = Darklang.Cli.Terminal.getWidth () // Build entire output as a single string to avoid flicker @@ -22,12 +22,12 @@ let renderViewList (state: State) (selected: Int64) : Unit = ++ " " ++ Darklang.Cli.Colors.dimText ("— " ++ Stdlib.Int.toString (Stdlib.List.length state.views) ++ " available") ++ "\n\n" - ++ Darklang.Cli.Colors.dimText (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 termWidth)) + ++ Darklang.Cli.Colors.dimText (Stdlib.String.repeat "─" termWidth) ++ "\n\n" let viewLines = state.views - |> Stdlib.List.indexedMap (fun idx view -> (Builtin.unwrap (Stdlib.Int.toInt64 idx), view)) + |> Stdlib.List.indexedMap (fun idx view -> (idx, view)) |> Stdlib.List.map (fun pair -> let (idx, view) = pair let isSelected = idx == selected @@ -48,7 +48,7 @@ let renderViewList (state: State) (selected: Int64) : Unit = let footer = "\n" - ++ Darklang.Cli.Colors.dimText (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 termWidth)) + ++ Darklang.Cli.Colors.dimText (Stdlib.String.repeat "─" termWidth) ++ "\n\n" ++ " " ++ Darklang.Cli.Colors.dimText "↑↓" @@ -63,11 +63,11 @@ let renderViewList (state: State) (selected: Int64) : Unit = Stdlib.print ("\u001b[?25l" ++ Darklang.Cli.Terminal.Display.clearScreen ++ header ++ viewLines ++ footer ++ "\u001b[?25h") -let renderViewDisplay (state: State) (viewIndex: Int64) : Unit = +let renderViewDisplay (state: State) (viewIndex: Int) : Unit = // Hide cursor + clear in one shot, then render view Stdlib.print ("\u001b[?25l" ++ Darklang.Cli.Terminal.Display.clearScreen) - match Stdlib.List.getAt state.views (Stdlib.Int.fromInt64 viewIndex) with + match Stdlib.List.getAt state.views viewIndex with | Some view -> view.render () | None -> Stdlib.printLine (Darklang.Cli.Colors.error "View not found") @@ -99,15 +99,15 @@ let handleKey : Action = match state.screen with | ViewList selected -> - let viewCount = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length state.views))) + let viewCount = Stdlib.List.length state.views match key with | Escape -> Action.Exit state | UpArrow -> - let newIdx = if selected > 0L then selected - 1L else selected + let newIdx = if selected > 0I then selected - 1I else selected Action.Continue ({ state with screen = Screen.ViewList newIdx }) | DownArrow -> - let maxIdx = viewCount - 1L - let newIdx = if selected < maxIdx then selected + 1L else selected + let maxIdx = viewCount - 1I + let newIdx = if selected < maxIdx then selected + 1I else selected Action.Continue ({ state with screen = Screen.ViewList newIdx }) | Enter -> Action.Continue ({ state with screen = Screen.ViewDisplay selected }) @@ -115,7 +115,7 @@ let handleKey | ViewDisplay _viewIndex -> match key with - | Escape -> Action.Continue ({ state with screen = Screen.ViewList 0L }) + | Escape -> Action.Continue ({ state with screen = Screen.ViewList 0I }) | _ -> Action.Continue state @@ -174,7 +174,7 @@ let execute (cliState: Darklang.Cli.AppState) (args: List) : Darklang.Cl Stdlib.printLine (Darklang.Cli.Colors.dimText "No views available.") cliState | _ -> - let state = State { screen = Screen.ViewList 0L; views = views } + let state = State { screen = Screen.ViewList 0I; views = views } let app = makeSubApp state { cliState with currentPage = Darklang.Cli.Page.SubApp app diff --git a/packages/darklang/cli/apps/views/package-stats.dark b/packages/darklang/cli/apps/views/package-stats.dark index cd4586eb7e..64ad0fbdaa 100644 --- a/packages/darklang/cli/apps/views/package-stats.dark +++ b/packages/darklang/cli/apps/views/package-stats.dark @@ -3,51 +3,51 @@ module Darklang.Cli.Apps.Views.PackageStats /// Demo data for package statistics type ModuleStats = { name: String - fnCount: Int64 - typeCount: Int64 - valueCount: Int64 - submodules: Int64 } + fnCount: Int + typeCount: Int + valueCount: Int + submodules: Int } let demoStats () : List = - [ ModuleStats { name = "Darklang.Stdlib"; fnCount = 247L; typeCount = 42L; valueCount = 18L; submodules = 23L } - ModuleStats { name = "Darklang.Cli"; fnCount = 89L; typeCount = 31L; valueCount = 12L; submodules = 15L } - ModuleStats { name = "Darklang.LanguageTools"; fnCount = 156L; typeCount = 67L; valueCount = 8L; submodules = 19L } - ModuleStats { name = "Darklang.SCM"; fnCount = 43L; typeCount = 14L; valueCount = 5L; submodules = 7L } - ModuleStats { name = "Darklang.PrettyPrinter"; fnCount = 38L; typeCount = 9L; valueCount = 3L; submodules = 4L } - ModuleStats { name = "Darklang.LLM"; fnCount = 22L; typeCount = 11L; valueCount = 6L; submodules = 3L } - ModuleStats { name = "Darklang.Test"; fnCount = 34L; typeCount = 8L; valueCount = 2L; submodules = 5L } ] + [ ModuleStats { name = "Darklang.Stdlib"; fnCount = 247I; typeCount = 42I; valueCount = 18I; submodules = 23I } + ModuleStats { name = "Darklang.Cli"; fnCount = 89I; typeCount = 31I; valueCount = 12I; submodules = 15I } + ModuleStats { name = "Darklang.LanguageTools"; fnCount = 156I; typeCount = 67I; valueCount = 8I; submodules = 19I } + ModuleStats { name = "Darklang.SCM"; fnCount = 43I; typeCount = 14I; valueCount = 5I; submodules = 7I } + ModuleStats { name = "Darklang.PrettyPrinter"; fnCount = 38I; typeCount = 9I; valueCount = 3I; submodules = 4I } + ModuleStats { name = "Darklang.LLM"; fnCount = 22I; typeCount = 11I; valueCount = 6I; submodules = 3I } + ModuleStats { name = "Darklang.Test"; fnCount = 34I; typeCount = 8I; valueCount = 2I; submodules = 5I } ] -let padRight (s: String) (width: Int64) : String = - let len = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length s)) +let padRight (s: String) (width: Int) : String = + let len = Stdlib.String.length s if len >= width then - Stdlib.String.slice s 0I (Stdlib.Int.fromInt64 width) + Stdlib.String.slice s 0I (width) else - s ++ (Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (width - len))) + s ++ (Stdlib.String.repeat " " ((width - len))) -let padLeft (s: String) (width: Int64) : String = - let len = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length s)) +let padLeft (s: String) (width: Int) : String = + let len = Stdlib.String.length s if len >= width then - Stdlib.String.slice s 0I (Stdlib.Int.fromInt64 width) + Stdlib.String.slice s 0I (width) else - (Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (width - len))) ++ s + (Stdlib.String.repeat " " ((width - len))) ++ s -let bar (value: Int64) (maxVal: Int64) (width: Int64) (color: String) : String = +let bar (value: Int) (maxVal: Int) (width: Int) (color: String) : String = let barLen = - if maxVal == 0L then 0L - else Stdlib.Int64.divide (value * width) maxVal - let filled = Stdlib.String.repeat "█" (Stdlib.Int.fromInt64 barLen) - let empty = Stdlib.String.repeat "░" (Stdlib.Int.fromInt64 (width - barLen)) + if maxVal == 0I then 0I + else Stdlib.Int.divide (value * width) maxVal + let filled = Stdlib.String.repeat "█" (barLen) + let empty = Stdlib.String.repeat "░" ((width - barLen)) (Darklang.Cli.Colors.colorize color filled) ++ (Darklang.Cli.Colors.dimText empty) let render () : Unit = let stats = demoStats () - let totalFns = Stdlib.List.fold stats 0L (fun acc s -> acc + s.fnCount) - let totalTypes = Stdlib.List.fold stats 0L (fun acc s -> acc + s.typeCount) - let totalValues = Stdlib.List.fold stats 0L (fun acc s -> acc + s.valueCount) - let totalModules = Stdlib.List.fold stats 0L (fun acc s -> acc + s.submodules) + let totalFns = Stdlib.List.fold stats 0I (fun acc s -> acc + s.fnCount) + let totalTypes = Stdlib.List.fold stats 0I (fun acc s -> acc + s.typeCount) + let totalValues = Stdlib.List.fold stats 0I (fun acc s -> acc + s.valueCount) + let totalModules = Stdlib.List.fold stats 0I (fun acc s -> acc + s.submodules) // Header Stdlib.printLine "" @@ -61,60 +61,60 @@ let render () : Unit = // Summary cards let summaryLine = " " - ++ Darklang.Cli.Colors.colorize (Darklang.Cli.Colors.bgGreen ++ Darklang.Cli.Colors.black ++ Darklang.Cli.Colors.bold) (" " ++ Stdlib.Int64.toString totalFns ++ " fns ") + ++ Darklang.Cli.Colors.colorize (Darklang.Cli.Colors.bgGreen ++ Darklang.Cli.Colors.black ++ Darklang.Cli.Colors.bold) (" " ++ Stdlib.Int.toString totalFns ++ " fns ") ++ " " - ++ Darklang.Cli.Colors.colorize (Darklang.Cli.Colors.bgBlue ++ Darklang.Cli.Colors.white ++ Darklang.Cli.Colors.bold) (" " ++ Stdlib.Int64.toString totalTypes ++ " types ") + ++ Darklang.Cli.Colors.colorize (Darklang.Cli.Colors.bgBlue ++ Darklang.Cli.Colors.white ++ Darklang.Cli.Colors.bold) (" " ++ Stdlib.Int.toString totalTypes ++ " types ") ++ " " - ++ Darklang.Cli.Colors.colorize (Darklang.Cli.Colors.bgMagenta ++ Darklang.Cli.Colors.white ++ Darklang.Cli.Colors.bold) (" " ++ Stdlib.Int64.toString totalValues ++ " values ") + ++ Darklang.Cli.Colors.colorize (Darklang.Cli.Colors.bgMagenta ++ Darklang.Cli.Colors.white ++ Darklang.Cli.Colors.bold) (" " ++ Stdlib.Int.toString totalValues ++ " values ") ++ " " - ++ Darklang.Cli.Colors.colorize (Darklang.Cli.Colors.grayBg ++ Darklang.Cli.Colors.white ++ Darklang.Cli.Colors.bold) (" " ++ Stdlib.Int64.toString totalModules ++ " modules ") + ++ Darklang.Cli.Colors.colorize (Darklang.Cli.Colors.grayBg ++ Darklang.Cli.Colors.white ++ Darklang.Cli.Colors.bold) (" " ++ Stdlib.Int.toString totalModules ++ " modules ") Stdlib.printLine summaryLine Stdlib.printLine "" // Table header let termCols = Darklang.Cli.Terminal.getWidth () - Stdlib.printLine (Darklang.Cli.Colors.dimText (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 termCols))) + Stdlib.printLine (Darklang.Cli.Colors.dimText (Stdlib.String.repeat "─" termCols)) let boldDim = Darklang.Cli.Colors.bold ++ Darklang.Cli.Colors.dim let headerLine = " " - ++ Darklang.Cli.Colors.colorize boldDim (padRight "MODULE" 30L) + ++ Darklang.Cli.Colors.colorize boldDim (padRight "MODULE" 30I) ++ " " - ++ Darklang.Cli.Colors.colorize boldDim (padLeft "FNS" 6L) + ++ Darklang.Cli.Colors.colorize boldDim (padLeft "FNS" 6I) ++ " " - ++ Darklang.Cli.Colors.colorize boldDim (padLeft "TYPES" 6L) + ++ Darklang.Cli.Colors.colorize boldDim (padLeft "TYPES" 6I) ++ " " - ++ Darklang.Cli.Colors.colorize boldDim (padLeft "VALS" 6L) + ++ Darklang.Cli.Colors.colorize boldDim (padLeft "VALS" 6I) ++ " " - ++ Darklang.Cli.Colors.colorize boldDim (padLeft "MODS" 6L) + ++ Darklang.Cli.Colors.colorize boldDim (padLeft "MODS" 6I) ++ " " ++ Darklang.Cli.Colors.colorize boldDim "FUNCTIONS" Stdlib.printLine headerLine - Stdlib.printLine (Darklang.Cli.Colors.dimText (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 termCols))) + Stdlib.printLine (Darklang.Cli.Colors.dimText (Stdlib.String.repeat "─" termCols)) let maxFns = stats |> Stdlib.List.map (fun s -> s.fnCount) - |> Stdlib.List.fold 0L (fun acc n -> if n > acc then n else acc) + |> Stdlib.List.fold 0I (fun acc n -> if n > acc then n else acc) // Rows stats |> Stdlib.List.iter (fun s -> let total = s.fnCount + s.typeCount + s.valueCount let nameStr = - if total > 100L then - Darklang.Cli.Colors.boldText (padRight s.name 30L) + if total > 100I then + Darklang.Cli.Colors.boldText (padRight s.name 30I) else - padRight s.name 30L - let fnStr = Darklang.Cli.Colors.colorize Darklang.Cli.Colors.green (padLeft (Stdlib.Int64.toString s.fnCount) 6L) - let typeStr = Darklang.Cli.Colors.colorize Darklang.Cli.Colors.blue (padLeft (Stdlib.Int64.toString s.typeCount) 6L) - let valStr = Darklang.Cli.Colors.colorize Darklang.Cli.Colors.magenta (padLeft (Stdlib.Int64.toString s.valueCount) 6L) - let modStr = Darklang.Cli.Colors.dimText (padLeft (Stdlib.Int64.toString s.submodules) 6L) - let barStr = bar s.fnCount maxFns 20L Darklang.Cli.Colors.green + padRight s.name 30I + let fnStr = Darklang.Cli.Colors.colorize Darklang.Cli.Colors.green (padLeft (Stdlib.Int.toString s.fnCount) 6I) + let typeStr = Darklang.Cli.Colors.colorize Darklang.Cli.Colors.blue (padLeft (Stdlib.Int.toString s.typeCount) 6I) + let valStr = Darklang.Cli.Colors.colorize Darklang.Cli.Colors.magenta (padLeft (Stdlib.Int.toString s.valueCount) 6I) + let modStr = Darklang.Cli.Colors.dimText (padLeft (Stdlib.Int.toString s.submodules) 6I) + let barStr = bar s.fnCount maxFns 20I Darklang.Cli.Colors.green Stdlib.printLine (" " ++ nameStr ++ " " ++ fnStr ++ " " ++ typeStr ++ " " ++ valStr ++ " " ++ modStr ++ " " ++ barStr)) - Stdlib.printLine (Darklang.Cli.Colors.dimText (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 termCols))) + Stdlib.printLine (Darklang.Cli.Colors.dimText (Stdlib.String.repeat "─" termCols)) Stdlib.printLine "" // Footer diff --git a/packages/darklang/cli/core.dark b/packages/darklang/cli/core.dark index 1ab51fb7be..68433744ba 100644 --- a/packages/darklang/cli/core.dark +++ b/packages/darklang/cli/core.dark @@ -28,7 +28,7 @@ type AppState = accountID: Stdlib.Option.Option accountName: String /// How many terminal rows the prompt used last frame - previousRenderedRows: Int64 + previousRenderedRows: Int /// True when invoked from the command line (not the interactive REPL) nonInteractive: Bool /// Cached completion hint — skip recompute when prompt text unchanged @@ -104,7 +104,7 @@ let initState () : AppState = currentBranchId = branchId accountID = accountID accountName = accountName - previousRenderedRows = 0L + previousRenderedRows = 0I nonInteractive = false cachedHintInput = "" cachedHintValue = "" @@ -170,7 +170,7 @@ module StatusBar = let init () : Unit = let terminalHeight = Terminal.getHeight () // Set scroll region to all rows except the last one - Stdlib.print (Colors.setScrollRegion 1L (terminalHeight - 1L)) + Stdlib.print (Colors.setScrollRegion 1I (terminalHeight - 1I)) /// Build the status bar string for the given state let build (state: AppState) : String = @@ -184,12 +184,12 @@ module StatusBar = let branchPart = Colors.colorize (Colors.grayBg ++ Colors.white) branchText - let leftLen = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length leftText + Stdlib.String.length branchText)) + let leftLen = Stdlib.String.length leftText + Stdlib.String.length branchText let paddingLen = terminalWidth - leftLen let padding = - if paddingLen > 0L then - Colors.colorize Colors.grayBg (Stdlib.String.repeat " " (Stdlib.Int.fromInt64 paddingLen)) + if paddingLen > 0I then + Colors.colorize Colors.grayBg (Stdlib.String.repeat " " paddingLen) else "" @@ -200,7 +200,7 @@ module StatusBar = let terminalHeight = Terminal.getHeight () Stdlib.print (Colors.saveCursor - ++ Colors.moveCursorTo terminalHeight 1L + ++ Colors.moveCursorTo terminalHeight 1I ++ statusLine ++ Colors.restoreCursor) @@ -211,7 +211,7 @@ module StatusBar = Stdlib.print (Colors.saveCursor ++ Colors.resetScrollRegion - ++ Colors.moveCursorTo terminalHeight 1L + ++ Colors.moveCursorTo terminalHeight 1I ++ Colors.clearLine ++ Colors.restoreCursor) @@ -705,7 +705,7 @@ let runInteractiveLoop (state: AppState) : Int64 = // Clear status bar and prompt line before exiting StatusBar.clear () // Move to column 1, clear entire line, then newline for clean shell prompt - Stdlib.print (Colors.moveCursorToColumn 1L ++ "\u001b[2K" ++ "\n") + Stdlib.print (Colors.moveCursorToColumn 1I ++ "\u001b[2K" ++ "\n") 0L else let tLoopStart = if state.telemetryEnabled then Telemetry.now () else 0L @@ -733,13 +733,13 @@ let runInteractiveLoop (state: AppState) : Int64 = // Fall back to 80 if the size query returns 0 (can happen at startup) — never divide by 0 below. let terminalWidth = let w = Terminal.getWidth () - if w <= 0L then 80L else w + if w <= 0I then 80I else w // Visual length (0-based char count; inputStartColumn is 1-based so subtract 1) let visualLength = - (inputStartColumn - 1L) + (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length state.prompt.text))) + (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length hint))) + (inputStartColumn - 1I) + (Stdlib.String.length state.prompt.text) + (Stdlib.String.length hint) let renderedRows = - if visualLength <= terminalWidth then 1L - else (Stdlib.Int64.divide (visualLength - 1L) terminalWidth) + 1L + if visualLength <= terminalWidth then 1I + else (Stdlib.Int.divide (visualLength - 1I) terminalWidth) + 1I // Display current page let tRender = if state.telemetryEnabled then Telemetry.now () else 0L @@ -751,25 +751,25 @@ let runInteractiveLoop (state: AppState) : Int64 = // Move up to prompt start if previous render occupied multiple rows // Skip on full redraw — cursor is already positioned after command output if Stdlib.Bool.not state.needsFullRedraw then - if state.previousRenderedRows > 1L then - Stdlib.print (Colors.moveCursorUp (state.previousRenderedRows - 1L)) + if state.previousRenderedRows > 1I then + Stdlib.print (Colors.moveCursorUp (state.previousRenderedRows - 1I)) Stdlib.print Colors.carriageReturn Stdlib.print promptOutput Stdlib.print "\u001b[J" // Clear any leftover rows // Position cursor at correct location within user input - let absoluteCursorPos = (inputStartColumn - 1L) + state.prompt.cursorPosition - if renderedRows > 1L then - let cursorRow = Stdlib.Int64.divide absoluteCursorPos terminalWidth - let cursorCol = (absoluteCursorPos % terminalWidth) + 1L - let textEndRow = renderedRows - 1L + let absoluteCursorPos = (inputStartColumn - 1I) + state.prompt.cursorPosition + if renderedRows > 1I then + let cursorRow = Stdlib.Int.divide absoluteCursorPos terminalWidth + let cursorCol = (absoluteCursorPos % terminalWidth) + 1I + let textEndRow = renderedRows - 1I let rowDiff = textEndRow - cursorRow - if rowDiff > 0L then + if rowDiff > 0I then Stdlib.print (Colors.moveCursorUp rowDiff) Stdlib.print (Colors.moveCursorToColumn cursorCol) else - Stdlib.print (Colors.moveCursorToColumn (absoluteCursorPos + 1L)) + Stdlib.print (Colors.moveCursorToColumn (absoluteCursorPos + 1I)) Stdlib.print "\u001b[?25h" // Show cursor diff --git a/packages/darklang/cli/outliner/list-picker.dark b/packages/darklang/cli/outliner/list-picker.dark index 1c601a3b0f..e9d803184d 100644 --- a/packages/darklang/cli/outliner/list-picker.dark +++ b/packages/darklang/cli/outliner/list-picker.dark @@ -2,7 +2,7 @@ module Darklang.Cli.Outliner.ListPicker type State<'item> = { items: List<'item> - selected: Int64 + selected: Int label: 'item -> String } type Result<'item> = @@ -11,7 +11,7 @@ type Result<'item> = | Cancelled let make (items: List<'item>) (label: 'item -> String) : State<'item> = - State { items = items; selected = 0L; label = label } + State { items = items; selected = 0I; label = label } let handleKey (state: State<'item>) @@ -24,17 +24,17 @@ let handleKey | Escape -> Result.Cancelled | UpArrow -> let newIdx = - if state.selected > 0L then state.selected - 1L + if state.selected > 0I then state.selected - 1I else state.selected Result.Browsing ({ state with selected = newIdx }) | DownArrow -> - let maxIdx = (Builtin.unwrap (Stdlib.Int.toInt64 itemCount)) - 1L + let maxIdx = itemCount - 1I let newIdx = - if state.selected < maxIdx then state.selected + 1L + if state.selected < maxIdx then state.selected + 1I else state.selected Result.Browsing ({ state with selected = newIdx }) | Enter -> - match Stdlib.List.getAt state.items (Stdlib.Int.fromInt64 state.selected) with + match Stdlib.List.getAt state.items state.selected with | Some item -> Result.Selected item | None -> Result.Cancelled | _ -> Result.Browsing state @@ -42,22 +42,23 @@ let handleKey /// Render the list into a layout region. let renderInRegion (state: State<'item>) (region: Darklang.Cli.UI.Layout.Region) : Unit = let itemCount = Stdlib.List.length state.items + let selectedIdx = state.selected let scrollOffset = - if state.selected >= region.rows then + if selectedIdx >= region.rows then Darklang.Cli.Terminal.clampScrollOffset - (state.selected - region.rows + 1L) - (Builtin.unwrap (Stdlib.Int.toInt64 itemCount)) + (selectedIdx - region.rows + 1I) + itemCount region.rows else - 0L + 0I state.items - |> Stdlib.List.indexedMap (fun idx item -> ((Builtin.unwrap (Stdlib.Int.toInt64 idx)), item)) - |> Stdlib.List.drop (Stdlib.Int.fromInt64 scrollOffset) - |> Stdlib.List.take (Stdlib.Int.fromInt64 region.rows) + |> Stdlib.List.indexedMap (fun idx item -> (idx, item)) + |> Stdlib.List.drop scrollOffset + |> Stdlib.List.take region.rows |> Stdlib.List.iter (fun pair -> let (idx, item) = pair let row = idx - scrollOffset - let isSelected = idx == state.selected + let isSelected = idx == selectedIdx let text = state.label item let prefix = if isSelected then ">" else " " let line = $" {prefix} {text}" @@ -66,4 +67,4 @@ let renderInRegion (state: State<'item>) (region: Darklang.Cli.UI.Layout.Region) Darklang.Cli.Colors.colorize Darklang.Cli.Colors.selection line else line - Darklang.Cli.UI.Layout.printAt region row 0L styled) + Darklang.Cli.UI.Layout.printAt region row 0I styled) diff --git a/packages/darklang/cli/outliner/main.dark b/packages/darklang/cli/outliner/main.dark index 0ced905f03..398e835be7 100644 --- a/packages/darklang/cli/outliner/main.dark +++ b/packages/darklang/cli/outliner/main.dark @@ -110,17 +110,17 @@ let handleDocPickerKey match keyChar with | Some "n" -> KeyResult.Save (createDocument state "Untitled") | Some "d" -> - match Stdlib.List.getAt picker.items (Stdlib.Int.fromInt64 picker.selected) with + match Stdlib.List.getAt picker.items picker.selected with | Some doc -> KeyResult.Save (deleteDocument state doc.id) | None -> KeyResult.Continue state | Some "r" -> - match Stdlib.List.getAt picker.items (Stdlib.Int.fromInt64 picker.selected) with + match Stdlib.List.getAt picker.items picker.selected with | Some doc -> let te = TextEditor.fromText doc.title KeyResult.Continue ({ state with screen = Screen.DocRenaming (doc.id, picker, te) }) | None -> KeyResult.Continue state | Some "e" -> - match Stdlib.List.getAt picker.items (Stdlib.Int.fromInt64 picker.selected) with + match Stdlib.List.getAt picker.items picker.selected with | Some doc -> KeyResult.Continue ({ state with @@ -210,15 +210,15 @@ let handleKey let renderTitleBar (titleText: String) (modeText: String) (modeColor: String) (region: Darklang.Cli.UI.Layout.Region) : Unit = let title = Darklang.Cli.Colors.colorize (Darklang.Cli.Colors.purpleBg ++ Darklang.Cli.Colors.white ++ Darklang.Cli.Colors.bold) $" {titleText} " let modeIndicator = Darklang.Cli.Colors.colorize modeColor modeText - Darklang.Cli.UI.Layout.printAt region 0L 0L (title ++ " " ++ modeIndicator) + Darklang.Cli.UI.Layout.printAt region 0I 0I (title ++ " " ++ modeIndicator) let renderHelpBar (helpText: String) (region: Darklang.Cli.UI.Layout.Region) : Unit = - let helpLen = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length helpText)) + let helpLen = Stdlib.String.length helpText let helpPadding = - if region.cols > helpLen then Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (region.cols - helpLen)) + if region.cols > helpLen then Stdlib.String.repeat " " (region.cols - helpLen) else "" let styled = Darklang.Cli.Colors.colorize (Darklang.Cli.Colors.grayBg ++ Darklang.Cli.Colors.white) (helpText ++ helpPadding) - Darklang.Cli.UI.Layout.printAt region 0L 0L styled + Darklang.Cli.UI.Layout.printAt region 0I 0I styled let renderChrome (titleText: String) (modeText: String) (modeColor: String) (helpText: String) (renderBody: Darklang.Cli.UI.Layout.Region -> Unit) : Unit = let termHeight = Darklang.Cli.Terminal.getHeight () @@ -226,14 +226,14 @@ let renderChrome (titleText: String) (modeText: String) (modeColor: String) (hel Stdlib.print "\u001b[?25l\u001b[2J\u001b[H" let screen = - Darklang.Cli.UI.Layout.Region { top = 1L; left = 1L; rows = termHeight - 1L; cols = termWidth } + Darklang.Cli.UI.Layout.Region { top = 1I; left = 1I; rows = termHeight - 1I; cols = termWidth } let titleComp = - Darklang.Cli.UI.Layout.fixedSize 2L (fun region -> renderTitleBar titleText modeText modeColor region) + Darklang.Cli.UI.Layout.fixedSize 2I (fun region -> renderTitleBar titleText modeText modeColor region) let bodyComp = Darklang.Cli.UI.Layout.greedy renderBody let helpComp = - Darklang.Cli.UI.Layout.fixedSize 1L (fun region -> renderHelpBar helpText region) + Darklang.Cli.UI.Layout.fixedSize 1I (fun region -> renderHelpBar helpText region) let components = [titleComp; bodyComp; helpComp] Darklang.Cli.UI.Layout.vstack screen components Stdlib.print "\u001b[?25h" @@ -260,7 +260,7 @@ let render (state: State) : Unit = |> Stdlib.List.indexedMap (fun idx item -> (idx, item)) |> Stdlib.List.iter (fun pair -> let (idx, item) = pair - let isSelected = idx == Stdlib.Int.fromInt64 picker.selected + let isSelected = idx == picker.selected let displayText = match Stdlib.List.getAt picker.items idx with | Some doc -> @@ -274,7 +274,7 @@ let render (state: State) : Unit = Darklang.Cli.Colors.colorize Darklang.Cli.Colors.selection line else line - Darklang.Cli.UI.Layout.printAt region (Builtin.unwrap (Stdlib.Int.toInt64 idx)) 0L styled)) + Darklang.Cli.UI.Layout.printAt region idx 0I styled)) | Editor editor -> let doc = activeDoc state @@ -300,8 +300,8 @@ let render (state: State) : Unit = "Edit path | Enter: export | Esc: cancel" (fun region -> let label = Darklang.Cli.Colors.colorize Darklang.Cli.Colors.dim " Path: " - Darklang.Cli.UI.Layout.printAt region 0L 0L $" Format: {formatName}" - Darklang.Cli.UI.Layout.printAt region 2L 0L (label ++ (TextEditor.renderInline te))) + Darklang.Cli.UI.Layout.printAt region 0I 0I $" Format: {formatName}" + Darklang.Cli.UI.Layout.printAt region 2I 0I (label ++ (TextEditor.renderInline te))) // --- Persistence --- diff --git a/packages/darklang/cli/outliner/outline-editor.dark b/packages/darklang/cli/outliner/outline-editor.dark index 3f0433a0dc..8b9f44cf8a 100644 --- a/packages/darklang/cli/outliner/outline-editor.dark +++ b/packages/darklang/cli/outliner/outline-editor.dark @@ -2,7 +2,7 @@ module Darklang.Cli.Outliner.OutlineEditor type State = { outline: Outline - cursor: Int64 + cursor: Int editing: Stdlib.Option.Option } type Result = @@ -11,20 +11,19 @@ type Result = | Back of State let fromOutline (outline: Outline) : State = - State { outline = outline; cursor = 0L; editing = Stdlib.Option.Option.None } + State { outline = outline; cursor = 0I; editing = Stdlib.Option.Option.None } // --- Helpers --- let getVisibleNodeAtCursor (state: State) : Stdlib.Option.Option = let flat = flattenVisible state.outline - Stdlib.List.getAt flat (Stdlib.Int.fromInt64 state.cursor) + Stdlib.List.getAt flat state.cursor -let findCursorIndex (outline: Outline) (nodeId: Int64) (fallback: Int64) : Int64 = +let findCursorIndex (outline: Outline) (nodeId: Int64) (fallback: Int) : Int = let flat = flattenVisible outline flat |> Stdlib.List.findFirstIndex (fun vn -> vn.id == nodeId) - |> Stdlib.Option.map (fun i -> Builtin.unwrap (Stdlib.Int.toInt64 i)) |> Stdlib.Option.withDefault fallback @@ -49,7 +48,7 @@ let insertAfter (state: State) : State = let o2 = { o1 with rootChildren = [id]; nextId = id + 1L } { state with outline = o2 - cursor = 0L + cursor = 0I editing = Stdlib.Option.Option.Some (TextEditor.empty) } | Some vn -> let o1 = addNode outline id "" @@ -79,7 +78,7 @@ let deleteNode (state: State) : State = let o1 = setChildren outline parentId newSiblings let o2 = removeNodeData o1 vn.id let flat = flattenVisible o2 - let maxIdx = Stdlib.Int64.max 0L ((Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length flat))) - 1L) + let maxIdx = Stdlib.Int.max 0I ((Stdlib.List.length flat) - 1I) let newCursor = if state.cursor > maxIdx then maxIdx else state.cursor @@ -169,16 +168,16 @@ let moveNodeDown (state: State) : State = { state with outline = o1; cursor = findCursorIndex o1 vn.id state.cursor } let moveCursorUp (state: State) : State = - if state.cursor > 0L then - { state with cursor = state.cursor - 1L } + if state.cursor > 0I then + { state with cursor = state.cursor - 1I } else state let moveCursorDown (state: State) : State = let flat = flattenVisible state.outline - let maxIndex = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length flat))) - 1L + let maxIndex = (Stdlib.List.length flat) - 1I if state.cursor < maxIndex then - { state with cursor = state.cursor + 1L } + { state with cursor = state.cursor + 1I } else state @@ -262,23 +261,23 @@ let renderBody (state: State) (region: Darklang.Cli.UI.Layout.Region) : Unit = | None -> false let scrollOffset = - if state.cursor < 0L then - 0L + if state.cursor < 0I then + 0I else if state.cursor >= region.rows then Darklang.Cli.Terminal.clampScrollOffset - (state.cursor - region.rows + 1L) - (Builtin.unwrap (Stdlib.Int.toInt64 totalItems)) + (state.cursor - region.rows + 1I) + totalItems region.rows else - 0L + 0I let visibleItems = flat - |> Stdlib.List.drop (Stdlib.Int.fromInt64 scrollOffset) - |> Stdlib.List.take (Stdlib.Int.fromInt64 region.rows) + |> Stdlib.List.drop scrollOffset + |> Stdlib.List.take region.rows visibleItems - |> Stdlib.List.indexedMap (fun relIdx vn -> ((Builtin.unwrap (Stdlib.Int.toInt64 relIdx)), vn)) + |> Stdlib.List.indexedMap (fun relIdx vn -> (relIdx, vn)) |> Stdlib.List.iter (fun pair -> let (relIdx, vn) = pair let absoluteIdx = scrollOffset + relIdx @@ -312,7 +311,7 @@ let renderBody (state: State) (region: Darklang.Cli.UI.Layout.Region) : Unit = Darklang.Cli.Colors.colorize Darklang.Cli.Colors.selection line else line - Darklang.Cli.UI.Layout.printAt region relIdx 0L styled) + Darklang.Cli.UI.Layout.printAt region relIdx 0I styled) let renderTitleBar (title: String) (isEditing: Bool) (region: Darklang.Cli.UI.Layout.Region) : Unit = let titleText = Darklang.Cli.Colors.colorize (Darklang.Cli.Colors.purpleBg ++ Darklang.Cli.Colors.white ++ Darklang.Cli.Colors.bold) $" {title} " @@ -322,15 +321,15 @@ let renderTitleBar (title: String) (isEditing: Bool) (region: Darklang.Cli.UI.La if isEditing then Darklang.Cli.Colors.greenBg ++ Darklang.Cli.Colors.black else Darklang.Cli.Colors.grayBg ++ Darklang.Cli.Colors.white let modeIndicator = Darklang.Cli.Colors.colorize modeColor modeText - Darklang.Cli.UI.Layout.printAt region 0L 0L (titleText ++ " " ++ modeIndicator) + Darklang.Cli.UI.Layout.printAt region 0I 0I (titleText ++ " " ++ modeIndicator) let renderHelpBar (helpText: String) (region: Darklang.Cli.UI.Layout.Region) : Unit = - let helpLen = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length helpText)) + let helpLen = Stdlib.String.length helpText let helpPadding = - if region.cols > helpLen then Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (region.cols - helpLen)) + if region.cols > helpLen then Stdlib.String.repeat " " (region.cols - helpLen) else "" let styled = Darklang.Cli.Colors.colorize (Darklang.Cli.Colors.grayBg ++ Darklang.Cli.Colors.white) (helpText ++ helpPadding) - Darklang.Cli.UI.Layout.printAt region 0L 0L styled + Darklang.Cli.UI.Layout.printAt region 0I 0I styled let render (state: State) (title: String) : Unit = let termHeight = Darklang.Cli.Terminal.getHeight () @@ -339,7 +338,7 @@ let render (state: State) (title: String) : Unit = Stdlib.print "\u001b[?25l\u001b[2J\u001b[H" let screen = - Darklang.Cli.UI.Layout.Region { top = 1L; left = 1L; rows = termHeight - 1L; cols = termWidth } + Darklang.Cli.UI.Layout.Region { top = 1I; left = 1I; rows = termHeight - 1I; cols = termWidth } let isEditing = match state.editing with @@ -351,11 +350,11 @@ let render (state: State) (title: String) : Unit = else "Up/Down: move | Enter: edit | o: new | Tab/S-Tab: indent | Space: collapse | C-Up/Down: reorder | Esc: back" let titleComp = - Darklang.Cli.UI.Layout.fixedSize 2L (fun region -> renderTitleBar title isEditing region) + Darklang.Cli.UI.Layout.fixedSize 2I (fun region -> renderTitleBar title isEditing region) let bodyComp = Darklang.Cli.UI.Layout.greedy (fun region -> renderBody state region) let helpComp = - Darklang.Cli.UI.Layout.fixedSize 1L (fun region -> renderHelpBar helpText region) + Darklang.Cli.UI.Layout.fixedSize 1I (fun region -> renderHelpBar helpText region) let components = [titleComp; bodyComp; helpComp] Darklang.Cli.UI.Layout.vstack screen components Stdlib.print "\u001b[?25h" diff --git a/packages/darklang/cli/outliner/tests.dark b/packages/darklang/cli/outliner/tests.dark index c88d46d3fa..5d5acf1055 100644 --- a/packages/darklang/cli/outliner/tests.dark +++ b/packages/darklang/cli/outliner/tests.dark @@ -182,7 +182,7 @@ let testIndentNode () : TestResult = [] [1L; 2L] 3L - let editor = { (makeEditor outline) with cursor = 1L } + let editor = { (makeEditor outline) with cursor = 1I } let newEditor = OutlineEditor.indentNode editor let rootCount = Stdlib.List.length newEditor.outline.rootChildren if rootCount == 1I then @@ -198,7 +198,7 @@ let testOutdentNode () : TestResult = [(1L, [2L])] [1L] 3L - let editor = { (makeEditor outline) with cursor = 1L } + let editor = { (makeEditor outline) with cursor = 1I } let newEditor = OutlineEditor.outdentNode editor assertInt "root count" (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length newEditor.outline.rootChildren))) 2L @@ -209,7 +209,7 @@ let testMoveNodeUp () : TestResult = [] [1L; 2L] 3L - let editor = { (makeEditor outline) with cursor = 1L } + let editor = { (makeEditor outline) with cursor = 1I } let newEditor = OutlineEditor.moveNodeUp editor match Stdlib.List.head newEditor.outline.rootChildren with | Some firstId -> @@ -243,10 +243,10 @@ let testMoveCursorUpDown () : TestResult = let down1 = OutlineEditor.moveCursorDown editor let down2 = OutlineEditor.moveCursorDown down1 let up1 = OutlineEditor.moveCursorUp down2 - if down1.cursor == 1L && down2.cursor == 2L && up1.cursor == 1L then + if down1.cursor == 1I && down2.cursor == 2I && up1.cursor == 1I then TestResult.Pass else - TestResult.Fail $"Cursor movement: d1={Stdlib.Int64.toString down1.cursor} d2={Stdlib.Int64.toString down2.cursor} u1={Stdlib.Int64.toString up1.cursor}" + TestResult.Fail $"Cursor movement: d1={Stdlib.Int.toString down1.cursor} d2={Stdlib.Int.toString down2.cursor} u1={Stdlib.Int.toString up1.cursor}" let testMoveCursorBounds () : TestResult = let outline = @@ -258,7 +258,7 @@ let testMoveCursorBounds () : TestResult = let editor = makeEditor outline let upFromZero = OutlineEditor.moveCursorUp editor let downFromMax = OutlineEditor.moveCursorDown editor - if upFromZero.cursor == 0L && downFromMax.cursor == 0L then + if upFromZero.cursor == 0I && downFromMax.cursor == 0I then TestResult.Pass else TestResult.Fail "Cursor should not move past bounds" diff --git a/packages/darklang/cli/outliner/text-editor.dark b/packages/darklang/cli/outliner/text-editor.dark index c5884c4b6a..3b212ef9d1 100644 --- a/packages/darklang/cli/outliner/text-editor.dark +++ b/packages/darklang/cli/outliner/text-editor.dark @@ -2,7 +2,7 @@ module Darklang.Cli.Outliner.TextEditor type State = { text: String - cursor: Int64 } + cursor: Int } type Result = | Editing of State @@ -10,10 +10,10 @@ type Result = | Cancelled let empty : State = - State { text = ""; cursor = 0L } + State { text = ""; cursor = 0I } let fromText (text: String) : State = - State { text = text; cursor = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length text)) } + State { text = text; cursor = Stdlib.String.length text } let handleKey (state: State) @@ -25,43 +25,43 @@ let handleKey | Enter -> Result.Finished state.text | Escape -> Result.Cancelled | Backspace -> - if state.cursor == 0L then + if state.cursor == 0I then Result.Editing state else - let before = Stdlib.String.slice state.text 0I (Stdlib.Int.fromInt64 (state.cursor - 1L)) - let after = Stdlib.String.dropFirst state.text (Stdlib.Int.fromInt64 state.cursor) - Result.Editing (State { text = before ++ after; cursor = state.cursor - 1L }) + let before = Stdlib.String.slice state.text 0I (state.cursor - 1I) + let after = Stdlib.String.dropFirst state.text state.cursor + Result.Editing (State { text = before ++ after; cursor = state.cursor - 1I }) | LeftArrow -> - if state.cursor > 0L then - Result.Editing ({ state with cursor = state.cursor - 1L }) + if state.cursor > 0I then + Result.Editing ({ state with cursor = state.cursor - 1I }) else Result.Editing state | RightArrow -> - let textLen = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length state.text)) + let textLen = Stdlib.String.length state.text if state.cursor < textLen then - Result.Editing ({ state with cursor = state.cursor + 1L }) + Result.Editing ({ state with cursor = state.cursor + 1I }) else Result.Editing state | _ -> match keyChar with | Some ch -> - let before = Stdlib.String.slice state.text 0I (Stdlib.Int.fromInt64 state.cursor) - let after = Stdlib.String.dropFirst state.text (Stdlib.Int.fromInt64 state.cursor) - Result.Editing (State { text = before ++ ch ++ after; cursor = state.cursor + 1L }) + let before = Stdlib.String.slice state.text 0I state.cursor + let after = Stdlib.String.dropFirst state.text state.cursor + Result.Editing (State { text = before ++ ch ++ after; cursor = state.cursor + 1I }) | None -> Result.Editing state /// Render text with a visible cursor. Returns a styled string, does not print. let renderInline (state: State) : String = - let before = Stdlib.String.slice state.text 0I (Stdlib.Int.fromInt64 state.cursor) + let before = Stdlib.String.slice state.text 0I state.cursor let cursorChar = - if state.cursor < (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length state.text))) then - Stdlib.String.slice state.text (Stdlib.Int.fromInt64 state.cursor) (Stdlib.Int.fromInt64 (state.cursor + 1L)) + if state.cursor < (Stdlib.String.length state.text) then + Stdlib.String.slice state.text state.cursor (state.cursor + 1I) else " " let cursorDisplay = Darklang.Cli.Colors.colorize Darklang.Cli.Colors.reverse cursorChar let afterCursor = - if state.cursor < (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length state.text))) then - Stdlib.String.dropFirst state.text (Stdlib.Int.fromInt64 (state.cursor + 1L)) + if state.cursor < (Stdlib.String.length state.text) then + Stdlib.String.dropFirst state.text (state.cursor + 1I) else "" before ++ cursorDisplay ++ afterCursor diff --git a/packages/darklang/cli/prompt.dark b/packages/darklang/cli/prompt.dark index 5fb0e396be..6f35ff2e0c 100644 --- a/packages/darklang/cli/prompt.dark +++ b/packages/darklang/cli/prompt.dark @@ -3,87 +3,87 @@ module Darklang.Cli.Prompt /// State for prompt-specific fields (text, cursor, history) type State = { text: String - cursorPosition: Int64 + cursorPosition: Int commandHistory: List - historyIndex: Int64 + historyIndex: Int savedPrompt: String } let initState () : State = State { text = "" - cursorPosition = 0L + cursorPosition = 0I commandHistory = [] - historyIndex = -1L + historyIndex = -1I savedPrompt = "" } module Editing = /// Insert text at cursor position let insertAtCursor (state: State) (char: String) : State = - let beforeCursor = Stdlib.String.slice state.text 0I (Stdlib.Int.fromInt64 state.cursorPosition) - let afterCursor = Stdlib.String.dropFirst state.text (Stdlib.Int.fromInt64 state.cursorPosition) + let beforeCursor = Stdlib.String.slice state.text 0I state.cursorPosition + let afterCursor = Stdlib.String.dropFirst state.text state.cursorPosition let newText = beforeCursor ++ char ++ afterCursor { state with text = newText - cursorPosition = state.cursorPosition + (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length char))) - historyIndex = -1L + cursorPosition = state.cursorPosition + (Stdlib.String.length char) + historyIndex = -1I savedPrompt = "" } /// Delete character before cursor (backspace) let deleteBeforeCursor (state: State) : State = - if state.cursorPosition > 0L then - let beforeCursor = Stdlib.String.slice state.text 0I (Stdlib.Int.fromInt64 (state.cursorPosition - 1L)) - let afterCursor = Stdlib.String.dropFirst state.text (Stdlib.Int.fromInt64 state.cursorPosition) + if state.cursorPosition > 0I then + let beforeCursor = Stdlib.String.slice state.text 0I (state.cursorPosition - 1I) + let afterCursor = Stdlib.String.dropFirst state.text state.cursorPosition let newText = beforeCursor ++ afterCursor { state with text = newText - cursorPosition = state.cursorPosition - 1L - historyIndex = -1L } + cursorPosition = state.cursorPosition - 1I + historyIndex = -1I } else state /// Delete character at cursor (delete key) let deleteAtCursor (state: State) : State = - let textLength = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length state.text)) + let textLength = Stdlib.String.length state.text if state.cursorPosition < textLength then - let beforeCursor = Stdlib.String.slice state.text 0I (Stdlib.Int.fromInt64 state.cursorPosition) - let afterCursor = Stdlib.String.dropFirst state.text (Stdlib.Int.fromInt64 (state.cursorPosition + 1L)) + let beforeCursor = Stdlib.String.slice state.text 0I state.cursorPosition + let afterCursor = Stdlib.String.dropFirst state.text (state.cursorPosition + 1I) let newText = beforeCursor ++ afterCursor - { state with text = newText; historyIndex = -1L } + { state with text = newText; historyIndex = -1I } else state /// Move cursor left let moveCursorLeft (state: State) : State = - let newCursorPos = Stdlib.Int64.max 0L (state.cursorPosition - 1L) + let newCursorPos = Stdlib.Int.max 0I (state.cursorPosition - 1I) { state with cursorPosition = newCursorPos } /// Move cursor right let moveCursorRight (state: State) : State = - let textLength = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length state.text)) - let newCursorPos = Stdlib.Int64.min textLength (state.cursorPosition + 1L) + let textLength = Stdlib.String.length state.text + let newCursorPos = Stdlib.Int.min textLength (state.cursorPosition + 1I) { state with cursorPosition = newCursorPos } /// Move cursor to start of line let moveCursorHome (state: State) : State = - { state with cursorPosition = 0L } + { state with cursorPosition = 0I } /// Move cursor to end of line let moveCursorEnd (state: State) : State = - let textLength = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length state.text)) + let textLength = Stdlib.String.length state.text { state with cursorPosition = textLength } /// Clear the prompt text let clear (state: State) : State = { state with text = "" - cursorPosition = 0L - historyIndex = -1L } + cursorPosition = 0I + historyIndex = -1I } /// Set the prompt text and move cursor to end let setText (state: State) (text: String) : State = - let textLength = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length text)) + let textLength = Stdlib.String.length text { state with text = text; cursorPosition = textLength } @@ -97,25 +97,25 @@ module History = state.commandHistory { state with commandHistory = updatedHistory - historyIndex = -1L } + historyIndex = -1I } /// Navigate to previous command in history let navigatePrevious (state: State) : State = if Stdlib.Bool.not (Stdlib.List.isEmpty state.commandHistory) then - let historyLength = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length state.commandHistory))) + let historyLength = Stdlib.List.length state.commandHistory let newIndex = - if state.historyIndex == -1L then - 0L // Start from the most recent command + if state.historyIndex == -1I then + 0I // Start from the most recent command else - if state.historyIndex < (historyLength - 1L) then - state.historyIndex + 1L + if state.historyIndex < (historyLength - 1I) then + state.historyIndex + 1I else state.historyIndex // Stay at oldest command - match Stdlib.List.getAt state.commandHistory (Stdlib.Int.fromInt64 newIndex) with + match Stdlib.List.getAt state.commandHistory newIndex with | Some command -> - let commandLength = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length command)) + let commandLength = Stdlib.String.length command let newSavedPrompt = - if state.historyIndex == -1L then + if state.historyIndex == -1I then state.text else state.savedPrompt @@ -131,22 +131,22 @@ module History = /// Navigate to next command in history let navigateNext (state: State) : State = - if Stdlib.Bool.not (Stdlib.List.isEmpty state.commandHistory) && state.historyIndex >= 0L then + if Stdlib.Bool.not (Stdlib.List.isEmpty state.commandHistory) && state.historyIndex >= 0I then let newIndex = - if state.historyIndex > 0L then - state.historyIndex - 1L + if state.historyIndex > 0I then + state.historyIndex - 1I else - -1L // Go back to empty prompt - if newIndex == -1L then - let restoredPromptLength = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length state.savedPrompt)) + -1I // Go back to empty prompt + if newIndex == -1I then + let restoredPromptLength = Stdlib.String.length state.savedPrompt { state with text = state.savedPrompt cursorPosition = restoredPromptLength historyIndex = newIndex } else - match Stdlib.List.getAt state.commandHistory (Stdlib.Int.fromInt64 newIndex) with + match Stdlib.List.getAt state.commandHistory newIndex with | Some command -> - let commandLength = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length command)) + let commandLength = Stdlib.String.length command { state with text = command cursorPosition = commandLength @@ -176,13 +176,13 @@ module Display = formattedLocation ++ "> " ++ text ++ (Colors.hint hint) /// Calculate the column where user input starts (after location + "> ") - let calculateInputStartColumn (locationStr: String) : Int64 = + let calculateInputStartColumn (locationStr: String) : Int = let locationLength = if Stdlib.String.isEmpty locationStr then - 0L + 0I else - (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length locationStr))) + 1L // +1 for the space after path + (Stdlib.String.length locationStr) + 1I // +1 for the space after path locationLength - + (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length "> "))) - + 1L + + (Stdlib.String.length "> ") + + 1I diff --git a/packages/darklang/cli/scm/review/app.dark b/packages/darklang/cli/scm/review/app.dark index 3af5f876d2..804078c019 100644 --- a/packages/darklang/cli/scm/review/app.dark +++ b/packages/darklang/cli/scm/review/app.dark @@ -39,7 +39,7 @@ let loadWipItems (branchId: Uuid) : List = let kind = Builtin.unwrap (Stdlib.Dict.get d "kind") let modulePath = Builtin.unwrap (Stdlib.Dict.get d "modulePath") let pCountStr = Builtin.unwrap (Stdlib.Dict.get d "propagatedCount") - let pCount = Builtin.unwrap (Stdlib.Int64.parse pCountStr) + let pCount = Builtin.unwrap (Stdlib.Int.parse pCountStr) PackageItem { name = name; kind = kind; modulePath = modulePath; propagatedCount = pCount }) let groupByModule (items: List) : List<(String * List)> = @@ -58,9 +58,10 @@ let loadBranchList () : List = let items = branches |> Stdlib.List.filterMap (fun b -> - let wipOpCount = SCM.PackageOps.getWipOpCount b.id - let committedCount = SCM.PackageOps.getCommitCount b.id - if wipOpCount == 0L && committedCount == 0L then + // bridge: packageOps counts are Int64 (out of scope); convert to Int at the boundary + let wipOpCount = Stdlib.Int.fromInt64 (SCM.PackageOps.getWipOpCount b.id) + let committedCount = Stdlib.Int.fromInt64 (SCM.PackageOps.getCommitCount b.id) + if wipOpCount == 0I && committedCount == 0I then Stdlib.Option.Option.None else Stdlib.Option.Option.Some @@ -70,7 +71,7 @@ let loadBranchList () : List = wipCount = wipOpCount committedCount = committedCount })) // Sort: branches with WIP first, then committed-only - let (withWip, committedOnly) = Stdlib.List.partition items (fun item -> item.wipCount > 0L) + let (withWip, committedOnly) = Stdlib.List.partition items (fun item -> item.wipCount > 0I) Stdlib.List.append withWip committedOnly let flattenGroups (groups: List<(String * List)>) : List = @@ -85,7 +86,7 @@ let flattenGroups (groups: List<(String * List)>) : List 200L then - let msg = $"Commit has {Stdlib.Int64.toString entry.opCount} ops — too large to display inline." + if entry.opCount > 200I then + let msg = $"Commit has {Stdlib.Int.toString entry.opCount} ops — too large to display inline." DiffState { itemName = entry.hash ++ " " ++ entry.message diffLines = [Stdlib.Diff.DiffLine.Same msg] - scrollOffset = 0L + scrollOffset = 0I returnTo = DiffReturnTo.ReturnToCommits commitList } else let ops = SCM.PackageOps.getCommitOps entry.fullHash @@ -274,7 +276,7 @@ let buildCommitDiffState (commitList: CommitListState) (entry: CommitEntry) : Di { name = PrettyPrinter.ProgramTypes.PackageLocation.packageLocation loc kind = kind modulePath = locationToModulePath loc - propagatedCount = 0L }) + propagatedCount = 0I }) let groups = groupByModule items let itemLines = Stdlib.List.fold groups [] (fun acc group -> @@ -288,13 +290,13 @@ let buildCommitDiffState (commitList: CommitListState) (entry: CommitEntry) : Di DiffState { itemName = entry.hash ++ " " ++ entry.message diffLines = itemLines - scrollOffset = 0L + scrollOffset = 0I returnTo = DiffReturnTo.ReturnToCommits commitList } // ── Key handling ── let openDiff (state: AppModel) (detail: DetailState) : KeyResult = - match Stdlib.List.getAt detail.flatItems (Stdlib.Int.fromInt64 detail.selected) with + match Stdlib.List.getAt detail.flatItems detail.selected with | Some flatItem -> match flatItem with | ItemEntry pkg -> @@ -305,16 +307,16 @@ let openDiff (state: AppModel) (detail: DetailState) : KeyResult = | None -> KeyResult.Continue state let openCommitDiff (state: AppModel) (commitList: CommitListState) : KeyResult = - match Stdlib.List.getAt commitList.commits (Stdlib.Int.fromInt64 commitList.selected) with + match Stdlib.List.getAt commitList.commits commitList.selected with | Some entry -> KeyResult.Continue ({ state with screen = Screen.DiffView (buildCommitDiffState commitList entry) }) | None -> KeyResult.Continue state let handleBranchListKey (state: AppModel) (branchList: BranchListState) (key: Stdlib.Cli.Stdin.Key.Key) (keyChar: Stdlib.Option.Option) : KeyResult = - let itemCount = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length branchList.items)) + let itemCount = Stdlib.List.length branchList.items match keyChar with | Some "r" -> - let newBranchList = BranchListState { items = loadBranchList (); selected = 0L } + let newBranchList = BranchListState { items = loadBranchList (); selected = 0I } KeyResult.Continue ({ state with screen = Screen.BranchList newBranchList }) | _ -> match key with @@ -324,7 +326,7 @@ let handleBranchListKey (state: AppModel) (branchList: BranchListState) (key: St | DownArrow -> KeyResult.Continue ({ state with screen = Screen.BranchList ({ branchList with selected = moveDown branchList.selected itemCount }) }) | Enter | RightArrow -> - match Stdlib.List.getAt branchList.items (Stdlib.Int.fromInt64 branchList.selected) with + match Stdlib.List.getAt branchList.items branchList.selected with | Some item -> KeyResult.Continue ({ state with screen = Screen.Detail (buildDetailState item) }) | None -> KeyResult.Continue state | _ -> KeyResult.Continue state @@ -337,7 +339,7 @@ let handleDetailKey (state: AppModel) (detail: DetailState) (key: Stdlib.Cli.Std match key with | Escape | LeftArrow -> if state.showAll then - KeyResult.Continue ({ state with screen = Screen.BranchList (BranchListState { items = loadBranchList (); selected = 0L }) }) + KeyResult.Continue ({ state with screen = Screen.BranchList (BranchListState { items = loadBranchList (); selected = 0I }) }) else KeyResult.Exit state | UpArrow -> KeyResult.Continue ({ state with screen = Screen.Detail ({ detail with selected = moveUpSkipping detail.selected detail.flatItems }) }) @@ -359,12 +361,12 @@ let handleDiffKey (state: AppModel) (diffState: DiffState) (key: Stdlib.Cli.Stdi | UpArrow -> KeyResult.Continue ({ state with screen = Screen.DiffView ({ diffState with scrollOffset = moveUp diffState.scrollOffset }) }) | DownArrow -> - let lineCount = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length diffState.diffLines)) + let lineCount = Stdlib.List.length diffState.diffLines KeyResult.Continue ({ state with screen = Screen.DiffView ({ diffState with scrollOffset = moveDown diffState.scrollOffset lineCount }) }) | _ -> KeyResult.Continue state let handleCommitListKey (state: AppModel) (commitList: CommitListState) (key: Stdlib.Cli.Stdin.Key.Key) : KeyResult = - let itemCount = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length commitList.commits)) + let itemCount = Stdlib.List.length commitList.commits match key with | Escape | LeftArrow -> KeyResult.Continue ({ state with screen = Screen.Detail commitList.returnTo }) | UpArrow -> @@ -384,15 +386,15 @@ let handleKey (state: AppModel) (key: Stdlib.Cli.Stdin.Key.Key) (_modifiers: Std // ── Rendering ── /// Format wip/committed counts for a branch review item -let formatBranchCounts (wipCount: Int64) (committedCount: Int64) (colorPrefix: String) : String = +let formatBranchCounts (wipCount: Int) (committedCount: Int) (colorPrefix: String) : String = let wipText = - if wipCount > 0L then - Darklang.Cli.Colors.colorize (colorPrefix ++ Darklang.Cli.Colors.pink) $"{Stdlib.Int64.toString wipCount} pending" + if wipCount > 0I then + Darklang.Cli.Colors.colorize (colorPrefix ++ Darklang.Cli.Colors.pink) $"{Stdlib.Int.toString wipCount} pending" else "" let committedText = - if committedCount > 0L then - let word = if committedCount == 1L then "commit" else "commits" - Darklang.Cli.Colors.colorize (colorPrefix ++ Darklang.Cli.Colors.purple) $"{Stdlib.Int64.toString committedCount} {word}" + if committedCount > 0I then + let word = if committedCount == 1I then "commit" else "commits" + Darklang.Cli.Colors.colorize (colorPrefix ++ Darklang.Cli.Colors.purple) $"{Stdlib.Int.toString committedCount} {word}" else "" [wipText; committedText] |> Stdlib.List.filter (fun s -> s != "") @@ -405,55 +407,55 @@ let kindLabel (kind: String) : String = | "Value" -> Darklang.Cli.Colors.colorize Darklang.Cli.Colors.orange "val" | other -> Darklang.Cli.Colors.colorize Darklang.Cli.Colors.dim other -let printLine (region: Darklang.Cli.UI.Layout.Region) (row: Int64) (text: String) : Unit = - Darklang.Cli.UI.Layout.printAt region row 0L (text ++ "\u001b[K") +let printLine (region: Darklang.Cli.UI.Layout.Region) (row: Int) (text: String) : Unit = + Darklang.Cli.UI.Layout.printAt region row 0I (text ++ "\u001b[K") -let clearRows (region: Darklang.Cli.UI.Layout.Region) (startRow: Int64) : Unit = - let rows = Stdlib.List.range (Stdlib.Int.fromInt64 startRow) (Stdlib.Int.fromInt64 (region.rows - 1L)) - Stdlib.List.iter rows (fun row -> Darklang.Cli.UI.Layout.printAt region (Builtin.unwrap (Stdlib.Int.toInt64 row)) 0L "\u001b[K") +let clearRows (region: Darklang.Cli.UI.Layout.Region) (startRow: Int) : Unit = + let rows = Stdlib.List.range startRow (region.rows - 1I) + Stdlib.List.iter rows (fun row -> Darklang.Cli.UI.Layout.printAt region row 0I "\u001b[K") let renderScrollableList (region: Darklang.Cli.UI.Layout.Region) (items: List<'a>) - (selected: Int64) - (startRow: Int64) - (rowsPerItem: Int64) - (renderItem: Darklang.Cli.UI.Layout.Region -> Int64 -> 'a -> Bool -> Unit) + (selected: Int) + (startRow: Int) + (rowsPerItem: Int) + (renderItem: Darklang.Cli.UI.Layout.Region -> Int -> 'a -> Bool -> Unit) : Unit = - let itemCount = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length items)) + let itemCount = Stdlib.List.length items let listRows = region.rows - startRow - let visibleCount = Stdlib.Int64.divide listRows rowsPerItem + let visibleCount = Stdlib.Int.divide listRows rowsPerItem let scrollOffset = computeScrollOffset selected visibleCount items - |> Stdlib.List.indexedMap (fun idx item -> (Builtin.unwrap (Stdlib.Int.toInt64 idx), item)) - |> Stdlib.List.drop (Stdlib.Int.fromInt64 scrollOffset) - |> Stdlib.List.take (Stdlib.Int.fromInt64 visibleCount) + |> Stdlib.List.indexedMap (fun idx item -> (idx, item)) + |> Stdlib.List.drop scrollOffset + |> Stdlib.List.take visibleCount |> Stdlib.List.iter (fun pair -> let (idx, item) = pair let itemRow = ((idx - scrollOffset) * rowsPerItem) + startRow let isSelected = idx == selected renderItem region itemRow item isSelected) - let renderedRows = ((Stdlib.Int64.min itemCount visibleCount) * rowsPerItem) + startRow + let renderedRows = ((Stdlib.Int.min itemCount visibleCount) * rowsPerItem) + startRow clearRows region renderedRows let renderTitleBar (region: Darklang.Cli.UI.Layout.Region) (modeText: String) : Unit = let title = Darklang.Cli.Colors.colorize (Darklang.Cli.Colors.bold ++ Darklang.Cli.Colors.magenta) "Review changes" let mode = Darklang.Cli.Colors.colorize Darklang.Cli.Colors.dim modeText - printLine region 0L ($" {title} {mode}") + printLine region 0I ($" {title} {mode}") let renderHelpBar (region: Darklang.Cli.UI.Layout.Region) (helpText: String) : Unit = - printLine region 0L (Darklang.Cli.Colors.colorize Darklang.Cli.Colors.dim helpText) + printLine region 0I (Darklang.Cli.Colors.colorize Darklang.Cli.Colors.dim helpText) let renderBranchListBody (branchList: BranchListState) (region: Darklang.Cli.UI.Layout.Region) : Unit = let itemCount = Stdlib.List.length branchList.items - printLine region 0L $" {Darklang.Cli.Colors.bold}branches to review{Darklang.Cli.Colors.reset}" + printLine region 0I $" {Darklang.Cli.Colors.bold}branches to review{Darklang.Cli.Colors.reset}" if itemCount == 0I then - printLine region 2L (Darklang.Cli.Colors.colorize Darklang.Cli.Colors.dim " No branches with changes to review.") - clearRows region 3L + printLine region 2I (Darklang.Cli.Colors.colorize Darklang.Cli.Colors.dim " No branches with changes to review.") + clearRows region 3I else let dim = Darklang.Cli.Colors.dim ++ Darklang.Cli.Colors.brightBlack - let hBar = Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (Stdlib.Int64.max 0L (region.cols - 5L))) - renderScrollableList region branchList.items branchList.selected 2L 4L (fun r cardRow item isSelected -> + let hBar = Stdlib.String.repeat "─" (Stdlib.Int.max 0I (region.cols - 5I)) + renderScrollableList region branchList.items branchList.selected 2I 4I (fun r cardRow item isSelected -> let borderColor = if isSelected then Darklang.Cli.Colors.cyan else dim let bar = Darklang.Cli.Colors.colorize borderColor "│" let marker = if isSelected then Darklang.Cli.Colors.colorize Darklang.Cli.Colors.cyan " > " else " " @@ -462,18 +464,18 @@ let renderBranchListBody (branchList: BranchListState) (region: Darklang.Cli.UI. let textDim = if isSelected then "" else Darklang.Cli.Colors.dim let countText = formatBranchCounts item.wipCount item.committedCount textDim printLine r cardRow (Darklang.Cli.Colors.colorize borderColor (" ╭" ++ hBar)) - printLine r (cardRow + 1L) $"{marker}{bar} {nameText} {countText}" - printLine r (cardRow + 2L) $" {bar}" - printLine r (cardRow + 3L) (Darklang.Cli.Colors.colorize borderColor (" ╰" ++ hBar))) + printLine r (cardRow + 1I) $"{marker}{bar} {nameText} {countText}" + printLine r (cardRow + 2I) $" {bar}" + printLine r (cardRow + 3I) (Darklang.Cli.Colors.colorize borderColor (" ╰" ++ hBar))) let renderDetailBody (detail: DetailState) (region: Darklang.Cli.UI.Layout.Region) : Unit = - printLine region 0L $" {Darklang.Cli.Colors.dim}review >{Darklang.Cli.Colors.reset} {Darklang.Cli.Colors.cyan}{detail.branchName}{Darklang.Cli.Colors.reset}" + printLine region 0I $" {Darklang.Cli.Colors.dim}review >{Darklang.Cli.Colors.reset} {Darklang.Cli.Colors.cyan}{detail.branchName}{Darklang.Cli.Colors.reset}" let itemCount = Stdlib.List.length detail.flatItems if itemCount == 0I then - printLine region 2L (Darklang.Cli.Colors.colorize Darklang.Cli.Colors.dim " No changes on this branch.") - clearRows region 3L + printLine region 2I (Darklang.Cli.Colors.colorize Darklang.Cli.Colors.dim " No changes on this branch.") + clearRows region 3I else - renderScrollableList region detail.flatItems detail.selected 2L 1L (fun r row item isSelected -> + renderScrollableList region detail.flatItems detail.selected 2I 1I (fun r row item isSelected -> let styled = match item with | ModuleHeader modPath -> @@ -482,8 +484,8 @@ let renderDetailBody (detail: DetailState) (region: Darklang.Cli.UI.Layout.Regio | ItemEntry pkg -> let prefix = if isSelected then " > " else " " let propText = - if pkg.propagatedCount > 0L then - Darklang.Cli.Colors.colorize Darklang.Cli.Colors.dim ($" ({Stdlib.Int64.toString pkg.propagatedCount} propagated)") + if pkg.propagatedCount > 0I then + Darklang.Cli.Colors.colorize Darklang.Cli.Colors.dim ($" ({Stdlib.Int.toString pkg.propagatedCount} propagated)") else "" $"{prefix}{kindLabel pkg.kind} {pkg.name}{propText}" @@ -494,35 +496,35 @@ let renderDiffBody (diffState: DiffState) (region: Darklang.Cli.UI.Layout.Region match diffState.returnTo with | ReturnToDetail detail -> detail.branchName | ReturnToCommits commitList -> commitList.branchName - printLine region 0L $" {Darklang.Cli.Colors.dim}review > {branchName} >{Darklang.Cli.Colors.reset} {Darklang.Cli.Colors.cyan}{diffState.itemName}{Darklang.Cli.Colors.reset}" - let listRows = region.rows - 2L - let lineCount = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length diffState.diffLines)) + printLine region 0I $" {Darklang.Cli.Colors.dim}review > {branchName} >{Darklang.Cli.Colors.reset} {Darklang.Cli.Colors.cyan}{diffState.itemName}{Darklang.Cli.Colors.reset}" + let listRows = region.rows - 2I + let lineCount = Stdlib.List.length diffState.diffLines diffState.diffLines - |> Stdlib.List.indexedMap (fun idx line -> (Builtin.unwrap (Stdlib.Int.toInt64 idx), line)) - |> Stdlib.List.drop (Stdlib.Int.fromInt64 diffState.scrollOffset) - |> Stdlib.List.take (Stdlib.Int.fromInt64 listRows) + |> Stdlib.List.indexedMap (fun idx line -> (idx, line)) + |> Stdlib.List.drop diffState.scrollOffset + |> Stdlib.List.take listRows |> Stdlib.List.iter (fun pair -> let (idx, diffLine) = pair - let row = (idx - diffState.scrollOffset) + 2L + let row = (idx - diffState.scrollOffset) + 2I let styled = match diffLine with | Added text -> Darklang.Cli.Colors.colorize Darklang.Cli.Colors.green (" + " ++ text) | Removed text -> Darklang.Cli.Colors.colorize Darklang.Cli.Colors.red (" - " ++ text) | Same text -> " " ++ text printLine region row styled) - clearRows region ((Stdlib.Int64.min lineCount listRows) + 2L) + clearRows region ((Stdlib.Int.min lineCount listRows) + 2I) let renderCommitListBody (commitList: CommitListState) (region: Darklang.Cli.UI.Layout.Region) : Unit = - printLine region 0L $" {Darklang.Cli.Colors.dim}review > {commitList.branchName} >{Darklang.Cli.Colors.reset} {Darklang.Cli.Colors.bold}commits{Darklang.Cli.Colors.reset}" + printLine region 0I $" {Darklang.Cli.Colors.dim}review > {commitList.branchName} >{Darklang.Cli.Colors.reset} {Darklang.Cli.Colors.bold}commits{Darklang.Cli.Colors.reset}" let itemCount = Stdlib.List.length commitList.commits if itemCount == 0I then - printLine region 2L (Darklang.Cli.Colors.colorize Darklang.Cli.Colors.dim " No commits on this branch.") - clearRows region 3L + printLine region 2I (Darklang.Cli.Colors.colorize Darklang.Cli.Colors.dim " No commits on this branch.") + clearRows region 3I else - renderScrollableList region commitList.commits commitList.selected 2L 1L (fun r row entry isSelected -> + renderScrollableList region commitList.commits commitList.selected 2I 1I (fun r row entry isSelected -> let prefix = if isSelected then " > " else " " let hashText = Darklang.Cli.Colors.colorize Darklang.Cli.Colors.yellow entry.hash - let opsText = Darklang.Cli.Colors.colorize Darklang.Cli.Colors.dim ($"{Stdlib.Int64.toString entry.opCount} ops") + let opsText = Darklang.Cli.Colors.colorize Darklang.Cli.Colors.dim ($"{Stdlib.Int.toString entry.opCount} ops") let dateText = Darklang.Cli.Colors.colorize Darklang.Cli.Colors.dim entry.date printLine r row $"{prefix}{hashText} {entry.message} {opsText} {dateText}") @@ -531,7 +533,7 @@ let render (state: AppModel) : Unit = let termWidth = Darklang.Cli.Terminal.getWidth () Stdlib.print "\u001b[?25l\u001b[2J\u001b[H" let screen = - Darklang.Cli.UI.Layout.Region { top = 1L; left = 1L; rows = termHeight - 1L; cols = termWidth } + Darklang.Cli.UI.Layout.Region { top = 1I; left = 1I; rows = termHeight - 1I; cols = termWidth } let (mode, bodyFn, helpText) = match state.screen with | BranchList branchList -> @@ -542,9 +544,9 @@ let render (state: AppModel) : Unit = (" DIFF ", (fun r -> renderDiffBody diffState r), "Up/Down: scroll | Left/Esc: back") | CommitList commitList -> (" COMMITS ", (fun r -> renderCommitListBody commitList r), "Up/Down: navigate | Right/Enter: view | Left/Esc: back") - let titleComp = Darklang.Cli.UI.Layout.fixedSize 2L (fun r -> renderTitleBar r mode) + let titleComp = Darklang.Cli.UI.Layout.fixedSize 2I (fun r -> renderTitleBar r mode) let bodyComp = Darklang.Cli.UI.Layout.greedy bodyFn - let helpComp = Darklang.Cli.UI.Layout.fixedSize 1L (fun r -> renderHelpBar r helpText) + let helpComp = Darklang.Cli.UI.Layout.fixedSize 1I (fun r -> renderHelpBar r helpText) Darklang.Cli.UI.Layout.vstack screen [ titleComp; bodyComp; helpComp ] Stdlib.print "\u001b[?25h" @@ -564,13 +566,14 @@ let buildDetailForBranch (branchId: Uuid) : Screen = match SCM.Branch.get branchId with | Some b -> b.name | None -> "unknown" - let wipCount = SCM.PackageOps.getWipOpCount branchId + // bridge: getWipOpCount is Int64 (out of scope); convert to Int at the boundary + let wipCount = Stdlib.Int.fromInt64 (SCM.PackageOps.getWipOpCount branchId) let item = BranchReviewItem { branchId = branchId branchName = branchName wipCount = wipCount - committedCount = 0L } + committedCount = 0I } Screen.Detail (buildDetailState item) @@ -598,8 +601,8 @@ let printWipItems (branchId: Uuid) : Unit = Stdlib.printLine $" {Darklang.Cli.Colors.bold}{Darklang.Cli.Colors.magenta}{modPath}{Darklang.Cli.Colors.reset}" Stdlib.List.iter items (fun pkg -> let propText = - if pkg.propagatedCount > 0L then - Darklang.Cli.Colors.dimText $" ({Stdlib.Int64.toString pkg.propagatedCount} propagated)" + if pkg.propagatedCount > 0I then + Darklang.Cli.Colors.dimText $" ({Stdlib.Int.toString pkg.propagatedCount} propagated)" else "" Stdlib.printLine $" {kindLabel pkg.kind} {pkg.name}{propText}") let diffLines = diffForItems ops branchId parentId items @@ -653,7 +656,7 @@ let execute (cliState: Darklang.Cli.AppState) (args: List) : Darklang.Cl Stdlib.print "\u001b[?1049h" let screen = if showAll then - Screen.BranchList (BranchListState { items = loadBranchList (); selected = 0L }) + Screen.BranchList (BranchListState { items = loadBranchList (); selected = 0I }) else buildDetailForBranch branchId let app = makeSubApp (AppModel { screen = screen; branchId = branchId; showAll = showAll }) diff --git a/packages/darklang/cli/scm/review/core.dark b/packages/darklang/cli/scm/review/core.dark index b1859ec0e6..2701f63010 100644 --- a/packages/darklang/cli/scm/review/core.dark +++ b/packages/darklang/cli/scm/review/core.dark @@ -4,17 +4,17 @@ type PackageItem = { name: String kind: String modulePath: String - propagatedCount: Int64 } + propagatedCount: Int } type BranchReviewItem = { branchId: Uuid branchName: String - wipCount: Int64 - committedCount: Int64 } + wipCount: Int + committedCount: Int } type BranchListState = { items: List - selected: Int64 } + selected: Int } type DetailItem = | ModuleHeader of String @@ -24,20 +24,20 @@ type DetailState = { branchName: String branchId: Uuid flatItems: List - selected: Int64 } + selected: Int } type CommitEntry = { hash: String fullHash: String message: String date: String - opCount: Int64 } + opCount: Int } type CommitListState = { branchName: String branchId: Uuid commits: List - selected: Int64 + selected: Int returnTo: DetailState } type DiffReturnTo = @@ -47,7 +47,7 @@ type DiffReturnTo = type DiffState = { itemName: String diffLines: List - scrollOffset: Int64 + scrollOffset: Int returnTo: DiffReturnTo } type Screen = @@ -67,17 +67,17 @@ type KeyResult = // ── Navigation helpers ── -let moveUp (selected: Int64) : Int64 = - if selected > 0L then selected - 1L else selected +let moveUp (selected: Int) : Int = + if selected > 0I then selected - 1I else selected -let moveDown (selected: Int64) (itemCount: Int64) : Int64 = - let maxIdx = itemCount - 1L - if selected < maxIdx then selected + 1L else selected +let moveDown (selected: Int) (itemCount: Int) : Int = + let maxIdx = itemCount - 1I + if selected < maxIdx then selected + 1I else selected /// Move up, skipping empty spacer items -let moveUpSkipping (selected: Int64) (items: List) : Int64 = +let moveUpSkipping (selected: Int) (items: List) : Int = let candidate = moveUp selected - match Stdlib.List.getAt items (Stdlib.Int.fromInt64 candidate) with + match Stdlib.List.getAt items candidate with | Some flatItem -> match flatItem with | ModuleHeader modPath -> @@ -87,10 +87,10 @@ let moveUpSkipping (selected: Int64) (items: List) : Int64 = | None -> candidate /// Move down, skipping empty spacer items -let moveDownSkipping (selected: Int64) (items: List) : Int64 = - let itemCount = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length items)) +let moveDownSkipping (selected: Int) (items: List) : Int = + let itemCount = Stdlib.List.length items let candidate = moveDown selected itemCount - match Stdlib.List.getAt items (Stdlib.Int.fromInt64 candidate) with + match Stdlib.List.getAt items candidate with | Some flatItem -> match flatItem with | ModuleHeader modPath -> @@ -99,6 +99,6 @@ let moveDownSkipping (selected: Int64) (items: List) : Int64 = | ItemEntry _pkg -> candidate | None -> candidate -let computeScrollOffset (selected: Int64) (visibleCount: Int64) : Int64 = - if selected >= visibleCount then selected - visibleCount + 1L - else 0L +let computeScrollOffset (selected: Int) (visibleCount: Int) : Int = + if selected >= visibleCount then selected - visibleCount + 1I + else 0I diff --git a/packages/darklang/cli/ui/components/button.dark b/packages/darklang/cli/ui/components/button.dark index 75d6b888e9..8ca0ff2df3 100644 --- a/packages/darklang/cli/ui/components/button.dark +++ b/packages/darklang/cli/ui/components/button.dark @@ -9,9 +9,9 @@ type ButtonModel = let createButton (text: String) (color: Core.Types.Color) (action: Unit -> Unit) : Core.Types.Component = let model = ButtonModel { text = text; color = color; size = Core.Types.Size.Normal; disabled = false; action = action } - let textWidth = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length text)) - let buttonWidth = textWidth + 4L // 2 for borders + 2 for padding - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = buttonWidth; height = 3L } } + let textWidth = Stdlib.String.length text + let buttonWidth = textWidth + 4I // 2 for borders + 2 for padding + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0I; y = 0I }; dimensions = Core.Types.Dimensions { width = buttonWidth; height = 3I } } Core.Types.Component { id = "button-" ++ text model = model @@ -25,10 +25,10 @@ let renderButton (component: Core.Types.Component) (context: Core.T let hasFocus = context.hasFocus && component.state == Core.Types.ComponentState.Focused // Calculate padding based on raw text length (before ANSI codes) - let innerWidth = component.bounds.dimensions.width - 2L - let textLen = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length model.text)) + let innerWidth = component.bounds.dimensions.width - 2I + let textLen = Stdlib.String.length model.text let totalPadding = innerWidth - textLen - let leftPad = Stdlib.Int64.divide totalPadding 2L + let leftPad = Stdlib.Int.divide totalPadding 2I let rightPad = totalPadding - leftPad // Style the text @@ -41,12 +41,12 @@ let renderButton (component: Core.Types.Component) (context: Core.T Core.Rendering.colorize model.color model.text // Build padded text with spacing around styled content - let paddedText = Stdlib.String.repeat " " (Stdlib.Int.fromInt64 leftPad) ++ styledText ++ Stdlib.String.repeat " " (Stdlib.Int.fromInt64 rightPad) + let paddedText = Stdlib.String.repeat " " leftPad ++ styledText ++ Stdlib.String.repeat " " rightPad let focusIndicator = if hasFocus then "► " else " " - [ focusIndicator ++ "┌" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 2L)) ++ "┐" + [ focusIndicator ++ "┌" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 2I) ++ "┐" focusIndicator ++ "│" ++ paddedText ++ "│" - focusIndicator ++ "└" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 2L)) ++ "┘" ] + focusIndicator ++ "└" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 2I) ++ "┘" ] let setButtonText (component: Core.Types.Component) (text: String) : Core.Types.Component = let model = component.model diff --git a/packages/darklang/cli/ui/components/card.dark b/packages/darklang/cli/ui/components/card.dark index d4573b4657..bd8a41ea05 100644 --- a/packages/darklang/cli/ui/components/card.dark +++ b/packages/darklang/cli/ui/components/card.dark @@ -18,14 +18,14 @@ type CardModel = footer: List headerColor: Core.Types.Color borderColor: Core.Types.Color - width: Int64 - height: Int64 + width: Int + height: Int hasShadow: Bool isRounded: Bool } -let createCard (title: String) (content: List) (width: Int64) (height: Int64) : Core.Types.Component = +let createCard (title: String) (content: List) (width: Int) (height: Int) : Core.Types.Component = let model = CardModel { title = title; subtitle = ""; content = content; footer = []; headerColor = Core.Types.Color.Default; borderColor = Core.Types.Color.Default; width = width; height = height; hasShadow = false; isRounded = false } - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = width; height = height } } + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0I; y = 0I }; dimensions = Core.Types.Dimensions { width = width; height = height } } Core.Types.Component { id = "card-" ++ title model = model @@ -51,15 +51,15 @@ let renderCard (component: Core.Types.Component) (context: Core.Types if Stdlib.String.isEmpty model.title && Stdlib.String.isEmpty model.subtitle then [] else - let innerWidth = model.width - 4L + let innerWidth = model.width - 4I let titleLine = if Stdlib.String.isEmpty model.title then "" else // Calculate padding based on raw text, then apply styling - let titleLen = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length model.title)) - let rightPad = if innerWidth > titleLen then Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (innerWidth - titleLen)) else "" + let titleLen = Stdlib.String.length model.title + let rightPad = if innerWidth > titleLen then Stdlib.String.repeat " " (innerWidth - titleLen) else "" let styledTitle = Core.Rendering.colorize model.headerColor (Core.Rendering.bold model.title) left ++ " " ++ styledTitle ++ rightPad ++ " " ++ right @@ -70,26 +70,26 @@ let renderCard (component: Core.Types.Component) (context: Core.Types let paddedSubtitle = Core.Rendering.padText model.subtitle innerWidth Core.Types.Alignment.Left left ++ " " ++ paddedSubtitle ++ " " ++ right - let headerSeparator = left ++ Stdlib.String.repeat horizontal (Stdlib.Int.fromInt64 (model.width - 2L)) ++ right + let headerSeparator = left ++ Stdlib.String.repeat horizontal (model.width - 2I) ++ right [titleLine; subtitleLine; headerSeparator] |> Stdlib.List.filter (fun line -> Stdlib.Bool.not (Stdlib.String.isEmpty line)) // Create content section let contentLines = - let maxContentHeight = (Stdlib.Int.fromInt64 (model.height - 2L)) - Stdlib.List.length headerLines - Stdlib.List.length model.footer + let maxContentHeight = (model.height - 2I) - Stdlib.List.length headerLines - Stdlib.List.length model.footer let paddedContent = model.content |> Stdlib.List.take maxContentHeight |> Stdlib.List.map (fun line -> - let truncatedLine = Core.Rendering.truncateText line (model.width - 4L) - let paddedLine = Core.Rendering.padText truncatedLine (model.width - 4L) Core.Types.Alignment.Left + let truncatedLine = Core.Rendering.truncateText line (model.width - 4I) + let paddedLine = Core.Rendering.padText truncatedLine (model.width - 4I) Core.Types.Alignment.Left left ++ " " ++ paddedLine ++ " " ++ right) let remainingHeight = maxContentHeight - Stdlib.List.length paddedContent let emptyLines = if remainingHeight > 0I then - let emptyLine = left ++ Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (model.width - 2L)) ++ right + let emptyLine = left ++ Stdlib.String.repeat " " (model.width - 2I) ++ right match Stdlib.List.repeat remainingHeight emptyLine with | Ok lines -> lines | Error _ -> [] @@ -104,11 +104,11 @@ let renderCard (component: Core.Types.Component) (context: Core.Types if Stdlib.List.isEmpty model.footer then [] else - let footerSeparator = left ++ (Stdlib.String.repeat horizontal (Stdlib.Int.fromInt64 (model.width - 2L))) ++ right + let footerSeparator = left ++ (Stdlib.String.repeat horizontal (model.width - 2I)) ++ right let footerContent = model.footer |> Stdlib.List.map (fun line -> - let paddedLine = Core.Rendering.padText line (model.width - 4L) Core.Types.Alignment.Left + let paddedLine = Core.Rendering.padText line (model.width - 4I) Core.Types.Alignment.Left left ++ " " ++ paddedLine ++ " " ++ right) [footerSeparator] @@ -117,11 +117,11 @@ let renderCard (component: Core.Types.Component) (context: Core.Types // Create borders let topBorder = if Stdlib.List.isEmpty headerLines then - top ++ (Stdlib.String.repeat horizontal (Stdlib.Int.fromInt64 (model.width - 2L))) ++ topRight + top ++ (Stdlib.String.repeat horizontal (model.width - 2I)) ++ topRight else - top ++ (Stdlib.String.repeat horizontal (Stdlib.Int.fromInt64 (model.width - 2L))) ++ topRight + top ++ (Stdlib.String.repeat horizontal (model.width - 2I)) ++ topRight - let bottomBorder = bottom ++ (Stdlib.String.repeat horizontal (Stdlib.Int.fromInt64 (model.width - 2L))) ++ bottomRight + let bottomBorder = bottom ++ (Stdlib.String.repeat horizontal (model.width - 2I)) ++ bottomRight // Combine all sections let cardContent = @@ -137,11 +137,11 @@ let renderCard (component: Core.Types.Component) (context: Core.Types cardContent |> Stdlib.List.indexedMap (fun i line -> if i == Stdlib.List.length cardContent - 1I then - line ++ " " ++ (Core.Rendering.dim (Stdlib.String.repeat "▄" (Stdlib.Int.fromInt64 (model.width - 1L)))) + line ++ " " ++ (Core.Rendering.dim (Stdlib.String.repeat "▄" (model.width - 1I))) else line ++ Core.Rendering.dim "▌") - let shadowBottom = " " ++ (Core.Rendering.dim (Stdlib.String.repeat "▀" (Stdlib.Int.fromInt64 model.width))) + let shadowBottom = " " ++ (Core.Rendering.dim (Stdlib.String.repeat "▀" model.width)) shadowedContent |> Stdlib.List.append [shadowBottom] else @@ -180,17 +180,17 @@ type MediaCardModel = { title: String description: String mediaPlaceholder: String - mediaWidth: Int64 - mediaHeight: Int64 + mediaWidth: Int + mediaHeight: Int actions: List - width: Int64 - height: Int64 } + width: Int + height: Int } -let createMediaCard (title: String) (description: String) (mediaWidth: Int64) (mediaHeight: Int64) : Core.Types.Component = - let totalWidth = mediaWidth + 4L - let totalHeight = mediaHeight + 6L +let createMediaCard (title: String) (description: String) (mediaWidth: Int) (mediaHeight: Int) : Core.Types.Component = + let totalWidth = mediaWidth + 4I + let totalHeight = mediaHeight + 6I let model = MediaCardModel { title = title; description = description; mediaPlaceholder = "📷"; mediaWidth = mediaWidth; mediaHeight = mediaHeight; actions = []; width = totalWidth; height = totalHeight } - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = totalWidth; height = totalHeight } } + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0I; y = 0I }; dimensions = Core.Types.Dimensions { width = totalWidth; height = totalHeight } } Core.Types.Component { id = "mediacard-" ++ title model = model @@ -202,33 +202,33 @@ let createMediaCard (title: String) (description: String) (mediaWidth: Int64) (m let renderMediaCard (component: Core.Types.Component) (context: Core.Types.RenderContext) : List = let model = component.model - let topBorder = "┌" ++ (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L))) ++ "┐" - let bottomBorder = "└" ++ (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L))) ++ "┘" + let topBorder = "┌" ++ (Stdlib.String.repeat "─" (model.width - 2I)) ++ "┐" + let bottomBorder = "└" ++ (Stdlib.String.repeat "─" (model.width - 2I)) ++ "┘" // Create media placeholder let mediaLines = - let centerY = Stdlib.Int.fromInt64 (Stdlib.Int64.divide model.mediaHeight 2L) - (Stdlib.List.range 0I (Stdlib.Int.fromInt64 model.mediaHeight)) + let centerY = Stdlib.Int.divide model.mediaHeight 2I + (Stdlib.List.range 0I model.mediaHeight) |> Stdlib.List.map (fun i -> if i == centerY then let centeredPlaceholder = Core.Rendering.padText model.mediaPlaceholder model.mediaWidth Core.Types.Alignment.Center - let borderedLine = Core.Rendering.padText centeredPlaceholder (model.width - 4L) Core.Types.Alignment.Center + let borderedLine = Core.Rendering.padText centeredPlaceholder (model.width - 4I) Core.Types.Alignment.Center "│ " ++ borderedLine ++ " │" else - let emptyLine = Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (model.width - 4L)) + let emptyLine = Stdlib.String.repeat " " (model.width - 4I) "│ " ++ emptyLine ++ " │") // Create title and description let titleLine = let styledTitle = Core.Rendering.bold model.title - let paddedTitle = Core.Rendering.padText styledTitle (model.width - 4L) Core.Types.Alignment.Left + let paddedTitle = Core.Rendering.padText styledTitle (model.width - 4I) Core.Types.Alignment.Left "│ " ++ paddedTitle ++ " │" let descLine = - let paddedDesc = Core.Rendering.padText model.description (model.width - 4L) Core.Types.Alignment.Left + let paddedDesc = Core.Rendering.padText model.description (model.width - 4I) Core.Types.Alignment.Left "│ " ++ paddedDesc ++ " │" - let separatorLine = "├" ++ (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L))) ++ "┤" + let separatorLine = "├" ++ (Stdlib.String.repeat "─" (model.width - 2I)) ++ "┤" // Create actions if any let actionLines = @@ -236,7 +236,7 @@ let renderMediaCard (component: Core.Types.Component) (context: [] else let actionText = Stdlib.String.join " | " model.actions - let paddedActions = Core.Rendering.padText actionText (model.width - 4L) Core.Types.Alignment.Center + let paddedActions = Core.Rendering.padText actionText (model.width - 4I) Core.Types.Alignment.Center ["│ " ++ paddedActions ++ " │"] [topBorder] diff --git a/packages/darklang/cli/ui/components/divider.dark b/packages/darklang/cli/ui/components/divider.dark index abcdd9f024..a4899b2304 100644 --- a/packages/darklang/cli/ui/components/divider.dark +++ b/packages/darklang/cli/ui/components/divider.dark @@ -3,11 +3,11 @@ module Darklang.CLI.UI.Components.Divider type DividerModel = { character: String color: Core.Types.Color - length: Int64 } + length: Int } -let createDivider (character: String) (length: Int64) (color: Core.Types.Color) : Core.Types.Component = +let createDivider (character: String) (length: Int) (color: Core.Types.Color) : Core.Types.Component = let model = DividerModel { character = character; color = color; length = length } - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = length; height = 1L } } + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0I; y = 0I }; dimensions = Core.Types.Dimensions { width = length; height = 1I } } Core.Types.Component { id = "divider" model = model @@ -18,7 +18,7 @@ let createDivider (character: String) (length: Int64) (color: Core.Types.Color) let renderDivider (component: Core.Types.Component) (context: Core.Types.RenderContext) : List = let model = component.model - let line = Stdlib.String.repeat model.character (Stdlib.Int.fromInt64 model.length) + let line = Stdlib.String.repeat model.character model.length let coloredLine = Core.Rendering.colorize model.color line [ coloredLine ] @@ -26,9 +26,9 @@ let setDividerCharacter (component: Core.Types.Component) (charact let model = component.model { component with model = { model with character = character } } -let setDividerLength (component: Core.Types.Component) (length: Int64) : Core.Types.Component = +let setDividerLength (component: Core.Types.Component) (length: Int) : Core.Types.Component = let model = component.model - let newBounds = Core.Types.Bounds { position = component.bounds.position; dimensions = Core.Types.Dimensions { width = length; height = 1L } } + let newBounds = Core.Types.Bounds { position = component.bounds.position; dimensions = Core.Types.Dimensions { width = length; height = 1I } } { component with model = { model with length = length } bounds = newBounds } diff --git a/packages/darklang/cli/ui/components/dropdown.dark b/packages/darklang/cli/ui/components/dropdown.dark index 6d45cf1730..1ec880f1e6 100644 --- a/packages/darklang/cli/ui/components/dropdown.dark +++ b/packages/darklang/cli/ui/components/dropdown.dark @@ -11,21 +11,21 @@ type DropdownItem = // Simple Dropdown Component type DropdownModel = { items: List - selectedIndex: Int64 + selectedIndex: Int isOpen: Bool placeholder: String disabled: Bool - maxHeight: Int64 } + maxHeight: Int } let createDropdown (placeholder: String) (items: List) : Core.Types.Component = - let model = DropdownModel { items = items; selectedIndex = -1L; isOpen = false; placeholder = placeholder; disabled = false; maxHeight = 8L } + let model = DropdownModel { items = items; selectedIndex = -1I; isOpen = false; placeholder = placeholder; disabled = false; maxHeight = 8I } let maxWidth = items |> Stdlib.List.map (fun item -> Stdlib.String.length item.label) |> Stdlib.List.append [Stdlib.String.length placeholder] |> Stdlib.List.fold 20I (fun acc len -> if len > acc then len else acc) - let height = if model.isOpen then Stdlib.Int64.min model.maxHeight ((Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length items))) + 2L) else 1L - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = (Builtin.unwrap (Stdlib.Int.toInt64 maxWidth)) + 4L; height = height } } + let height = if model.isOpen then Stdlib.Int.min model.maxHeight ((Stdlib.List.length items) + 2I) else 1I + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0I; y = 0I }; dimensions = Core.Types.Dimensions { width = maxWidth + 4I; height = height } } Core.Types.Component { id = "dropdown" model = model @@ -39,14 +39,14 @@ let renderDropdown (component: Core.Types.Component) (context: Co let hasFocus = context.hasFocus && component.state == Core.Types.ComponentState.Focused let displayText = - if model.selectedIndex >= 0L then - match Stdlib.List.getAt model.items (Stdlib.Int.fromInt64 model.selectedIndex) with + if model.selectedIndex >= 0I then + match Stdlib.List.getAt model.items model.selectedIndex with | Some item -> item.label | None -> model.placeholder else model.placeholder - let paddedText = Core.Rendering.padText displayText (component.bounds.dimensions.width - 6L) Core.Types.Alignment.Left + let paddedText = Core.Rendering.padText displayText (component.bounds.dimensions.width - 6I) Core.Types.Alignment.Left let arrow = if model.isOpen then "▲" else "▼" let focusIndicator = if hasFocus then "► " else " " let borderColor = if model.disabled then Core.Types.Color.Dark else Core.Types.Color.Default @@ -58,13 +58,13 @@ let renderDropdown (component: Core.Types.Component) (context: Co if model.isOpen then let visibleItems = model.items - |> Stdlib.List.take (Stdlib.Int.fromInt64 model.maxHeight) + |> Stdlib.List.take model.maxHeight |> Stdlib.List.indexedMap (fun i item -> if item.separator then - " ├" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 4L)) ++ "┤" + " ├" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 4I) ++ "┤" else - let isSelected = (Builtin.unwrap (Stdlib.Int.toInt64 i)) == model.selectedIndex - let isHovered = hasFocus && (Builtin.unwrap (Stdlib.Int.toInt64 i)) == model.selectedIndex + let isSelected = i == model.selectedIndex + let isHovered = hasFocus && i == model.selectedIndex let prefix = if isSelected then "●" else " " let itemColor = @@ -73,20 +73,20 @@ let renderDropdown (component: Core.Types.Component) (context: Co else Core.Types.Color.Default let styledLabel = Core.Rendering.colorize itemColor (prefix ++ " " ++ item.label) - let paddedLabel = Core.Rendering.padText styledLabel (component.bounds.dimensions.width - 4L) Core.Types.Alignment.Left + let paddedLabel = Core.Rendering.padText styledLabel (component.bounds.dimensions.width - 4I) Core.Types.Alignment.Left " │ " ++ paddedLabel ++ " │") - let bottomBorder = " └" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 4L)) ++ "┘" + let bottomBorder = " └" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 4I) ++ "┘" [mainLine] |> Stdlib.List.append visibleItems |> Stdlib.List.append [bottomBorder] else [mainLine] -let selectDropdownItem (component: Core.Types.Component) (index: Int64) : Core.Types.Component = +let selectDropdownItem (component: Core.Types.Component) (index: Int) : Core.Types.Component = let model = component.model - if index >= 0L && index < (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length model.items))) then - match Stdlib.List.getAt model.items (Stdlib.Int.fromInt64 index) with + if index >= 0I && index < (Stdlib.List.length model.items) then + match Stdlib.List.getAt model.items index with | Some item -> if item.disabled || item.separator then component @@ -114,22 +114,22 @@ let closeDropdown (component: Core.Types.Component) : Core.Types. // Multi-Select Dropdown Component type MultiSelectModel = { items: List - selectedIndices: List + selectedIndices: List isOpen: Bool placeholder: String disabled: Bool - maxHeight: Int64 - maxSelections: Int64 } + maxHeight: Int + maxSelections: Int } -let createMultiSelect (placeholder: String) (items: List) (maxSelections: Int64) : Core.Types.Component = - let model = MultiSelectModel { items = items; selectedIndices = []; isOpen = false; placeholder = placeholder; disabled = false; maxHeight = 8L; maxSelections = maxSelections } +let createMultiSelect (placeholder: String) (items: List) (maxSelections: Int) : Core.Types.Component = + let model = MultiSelectModel { items = items; selectedIndices = []; isOpen = false; placeholder = placeholder; disabled = false; maxHeight = 8I; maxSelections = maxSelections } let maxWidth = items |> Stdlib.List.map (fun item -> Stdlib.String.length item.label) |> Stdlib.List.append [Stdlib.String.length placeholder] |> Stdlib.List.fold 25I (fun acc len -> if len > acc then len else acc) - let height = if model.isOpen then Stdlib.Int64.min model.maxHeight ((Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length items))) + 2L) else 1L - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = (Builtin.unwrap (Stdlib.Int.toInt64 maxWidth)) + 4L; height = height } } + let height = if model.isOpen then Stdlib.Int.min model.maxHeight ((Stdlib.List.length items) + 2I) else 1I + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0I; y = 0I }; dimensions = Core.Types.Dimensions { width = maxWidth + 4I; height = height } } Core.Types.Component { id = "multiselect" model = model @@ -149,7 +149,7 @@ let renderMultiSelect (component: Core.Types.Component) (conte let selectedCount = Stdlib.List.length model.selectedIndices Stdlib.Int.toString selectedCount ++ " selected" - let paddedText = Core.Rendering.padText displayText (component.bounds.dimensions.width - 6L) Core.Types.Alignment.Left + let paddedText = Core.Rendering.padText displayText (component.bounds.dimensions.width - 6I) Core.Types.Alignment.Left let arrow = if model.isOpen then "▲" else "▼" let focusIndicator = if hasFocus then "► " else " " let borderColor = if model.disabled then Core.Types.Color.Dark else Core.Types.Color.Default @@ -161,12 +161,12 @@ let renderMultiSelect (component: Core.Types.Component) (conte if model.isOpen then let visibleItems = model.items - |> Stdlib.List.take (Stdlib.Int.fromInt64 model.maxHeight) + |> Stdlib.List.take model.maxHeight |> Stdlib.List.indexedMap (fun i item -> if item.separator then - " ├" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 4L)) ++ "┤" + " ├" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 4I) ++ "┤" else - let isSelected = Stdlib.List.``member`` model.selectedIndices (Builtin.unwrap (Stdlib.Int.toInt64 i)) + let isSelected = Stdlib.List.``member`` model.selectedIndices i let checkMark = if isSelected then "☑" else "☐" let itemColor = @@ -175,20 +175,20 @@ let renderMultiSelect (component: Core.Types.Component) (conte else Core.Types.Color.Default let styledLabel = Core.Rendering.colorize itemColor (checkMark ++ " " ++ item.label) - let paddedLabel = Core.Rendering.padText styledLabel (component.bounds.dimensions.width - 4L) Core.Types.Alignment.Left + let paddedLabel = Core.Rendering.padText styledLabel (component.bounds.dimensions.width - 4I) Core.Types.Alignment.Left " │ " ++ paddedLabel ++ " │") - let bottomBorder = " └" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 4L)) ++ "┘" + let bottomBorder = " └" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 4I) ++ "┘" [mainLine] |> Stdlib.List.append visibleItems |> Stdlib.List.append [bottomBorder] else [mainLine] -let toggleMultiSelectItem (component: Core.Types.Component) (index: Int64) : Core.Types.Component = +let toggleMultiSelectItem (component: Core.Types.Component) (index: Int) : Core.Types.Component = let model = component.model - if index >= 0L && index < (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length model.items))) then - match Stdlib.List.getAt model.items (Stdlib.Int.fromInt64 index) with + if index >= 0I && index < (Stdlib.List.length model.items) then + match Stdlib.List.getAt model.items index with | Some item -> if item.disabled || item.separator then component @@ -198,7 +198,7 @@ let toggleMultiSelectItem (component: Core.Types.Component) (i if isSelected then Stdlib.List.filter model.selectedIndices (fun i -> i != index) else - if (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length model.selectedIndices))) < model.maxSelections then + if (Stdlib.List.length model.selectedIndices) < model.maxSelections then model.selectedIndices |> Stdlib.List.append [index] else @@ -215,13 +215,13 @@ type ContextMenuModel = position: Core.Types.Position } let createContextMenu (items: List) : Core.Types.Component = - let model = ContextMenuModel { items = items; isVisible = false; position = Core.Types.Position { x = 0L; y = 0L } } + let model = ContextMenuModel { items = items; isVisible = false; position = Core.Types.Position { x = 0I; y = 0I } } let maxWidth = items |> Stdlib.List.map (fun item -> Stdlib.String.length item.label + 4I) |> Stdlib.List.fold 15I (fun acc len -> if len > acc then len else acc) - let height = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length items))) + 2L - let bounds = Core.Types.Bounds { position = model.position; dimensions = Core.Types.Dimensions { width = Builtin.unwrap (Stdlib.Int.toInt64 maxWidth); height = height } } + let height = (Stdlib.List.length items) + 2I + let bounds = Core.Types.Bounds { position = model.position; dimensions = Core.Types.Dimensions { width = maxWidth; height = height } } Core.Types.Component { id = "contextmenu" model = model @@ -237,17 +237,17 @@ let renderContextMenu (component: Core.Types.Component) (conte else let hasFocus = context.hasFocus && component.state == Core.Types.ComponentState.Focused - let topBorder = "┌" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 2L)) ++ "┐" - let bottomBorder = "└" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 2L)) ++ "┘" + let topBorder = "┌" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 2I) ++ "┐" + let bottomBorder = "└" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 2I) ++ "┘" let menuItems = model.items |> Stdlib.List.map (fun item -> if item.separator then - "├" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 2L)) ++ "┤" + "├" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 2I) ++ "┤" else let itemColor = if item.disabled then Core.Types.Color.Dark else Core.Types.Color.Default - let paddedLabel = Core.Rendering.padText item.label (component.bounds.dimensions.width - 4L) Core.Types.Alignment.Left + let paddedLabel = Core.Rendering.padText item.label (component.bounds.dimensions.width - 4I) Core.Types.Alignment.Left let styledLabel = Core.Rendering.colorize itemColor paddedLabel "│ " ++ styledLabel ++ " │") diff --git a/packages/darklang/cli/ui/components/forms.dark b/packages/darklang/cli/ui/components/forms.dark index 218f5c68e1..9c7d295b8f 100644 --- a/packages/darklang/cli/ui/components/forms.dark +++ b/packages/darklang/cli/ui/components/forms.dark @@ -5,14 +5,14 @@ module Darklang.CLI.UI.Components.Forms type TextInputModel = { value: String placeholder: String - maxLength: Int64 + maxLength: Int disabled: Bool password: Bool - cursorPosition: Int64 } + cursorPosition: Int } -let createTextInput (placeholder: String) (maxLength: Int64) : Core.Types.Component = - let model = TextInputModel { value = ""; placeholder = placeholder; maxLength = maxLength; disabled = false; password = false; cursorPosition = 0L } - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = maxLength + 4L; height = 3L } } +let createTextInput (placeholder: String) (maxLength: Int) : Core.Types.Component = + let model = TextInputModel { value = ""; placeholder = placeholder; maxLength = maxLength; disabled = false; password = false; cursorPosition = 0I } + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0I; y = 0I }; dimensions = Core.Types.Dimensions { width = maxLength + 4I; height = 3I } } Core.Types.Component { id = "textinput" model = model @@ -24,7 +24,7 @@ let createTextInput (placeholder: String) (maxLength: Int64) : Core.Types.Compon let renderTextInput (component: Core.Types.Component) (context: Core.Types.RenderContext) : List = let model = component.model let hasFocus = context.hasFocus && component.state == Core.Types.ComponentState.Focused - let innerWidth = component.bounds.dimensions.width - 4L + let innerWidth = component.bounds.dimensions.width - 4I // Calculate padding based on raw text length let (rawValue, styledValue) = @@ -36,14 +36,14 @@ let renderTextInput (component: Core.Types.Component) (context: else (model.value, model.value) - let textLen = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length rawValue)) - let rightPad = if innerWidth > textLen then Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (innerWidth - textLen)) else "" + let textLen = Stdlib.String.length rawValue + let rightPad = if innerWidth > textLen then Stdlib.String.repeat " " (innerWidth - textLen) else "" let cursor = if hasFocus then "│" else " " let focusIndicator = if hasFocus then "► " else " " - [ focusIndicator ++ "┌" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 2L)) ++ "┐" + [ focusIndicator ++ "┌" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 2I) ++ "┐" focusIndicator ++ "│ " ++ styledValue ++ rightPad ++ cursor ++ " │" - focusIndicator ++ "└" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 2L)) ++ "┘" ] + focusIndicator ++ "└" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 2I) ++ "┘" ] let updateTextInput (component: Core.Types.Component) (event: Core.Types.ComponentEvent) : Core.Types.Component = match event with @@ -51,23 +51,23 @@ let updateTextInput (component: Core.Types.Component) (event: Co let model = component.model (match keyEvent with | Character char -> - if (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length model.value))) < model.maxLength then + if (Stdlib.String.length model.value) < model.maxLength then let newValue = model.value ++ char - { component with model = { model with value = newValue; cursorPosition = model.cursorPosition + 1L } } + { component with model = { model with value = newValue; cursorPosition = model.cursorPosition + 1I } } else component | Backspace -> - if model.cursorPosition > 0L then - let newValue = Stdlib.String.slice model.value 0I (Stdlib.Int.fromInt64 (model.cursorPosition - 1L)) - { component with model = { model with value = newValue; cursorPosition = model.cursorPosition - 1L } } + if model.cursorPosition > 0I then + let newValue = Stdlib.String.slice model.value 0I (model.cursorPosition - 1I) + { component with model = { model with value = newValue; cursorPosition = model.cursorPosition - 1I } } else component | Left -> - let newPos = if model.cursorPosition > 0L then model.cursorPosition - 1L else 0L + let newPos = if model.cursorPosition > 0I then model.cursorPosition - 1I else 0I { component with model = { model with cursorPosition = newPos } } | Right -> - let maxPos = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length model.value)) - let newPos = if model.cursorPosition < maxPos then model.cursorPosition + 1L else maxPos + let maxPos = Stdlib.String.length model.value + let newPos = if model.cursorPosition < maxPos then model.cursorPosition + 1I else maxPos { component with model = { model with cursorPosition = newPos } } | _ -> component) | _ -> component @@ -81,8 +81,8 @@ type CheckboxModel = let createCheckbox (label: String) (checked: Bool) : Core.Types.Component = let model = CheckboxModel { checked = checked; label = label; disabled = false } - let labelLength = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length label)) - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = labelLength + 6L; height = 1L } } + let labelLength = Stdlib.String.length label + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0I; y = 0I }; dimensions = Core.Types.Dimensions { width = labelLength + 6I; height = 1I } } Core.Types.Component { id = "checkbox-" ++ label model = model @@ -116,17 +116,17 @@ let toggleCheckbox (component: Core.Types.Component) : Core.Types // Radio Button Group Component type RadioModel = { options: List - selectedIndex: Int64 + selectedIndex: Int disabled: Bool } -let createRadioGroup (options: List) (selectedIndex: Int64) : Core.Types.Component = +let createRadioGroup (options: List) (selectedIndex: Int) : Core.Types.Component = let model = RadioModel { options = options; selectedIndex = selectedIndex; disabled = false } let maxWidth = options - |> Stdlib.List.map (fun opt -> (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length opt))) + 6L) - |> Stdlib.List.fold 20L (fun acc len -> if len > acc then len else acc) - let height = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length options)) - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = maxWidth; height = height } } + |> Stdlib.List.map (fun opt -> (Stdlib.String.length opt) + 6I) + |> Stdlib.List.fold 20I (fun acc len -> if len > acc then len else acc) + let height = Stdlib.List.length options + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0I; y = 0I }; dimensions = Core.Types.Dimensions { width = maxWidth; height = height } } Core.Types.Component { id = "radiogroup" model = model @@ -141,20 +141,20 @@ let renderRadioGroup (component: Core.Types.Component) (context: Cor model.options |> Stdlib.List.indexedMap (fun i option -> - let isSelected = (Builtin.unwrap (Stdlib.Int.toInt64 i)) == model.selectedIndex + let isSelected = i == model.selectedIndex let radioSymbol = if isSelected then "●" else "○" let boxColor = if model.disabled then Core.Types.Color.Dark else Core.Types.Color.Primary let labelColor = if model.disabled then Core.Types.Color.Dark else Core.Types.Color.Default let styledRadio = Core.Rendering.colorize boxColor ("(" ++ radioSymbol ++ ")") let styledLabel = Core.Rendering.colorize labelColor option - let focusIndicator = if hasFocus && (Builtin.unwrap (Stdlib.Int.toInt64 i)) == model.selectedIndex then "► " else " " + let focusIndicator = if hasFocus && i == model.selectedIndex then "► " else " " focusIndicator ++ styledRadio ++ " " ++ styledLabel) -let selectRadioOption (component: Core.Types.Component) (index: Int64) : Core.Types.Component = +let selectRadioOption (component: Core.Types.Component) (index: Int) : Core.Types.Component = let model = component.model - if model.disabled || index < 0L || index >= (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length model.options))) then + if model.disabled || index < 0I || index >= (Stdlib.List.length model.options) then component else { component with model = { model with selectedIndex = index } } @@ -163,18 +163,18 @@ let selectRadioOption (component: Core.Types.Component) (index: Int6 // Select Dropdown Component type SelectModel = { options: List - selectedIndex: Int64 + selectedIndex: Int isOpen: Bool disabled: Bool } -let createSelect (options: List) (selectedIndex: Int64) : Core.Types.Component = +let createSelect (options: List) (selectedIndex: Int) : Core.Types.Component = let model = SelectModel { options = options; selectedIndex = selectedIndex; isOpen = false; disabled = false } let maxWidth = options - |> Stdlib.List.map (fun opt -> Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length opt))) - |> Stdlib.List.fold 10L (fun acc len -> if len > acc then len else acc) - let baseHeight = if model.isOpen then (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length options))) + 2L else 1L - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = maxWidth + 4L; height = baseHeight } } + |> Stdlib.List.map (fun opt -> Stdlib.String.length opt) + |> Stdlib.List.fold 10I (fun acc len -> if len > acc then len else acc) + let baseHeight = if model.isOpen then (Stdlib.List.length options) + 2I else 1I + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0I; y = 0I }; dimensions = Core.Types.Dimensions { width = maxWidth + 4I; height = baseHeight } } Core.Types.Component { id = "select" model = model @@ -188,11 +188,11 @@ let renderSelect (component: Core.Types.Component) (context: Core.T let hasFocus = context.hasFocus && component.state == Core.Types.ComponentState.Focused let selectedOption = - match Stdlib.List.getAt model.options (Stdlib.Int.fromInt64 model.selectedIndex) with + match Stdlib.List.getAt model.options model.selectedIndex with | Some opt -> opt | None -> "" - let paddedOption = Core.Rendering.padText selectedOption (component.bounds.dimensions.width - 4L) Core.Types.Alignment.Left + let paddedOption = Core.Rendering.padText selectedOption (component.bounds.dimensions.width - 4I) Core.Types.Alignment.Left let arrow = if model.isOpen then "▲" else "▼" let focusIndicator = if hasFocus then "► " else " " @@ -202,16 +202,16 @@ let renderSelect (component: Core.Types.Component) (context: Core.T let optionLines = model.options |> Stdlib.List.indexedMap (fun i option -> - let isSelected = (Builtin.unwrap (Stdlib.Int.toInt64 i)) == model.selectedIndex + let isSelected = i == model.selectedIndex let prefix = if isSelected then "►" else " " let styledOption = if isSelected then Core.Rendering.colorize Core.Types.Color.Primary (prefix ++ " " ++ option) else prefix ++ " " ++ option - " │" ++ Core.Rendering.padText styledOption (component.bounds.dimensions.width - 4L) Core.Types.Alignment.Left ++ "│") + " │" ++ Core.Rendering.padText styledOption (component.bounds.dimensions.width - 4I) Core.Types.Alignment.Left ++ "│") - let bottomLine = " └" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 2L)) ++ "┘" + let bottomLine = " └" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 2I) ++ "┘" [mainLine] |> Stdlib.List.append optionLines |> Stdlib.List.append [bottomLine] @@ -226,10 +226,10 @@ type SliderModel = max: Float step: Float label: String - width: Int64 + width: Int disabled: Bool } -let createSlider (label: String) (min: Float) (max: Float) (value: Float) (width: Int64) : Core.Types.Component = +let createSlider (label: String) (min: Float) (max: Float) (value: Float) (width: Int) : Core.Types.Component = let model = SliderModel { value = value @@ -239,7 +239,7 @@ let createSlider (label: String) (min: Float) (max: Float) (value: Float) (width ; label = label ; width = width ; disabled = false } - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = width + 4L; height = 3L } } + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0I; y = 0I }; dimensions = Core.Types.Dimensions { width = width + 4I; height = 3I } } Core.Types.Component { id = "slider-" ++ label model = model @@ -256,20 +256,18 @@ let renderSlider (component: Core.Types.Component) (context: Core.T (Stdlib.Float.subtract model.value model.min) |> fun diff -> Stdlib.Float.divide diff (Stdlib.Float.subtract model.max model.min) let filledWidth = - (Stdlib.Float.multiply (Stdlib.Int64.toFloat model.width) percentage) + (Stdlib.Float.multiply (Stdlib.Int.toFloat model.width) percentage) |> Stdlib.Float.round - |> Stdlib.Int.toInt64 - |> Builtin.unwrap - let emptyWidth = Stdlib.Int64.subtract model.width filledWidth + let emptyWidth = model.width - filledWidth - let track = Stdlib.String.repeat "═" (Stdlib.Int.fromInt64 filledWidth) ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 emptyWidth) + let track = Stdlib.String.repeat "═" filledWidth ++ Stdlib.String.repeat "─" emptyWidth let handle = "●" let valueText = "Value: " ++ Stdlib.Float.toString model.value let focusIndicator = if hasFocus then "► " else " " [ focusIndicator ++ model.label ++ " (" ++ valueText ++ ")" focusIndicator ++ "├" ++ track ++ "┤" - focusIndicator ++ Stdlib.String.repeat " " (Stdlib.Int.fromInt64 filledWidth) ++ handle ] + focusIndicator ++ Stdlib.String.repeat " " filledWidth ++ handle ] let updateSlider (component: Core.Types.Component) (direction: String) : Core.Types.Component = let model = component.model @@ -288,9 +286,9 @@ let updateSlider (component: Core.Types.Component) (direction: Stri // DateField Component type DateFieldModel = - { day: Int64 - month: Int64 - year: Int64 + { day: Int + month: Int + year: Int placeholder: String disabled: Bool focused: String } // "day", "month", "year", or "" @@ -298,13 +296,13 @@ type DateFieldModel = let createDateField (placeholder: String) : Core.Types.Component = let model = DateFieldModel - { day = 1L - ; month = 1L - ; year = 2024L + { day = 1I + ; month = 1I + ; year = 2024I ; placeholder = placeholder ; disabled = false ; focused = "" } - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = 20L; height = 3L } } + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0I; y = 0I }; dimensions = Core.Types.Dimensions { width = 20I; height = 3I } } Core.Types.Component { id = "datefield" model = model @@ -317,9 +315,9 @@ let renderDateField (component: Core.Types.Component) (context: let model = component.model let hasFocus = context.hasFocus && component.state == Core.Types.ComponentState.Focused - let dayStr = if model.day < 10L then "0" ++ Stdlib.Int64.toString model.day else Stdlib.Int64.toString model.day - let monthStr = if model.month < 10L then "0" ++ Stdlib.Int64.toString model.month else Stdlib.Int64.toString model.month - let yearStr = Stdlib.Int64.toString model.year + let dayStr = if model.day < 10I then "0" ++ Stdlib.Int.toString model.day else Stdlib.Int.toString model.day + let monthStr = if model.month < 10I then "0" ++ Stdlib.Int.toString model.month else Stdlib.Int.toString model.month + let yearStr = Stdlib.Int.toString model.year let dayPart = if model.focused == "day" && hasFocus then "[" ++ dayStr ++ "]" else dayStr let monthPart = if model.focused == "month" && hasFocus then "[" ++ monthStr ++ "]" else monthStr @@ -330,7 +328,7 @@ let renderDateField (component: Core.Types.Component) (context: [ focusIndicator ++ model.placeholder focusIndicator ++ "┌──────────────────┐" - focusIndicator ++ "│ " ++ Core.Rendering.padText dateValue 16L Core.Types.Alignment.Center ++ " │" + focusIndicator ++ "│ " ++ Core.Rendering.padText dateValue 16I Core.Types.Alignment.Center ++ " │" focusIndicator ++ "└──────────────────┘" ] let updateDateField (component: Core.Types.Component) (field: String) (increment: Bool) : Core.Types.Component = @@ -340,16 +338,16 @@ let updateDateField (component: Core.Types.Component) (field: St else let (newDay, newMonth, newYear) = if field == "day" then - let newDay = if increment then model.day + 1L else model.day - 1L - let clampedDay = if newDay > 31L then 1L else if newDay < 1L then 31L else newDay + let newDay = if increment then model.day + 1I else model.day - 1I + let clampedDay = if newDay > 31I then 1I else if newDay < 1I then 31I else newDay (clampedDay, model.month, model.year) else if field == "month" then - let newMonth = if increment then model.month + 1L else model.month - 1L - let clampedMonth = if newMonth > 12L then 1L else if newMonth < 1L then 12L else newMonth + let newMonth = if increment then model.month + 1I else model.month - 1I + let clampedMonth = if newMonth > 12I then 1I else if newMonth < 1I then 12I else newMonth (model.day, clampedMonth, model.year) else if field == "year" then - let newYear = if increment then model.year + 1L else model.year - 1L - let clampedYear = if newYear < 1900L then 1900L else if newYear > 2100L then 2100L else newYear + let newYear = if increment then model.year + 1I else model.year - 1I + let clampedYear = if newYear < 1900I then 1900I else if newYear > 2100I then 2100I else newYear (model.day, model.month, clampedYear) else (model.day, model.month, model.year) diff --git a/packages/darklang/cli/ui/components/label.dark b/packages/darklang/cli/ui/components/label.dark index f2089c83b7..918e7dff79 100644 --- a/packages/darklang/cli/ui/components/label.dark +++ b/packages/darklang/cli/ui/components/label.dark @@ -8,8 +8,8 @@ type LabelModel = let createLabel (text: String) (color: Core.Types.Color) : Core.Types.Component = let model = LabelModel { text = text; color = color; size = Core.Types.Size.Normal; bold = false } - let textLength = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length text)) - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = textLength; height = 1L } } + let textLength = Stdlib.String.length text + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0I; y = 0I }; dimensions = Core.Types.Dimensions { width = textLength; height = 1I } } Core.Types.Component { id = "label-" ++ text model = model @@ -31,8 +31,8 @@ let renderLabel (component: Core.Types.Component) (context: Core.Typ let setLabelText (component: Core.Types.Component) (text: String) : Core.Types.Component = let model = component.model - let textLength = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length text)) - let newBounds = Core.Types.Bounds { position = component.bounds.position; dimensions = Core.Types.Dimensions { width = textLength; height = 1L } } + let textLength = Stdlib.String.length text + let newBounds = Core.Types.Bounds { position = component.bounds.position; dimensions = Core.Types.Dimensions { width = textLength; height = 1I } } { component with model = { model with text = text } bounds = newBounds } diff --git a/packages/darklang/cli/ui/components/layout.dark b/packages/darklang/cli/ui/components/layout.dark index ec4836fcd5..193af44c79 100644 --- a/packages/darklang/cli/ui/components/layout.dark +++ b/packages/darklang/cli/ui/components/layout.dark @@ -3,14 +3,14 @@ module Darklang.CLI.UI.Components.Layout // Container Component type ContainerModel<'TChild> = { children: List<'TChild> - padding: Int64 + padding: Int border: Bool title: String } let createContainer (children: List<'TChild>) (title: String) (border: Bool) : Core.Types.Component> = - let model = ContainerModel { children = children; padding = 1L; border = border; title = title } + let model = ContainerModel { children = children; padding = 1I; border = border; title = title } // Calculate container size based on children (simplified) - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = 40L; height = 20L } } + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0I; y = 0I }; dimensions = Core.Types.Dimensions { width = 40I; height = 20I } } Core.Types.Component { id = "container-" ++ title model = model @@ -44,12 +44,12 @@ type PanelModel = let createPanel (title: String) (content: List) (color: Core.Types.Color) : Core.Types.Component = let model = PanelModel { content = content; title = title; color = color; collapsible = false; collapsed = false } - let contentHeight = if model.collapsed then 1L else (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length content))) + 2L + let contentHeight = if model.collapsed then 1I else (Stdlib.List.length content) + 2I let maxWidth = (Stdlib.List.push content title) - |> Stdlib.List.map (fun s -> Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length s))) - |> Stdlib.List.fold 20L (fun acc len -> if len > acc then len else acc) - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = maxWidth + 4L; height = contentHeight } } + |> Stdlib.List.map (fun s -> Stdlib.String.length s) + |> Stdlib.List.fold 20I (fun acc len -> if len > acc then len else acc) + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0I; y = 0I }; dimensions = Core.Types.Dimensions { width = maxWidth + 4I; height = contentHeight } } Core.Types.Component { id = "panel-" ++ title model = model @@ -83,17 +83,17 @@ let togglePanel (component: Core.Types.Component) : Core.Types.Compo // Grid Layout Component type GridModel<'TItem> = { items: List<'TItem> - columns: Int64 - spacing: Int64 - itemWidth: Int64 - itemHeight: Int64 } - -let createGrid (items: List<'TItem>) (columns: Int64) (itemWidth: Int64) (itemHeight: Int64) : Core.Types.Component> = - let model = GridModel { items = items; columns = columns; spacing = 1L; itemWidth = itemWidth; itemHeight = itemHeight } - let rows = Stdlib.Int64.divide ((Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length items))) + columns - 1L) columns - let totalWidth = columns * itemWidth + (columns - 1L) * model.spacing - let totalHeight = rows * itemHeight + (rows - 1L) * model.spacing - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = totalWidth; height = totalHeight } } + columns: Int + spacing: Int + itemWidth: Int + itemHeight: Int } + +let createGrid (items: List<'TItem>) (columns: Int) (itemWidth: Int) (itemHeight: Int) : Core.Types.Component> = + let model = GridModel { items = items; columns = columns; spacing = 1I; itemWidth = itemWidth; itemHeight = itemHeight } + let rows = Stdlib.Int.divide ((Stdlib.List.length items) + columns - 1I) columns + let totalWidth = columns * itemWidth + (columns - 1I) * model.spacing + let totalHeight = rows * itemHeight + (rows - 1I) * model.spacing + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0I; y = 0I }; dimensions = Core.Types.Dimensions { width = totalWidth; height = totalHeight } } Core.Types.Component { id = "grid" model = model @@ -102,25 +102,25 @@ let createGrid (items: List<'TItem>) (columns: Int64) (itemWidth: Int64) (itemHe visible = true focusable = true } -let renderGrid (component: Core.Types.Component>) (context: Core.Types.RenderContext) (renderItem: 'TItem -> Int64 -> Core.Types.RenderContext -> List) : List = +let renderGrid (component: Core.Types.Component>) (context: Core.Types.RenderContext) (renderItem: 'TItem -> Int -> Core.Types.RenderContext -> List) : List = let model = component.model // Simplified grid rendering - just render items in a vertical list for now model.items |> Stdlib.List.indexedMap (fun index item -> - let renderedItem = renderItem item (Builtin.unwrap (Stdlib.Int.toInt64 index)) context + let renderedItem = renderItem item index context renderedItem) |> Stdlib.List.flatten // Horizontal Stack Component type HStackModel<'TItem> = { items: List<'TItem> - spacing: Int64 + spacing: Int alignment: Core.Types.Alignment } -let createHStack (items: List<'TItem>) (spacing: Int64) (alignment: Core.Types.Alignment) : Core.Types.Component> = +let createHStack (items: List<'TItem>) (spacing: Int) (alignment: Core.Types.Alignment) : Core.Types.Component> = let model = HStackModel { items = items; spacing = spacing; alignment = alignment } // Calculate size based on items (simplified) - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = 60L; height = 5L } } + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0I; y = 0I }; dimensions = Core.Types.Dimensions { width = 60I; height = 5I } } Core.Types.Component { id = "hstack" model = model @@ -147,16 +147,16 @@ let renderHStack (component: Core.Types.Component>) (context match Stdlib.List.getAt itemLines lineIndex with | Some line -> line | None -> "") - |> Stdlib.String.join (Stdlib.String.repeat " " (Stdlib.Int.fromInt64 model.spacing))) + |> Stdlib.String.join (Stdlib.String.repeat " " model.spacing)) // Vertical Stack Component type VStackModel<'TItem> = { items: List<'TItem> - spacing: Int64 } + spacing: Int } -let createVStack (items: List<'TItem>) (spacing: Int64) : Core.Types.Component> = +let createVStack (items: List<'TItem>) (spacing: Int) : Core.Types.Component> = let model = VStackModel { items = items; spacing = spacing } - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = 40L; height = 20L } } + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0I; y = 0I }; dimensions = Core.Types.Dimensions { width = 40I; height = 20I } } Core.Types.Component { id = "vstack" model = model @@ -167,7 +167,7 @@ let createVStack (items: List<'TItem>) (spacing: Int64) : Core.Types.Component>) (context: Core.Types.RenderContext) (renderItem: 'TItem -> Core.Types.RenderContext -> List) : List = let model = component.model - let spacingLines = (Stdlib.List.range 0I (Stdlib.Int.fromInt64 (model.spacing - 1L))) |> Stdlib.List.map (fun _ -> "") + let spacingLines = (Stdlib.List.range 0I (model.spacing - 1I)) |> Stdlib.List.map (fun _ -> "") model.items |> Stdlib.List.map (fun item -> renderItem item context) diff --git a/packages/darklang/cli/ui/components/listview.dark b/packages/darklang/cli/ui/components/listview.dark index 784d90b6e1..c1a3db2184 100644 --- a/packages/darklang/cli/ui/components/listview.dark +++ b/packages/darklang/cli/ui/components/listview.dark @@ -11,14 +11,14 @@ type ListItem = // ListView Component type ListViewModel = { items: List - selectedIndex: Int64 - width: Int64 - height: Int64 - scrollOffset: Int64 } + selectedIndex: Int + width: Int + height: Int + scrollOffset: Int } -let createListView (items: List) (width: Int64) (height: Int64) : Core.Types.Component = - let model = ListViewModel { items = items; selectedIndex = 0L; width = width; height = height; scrollOffset = 0L } - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = width; height = height } } +let createListView (items: List) (width: Int) (height: Int) : Core.Types.Component = + let model = ListViewModel { items = items; selectedIndex = 0I; width = width; height = height; scrollOffset = 0I } + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0I; y = 0I }; dimensions = Core.Types.Dimensions { width = width; height = height } } Core.Types.Component { id = "listview" model = model @@ -30,21 +30,21 @@ let createListView (items: List) (width: Int64) (height: Int64) : Core let renderListView (component: Core.Types.Component) (context: Core.Types.RenderContext) : List = let model = component.model let hasFocus = context.hasFocus && component.state == Core.Types.ComponentState.Focused - let innerWidth = model.width - 4L + let innerWidth = model.width - 4I let visibleItems = model.items - |> Stdlib.List.drop (Stdlib.Int.fromInt64 model.scrollOffset) - |> Stdlib.List.take (Stdlib.Int.fromInt64 (model.height - 2L)) + |> Stdlib.List.drop model.scrollOffset + |> Stdlib.List.take (model.height - 2I) let content = visibleItems |> Stdlib.List.indexedMap (fun i item -> - let globalIndex = model.scrollOffset + (Builtin.unwrap (Stdlib.Int.toInt64 i)) + let globalIndex = model.scrollOffset + i let marker = if globalIndex == model.selectedIndex then "▶ " else " " let rawText = marker ++ item.text - let textLen = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length rawText)) - let rightPad = if innerWidth > textLen then Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (innerWidth - textLen)) else "" + let textLen = Stdlib.String.length rawText + let rightPad = if innerWidth > textLen then Stdlib.String.repeat " " (innerWidth - textLen) else "" // Style after calculating padding let styledText = @@ -59,8 +59,8 @@ let renderListView (component: Core.Types.Component) (context: Co styledText ++ rightPad) - let topBorder = "┌" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L)) ++ "┐" - let bottomBorder = "└" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L)) ++ "┘" + let topBorder = "┌" ++ Stdlib.String.repeat "─" (model.width - 2I) ++ "┐" + let bottomBorder = "└" ++ Stdlib.String.repeat "─" (model.width - 2I) ++ "┘" let contentLines = content |> Stdlib.List.map (fun line -> "│ " ++ line ++ " │") @@ -69,13 +69,13 @@ let renderListView (component: Core.Types.Component) (context: Co |> Stdlib.List.append contentLines |> Stdlib.List.append [bottomBorder] -let selectItem (component: Core.Types.Component) (index: Int64) : Core.Types.Component = +let selectItem (component: Core.Types.Component) (index: Int) : Core.Types.Component = let model = component.model - let clampedIndex = Stdlib.Int64.max 0L (Stdlib.Int64.min index ((Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length model.items))) - 1L)) + let clampedIndex = Stdlib.Int.max 0I (Stdlib.Int.min index ((Stdlib.List.length model.items) - 1I)) { component with model = { model with selectedIndex = clampedIndex } } let getSelectedItem (component: Core.Types.Component) : ListItem = let model = component.model - match Stdlib.List.getAt model.items (Stdlib.Int.fromInt64 model.selectedIndex) with + match Stdlib.List.getAt model.items model.selectedIndex with | Some item -> item | None -> ListItem { text = ""; enabled = false; data = "" } \ No newline at end of file diff --git a/packages/darklang/cli/ui/components/message.dark b/packages/darklang/cli/ui/components/message.dark index 9a7fabdbe6..d234e58dcf 100644 --- a/packages/darklang/cli/ui/components/message.dark +++ b/packages/darklang/cli/ui/components/message.dark @@ -8,12 +8,12 @@ type MessageModel = messageType: Core.Types.Color isDismissible: Bool isVisible: Bool - width: Int64 } + width: Int } -let createMessage (title: String) (content: String) (messageType: Core.Types.Color) (width: Int64) : Core.Types.Component = +let createMessage (title: String) (content: String) (messageType: Core.Types.Color) (width: Int) : Core.Types.Component = let model = MessageModel { title = title; content = content; messageType = messageType; isDismissible = true; isVisible = true; width = width } - let height = 4L - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = width; height = height } } + let height = 4I + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0I; y = 0I }; dimensions = Core.Types.Dimensions { width = width; height = height } } Core.Types.Component { id = "message-" ++ title model = model @@ -35,25 +35,25 @@ let renderMessage (component: Core.Types.Component) (context: Core | Info -> "ℹ" | _ -> "•" - let topBorder = "┌" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L)) ++ "┐" - let bottomBorder = "└" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L)) ++ "┘" + let topBorder = "┌" ++ Stdlib.String.repeat "─" (model.width - 2I) ++ "┐" + let bottomBorder = "└" ++ Stdlib.String.repeat "─" (model.width - 2I) ++ "┘" let titleLine = let dismissButton = if model.isDismissible then "✕" else "" - let dismissLen = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length dismissButton)) + let dismissLen = Stdlib.String.length dismissButton // Calculate padding based on raw text (without ANSI codes) let rawTitle = typeIcon ++ " " ++ model.title - let rawTitleLen = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length rawTitle)) - let innerWidth = model.width - 4L // borders and padding + let rawTitleLen = Stdlib.String.length rawTitle + let innerWidth = model.width - 4I // borders and padding let paddingNeeded = innerWidth - rawTitleLen - dismissLen - let rightPad = if paddingNeeded > 0L then Stdlib.String.repeat " " (Stdlib.Int.fromInt64 paddingNeeded) else "" + let rightPad = if paddingNeeded > 0I then Stdlib.String.repeat " " paddingNeeded else "" // Apply styling after calculating padding let styledTitle = Core.Rendering.colorize model.messageType (Core.Rendering.bold rawTitle) "│ " ++ styledTitle ++ rightPad ++ dismissButton ++ " │" let contentLine = - let paddedContent = Core.Rendering.padText model.content (model.width - 4L) Core.Types.Alignment.Left + let paddedContent = Core.Rendering.padText model.content (model.width - 4I) Core.Types.Alignment.Left "│ " ++ paddedContent ++ " │" [topBorder; titleLine; contentLine; bottomBorder] @@ -76,15 +76,15 @@ let dismissMessage (component: Core.Types.Component) : Core.Types. type ToastModel = { message: String toastType: Core.Types.Color - duration: Int64 + duration: Int isVisible: Bool position: Core.Types.Position } -let createToast (message: String) (toastType: Core.Types.Color) (duration: Int64) : Core.Types.Component = - let model = ToastModel { message = message; toastType = toastType; duration = duration; isVisible = true; position = Core.Types.Position { x = 0L; y = 0L } } +let createToast (message: String) (toastType: Core.Types.Color) (duration: Int) : Core.Types.Component = + let model = ToastModel { message = message; toastType = toastType; duration = duration; isVisible = true; position = Core.Types.Position { x = 0I; y = 0I } } // Width = borders (2) + padding (2) + icon (1) + space (1) + message - let width = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length message))) + 6L - let height = 3L + let width = (Stdlib.String.length message) + 6I + let height = 3I let bounds = Core.Types.Bounds { position = model.position; dimensions = Core.Types.Dimensions { width = width; height = height } } Core.Types.Component { id = "toast" @@ -109,16 +109,16 @@ let renderToast (component: Core.Types.Component) (context: Core.Typ // Calculate padding based on raw text length (without ANSI codes) let rawText = typeIcon ++ " " ++ model.message - let innerWidth = component.bounds.dimensions.width - 4L - let textLen = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length rawText)) - let rightPad = if innerWidth > textLen then Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (innerWidth - textLen)) else "" + let innerWidth = component.bounds.dimensions.width - 4I + let textLen = Stdlib.String.length rawText + let rightPad = if innerWidth > textLen then Stdlib.String.repeat " " (innerWidth - textLen) else "" // Style the content let styledContent = Core.Rendering.colorize model.toastType rawText - let topBorder = "╭" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 2L)) ++ "╮" + let topBorder = "╭" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 2I) ++ "╮" let contentLine = "│ " ++ styledContent ++ rightPad ++ " │" - let bottomBorder = "╰" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 2L)) ++ "╯" + let bottomBorder = "╰" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 2I) ++ "╯" [topBorder; contentLine; bottomBorder] @@ -135,12 +135,12 @@ type AlertModel = { message: String alertType: Core.Types.Color isVisible: Bool - width: Int64 } + width: Int } -let createAlert (message: String) (alertType: Core.Types.Color) (width: Int64) : Core.Types.Component = +let createAlert (message: String) (alertType: Core.Types.Color) (width: Int) : Core.Types.Component = let model = AlertModel { message = message; alertType = alertType; isVisible = true; width = width } - let height = 1L - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = width; height = height } } + let height = 1I + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0I; y = 0I }; dimensions = Core.Types.Dimensions { width = width; height = height } } Core.Types.Component { id = "alert" model = model diff --git a/packages/darklang/cli/ui/components/modal.dark b/packages/darklang/cli/ui/components/modal.dark index 314c961796..85e2b604f9 100644 --- a/packages/darklang/cli/ui/components/modal.dark +++ b/packages/darklang/cli/ui/components/modal.dark @@ -8,13 +8,13 @@ type ModalModel = content: List isVisible: Bool hasCloseButton: Bool - width: Int64 - height: Int64 + width: Int + height: Int backgroundColor: Core.Types.Color } -let createModal (title: String) (content: List) (width: Int64) (height: Int64) : Core.Types.Component = +let createModal (title: String) (content: List) (width: Int) (height: Int) : Core.Types.Component = let model = ModalModel { title = title; content = content; isVisible = false; hasCloseButton = true; width = width; height = height; backgroundColor = Core.Types.Color.Light } - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = width; height = height } } + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0I; y = 0I }; dimensions = Core.Types.Dimensions { width = width; height = height } } Core.Types.Component { id = "modal-" ++ title model = model @@ -32,39 +32,39 @@ let renderModal (component: Core.Types.Component) (context: Core.Typ let hasFocus = context.hasFocus && component.state == Core.Types.ComponentState.Focused // Create backdrop - let backdropWidth = 60L - let backdropHeight = 20L + let backdropWidth = 60I + let backdropHeight = 20I let backdrop = - Stdlib.List.repeat (Stdlib.Int.fromInt64 backdropHeight) (Core.Rendering.dim (Stdlib.String.repeat "░" (Stdlib.Int.fromInt64 backdropWidth))) + Stdlib.List.repeat backdropHeight (Core.Rendering.dim (Stdlib.String.repeat "░" backdropWidth)) // Calculate modal position (centered) - let modalX = Stdlib.Int64.divide (backdropWidth - model.width) 2L - let modalY = Stdlib.Int.fromInt64 (Stdlib.Int64.divide (backdropHeight - model.height) 2L) + let modalX = Stdlib.Int.divide (backdropWidth - model.width) 2I + let modalY = Stdlib.Int.divide (backdropHeight - model.height) 2I // Create modal box - let topBorder = "╔" ++ Stdlib.String.repeat "═" (Stdlib.Int.fromInt64 (model.width - 2L)) ++ "╗" - let bottomBorder = "╚" ++ Stdlib.String.repeat "═" (Stdlib.Int.fromInt64 (model.width - 2L)) ++ "╝" + let topBorder = "╔" ++ Stdlib.String.repeat "═" (model.width - 2I) ++ "╗" + let bottomBorder = "╚" ++ Stdlib.String.repeat "═" (model.width - 2I) ++ "╝" let titleLine = let closeButton = if model.hasCloseButton then " ✕" else "" - let availableWidth = model.width - 4L - (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length closeButton))) + let availableWidth = model.width - 4I - (Stdlib.String.length closeButton) let paddedTitle = Core.Rendering.padText model.title availableWidth Core.Types.Alignment.Center let titleColor = if hasFocus then Core.Types.Color.Primary else Core.Types.Color.Default "║ " ++ Core.Rendering.colorize titleColor (Core.Rendering.bold paddedTitle) ++ closeButton ++ " ║" - let separatorLine = "╠" ++ Stdlib.String.repeat "═" (Stdlib.Int.fromInt64 (model.width - 2L)) ++ "╣" + let separatorLine = "╠" ++ Stdlib.String.repeat "═" (model.width - 2I) ++ "╣" let contentLines = model.content |> Stdlib.List.map (fun line -> - let paddedLine = Core.Rendering.padText line (model.width - 4L) Core.Types.Alignment.Left + let paddedLine = Core.Rendering.padText line (model.width - 4I) Core.Types.Alignment.Left "║ " ++ paddedLine ++ " ║") // Fill remaining space if content is shorter than modal height - let remainingHeight = (Stdlib.Int.fromInt64 (model.height - 4L)) - Stdlib.List.length contentLines + let remainingHeight = (model.height - 4I) - Stdlib.List.length contentLines let fillerLines = if remainingHeight > 0I then - Stdlib.List.repeat remainingHeight ("║" ++ Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (model.width - 2L)) ++ "║") + Stdlib.List.repeat remainingHeight ("║" ++ Stdlib.String.repeat " " (model.width - 2I) ++ "║") else [] @@ -82,8 +82,8 @@ let renderModal (component: Core.Types.Component) (context: Core.Typ let modalLineIndex = i - modalY match Stdlib.List.getAt modalContent modalLineIndex with | Some modalLine -> - let beforeModal = Stdlib.String.repeat " " (Stdlib.Int.fromInt64 modalX) - let afterModal = Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (backdropWidth - modalX - model.width)) + let beforeModal = Stdlib.String.repeat " " modalX + let afterModal = Stdlib.String.repeat " " (backdropWidth - modalX - model.width) beforeModal ++ modalLine ++ afterModal | None -> backdropLine else @@ -114,13 +114,13 @@ type ConfirmDialogModel = confirmText: String cancelText: String isVisible: Bool - selectedButton: Int64 } + selectedButton: Int } let createConfirmDialog (title: String) (message: String) (confirmText: String) (cancelText: String) : Core.Types.Component = - let model = ConfirmDialogModel { title = title; message = message; confirmText = confirmText; cancelText = cancelText; isVisible = false; selectedButton = 0L } - let width = 40L - let height = 8L - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = width; height = height } } + let model = ConfirmDialogModel { title = title; message = message; confirmText = confirmText; cancelText = cancelText; isVisible = false; selectedButton = 0I } + let width = 40I + let height = 8I + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0I; y = 0I }; dimensions = Core.Types.Dimensions { width = width; height = height } } Core.Types.Component { id = "confirm-dialog" model = model @@ -136,44 +136,44 @@ let renderConfirmDialog (component: Core.Types.Component) (c else let hasFocus = context.hasFocus && component.state == Core.Types.ComponentState.Focused - let topBorder = "┌" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 2L)) ++ "┐" - let bottomBorder = "└" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 2L)) ++ "┘" + let topBorder = "┌" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 2I) ++ "┐" + let bottomBorder = "└" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 2I) ++ "┘" let titleLine = - let paddedTitle = Core.Rendering.padText model.title (component.bounds.dimensions.width - 4L) Core.Types.Alignment.Center + let paddedTitle = Core.Rendering.padText model.title (component.bounds.dimensions.width - 4I) Core.Types.Alignment.Center let titleColor = if hasFocus then Core.Types.Color.Warning else Core.Types.Color.Default "│ " ++ Core.Rendering.colorize titleColor (Core.Rendering.bold paddedTitle) ++ " │" - let separatorLine = "├" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 2L)) ++ "┤" + let separatorLine = "├" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 2I) ++ "┤" let messageLine = - let paddedMessage = Core.Rendering.padText model.message (component.bounds.dimensions.width - 4L) Core.Types.Alignment.Center + let paddedMessage = Core.Rendering.padText model.message (component.bounds.dimensions.width - 4I) Core.Types.Alignment.Center "│ " ++ paddedMessage ++ " │" - let emptyLine = "│" ++ Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 2L)) ++ "│" + let emptyLine = "│" ++ Stdlib.String.repeat " " (component.bounds.dimensions.width - 2I) ++ "│" let buttonLine = let confirmButton = - if model.selectedButton == 0L then + if model.selectedButton == 0I then Core.Rendering.colorize Core.Types.Color.Success ("[ " ++ model.confirmText ++ " ]") else "[ " ++ model.confirmText ++ " ]" let cancelButton = - if model.selectedButton == 1L then + if model.selectedButton == 1I then Core.Rendering.colorize Core.Types.Color.Error ("[ " ++ model.cancelText ++ " ]") else "[ " ++ model.cancelText ++ " ]" let buttons = confirmButton ++ " " ++ cancelButton - let paddedButtons = Core.Rendering.padText buttons (component.bounds.dimensions.width - 4L) Core.Types.Alignment.Center + let paddedButtons = Core.Rendering.padText buttons (component.bounds.dimensions.width - 4I) Core.Types.Alignment.Center "│ " ++ paddedButtons ++ " │" [topBorder; titleLine; separatorLine; messageLine; emptyLine; buttonLine; bottomBorder] -let selectConfirmButton (component: Core.Types.Component) (buttonIndex: Int64) : Core.Types.Component = +let selectConfirmButton (component: Core.Types.Component) (buttonIndex: Int) : Core.Types.Component = let model = component.model - if buttonIndex >= 0L && buttonIndex <= 1L then + if buttonIndex >= 0I && buttonIndex <= 1I then { component with model = { model with selectedButton = buttonIndex } } else component diff --git a/packages/darklang/cli/ui/components/navigation.dark b/packages/darklang/cli/ui/components/navigation.dark index 51ba42e489..d474d3de76 100644 --- a/packages/darklang/cli/ui/components/navigation.dark +++ b/packages/darklang/cli/ui/components/navigation.dark @@ -13,18 +13,18 @@ type MenuItem = // Menu Component type MenuModel = { items: List - selectedIndex: Int64 + selectedIndex: Int isOpen: Bool title: String } let createMenu (title: String) (items: List) : Core.Types.Component = - let model = MenuModel { items = items; selectedIndex = 0L; isOpen = false; title = title } + let model = MenuModel { items = items; selectedIndex = 0I; isOpen = false; title = title } let maxWidth = items - |> Stdlib.List.map (fun item -> (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length item.label + Stdlib.String.length item.shortcut))) + 4L) - |> Stdlib.List.fold 20L (fun acc len -> if len > acc then len else acc) - let height = if model.isOpen then (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length items))) + 2L else 1L - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = maxWidth; height = height } } + |> Stdlib.List.map (fun item -> (Stdlib.String.length item.label + Stdlib.String.length item.shortcut) + 4I) + |> Stdlib.List.fold 20I (fun acc len -> if len > acc then len else acc) + let height = if model.isOpen then (Stdlib.List.length items) + 2I else 1I + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0I; y = 0I }; dimensions = Core.Types.Dimensions { width = maxWidth; height = height } } Core.Types.Component { id = "menu-" ++ title model = model @@ -45,21 +45,21 @@ let renderMenu (component: Core.Types.Component) (context: Core.Types let menuItems = model.items |> Stdlib.List.indexedMap (fun i item -> - let isSelected = (Builtin.unwrap (Stdlib.Int.toInt64 i)) == model.selectedIndex + let isSelected = i == model.selectedIndex let prefix = if isSelected then "►" else " " let itemColor = if Stdlib.Bool.not item.enabled then Core.Types.Color.Dark else if isSelected then Core.Types.Color.Primary else Core.Types.Color.Default - let label = Core.Rendering.padText item.label (component.bounds.dimensions.width - 6L - (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length item.shortcut)))) Core.Types.Alignment.Left + let label = Core.Rendering.padText item.label (component.bounds.dimensions.width - 6I - (Stdlib.String.length item.shortcut)) Core.Types.Alignment.Left let shortcut = if Stdlib.String.isEmpty item.shortcut then "" else "[" ++ item.shortcut ++ "]" let styledItem = Core.Rendering.colorize itemColor (prefix ++ " " ++ label ++ " " ++ shortcut) "│" ++ styledItem ++ "│") - let topBorder = "┌" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 2L)) ++ "┐" - let bottomBorder = "└" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 2L)) ++ "┘" - let titleLine = "│" ++ Core.Rendering.padText styledTitle (component.bounds.dimensions.width - 2L) Core.Types.Alignment.Center ++ "│" + let topBorder = "┌" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 2I) ++ "┐" + let bottomBorder = "└" ++ Stdlib.String.repeat "─" (component.bounds.dimensions.width - 2I) ++ "┘" + let titleLine = "│" ++ Core.Rendering.padText styledTitle (component.bounds.dimensions.width - 2I) Core.Types.Alignment.Center ++ "│" [ topBorder; titleLine ] |> Stdlib.List.append menuItems @@ -67,9 +67,9 @@ let renderMenu (component: Core.Types.Component) (context: Core.Types else [focusIndicator ++ styledTitle ++ " ▼"] -let selectMenuItem (component: Core.Types.Component) (index: Int64) : Core.Types.Component = +let selectMenuItem (component: Core.Types.Component) (index: Int) : Core.Types.Component = let model = component.model - if index >= 0L && index < (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length model.items))) then + if index >= 0I && index < (Stdlib.List.length model.items) then { component with model = { model with selectedIndex = index } } else component @@ -81,13 +81,13 @@ let toggleMenu (component: Core.Types.Component) : Core.Types.Compone // Tab Component type TabModel = { tabs: List - activeIndex: Int64 - tabWidth: Int64 } + activeIndex: Int + tabWidth: Int } -let createTabs (tabs: List) (activeIndex: Int64) : Core.Types.Component = - let model = TabModel { tabs = tabs; activeIndex = activeIndex; tabWidth = 12L } - let totalWidth = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length tabs))) * model.tabWidth - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = totalWidth; height = 2L } } +let createTabs (tabs: List) (activeIndex: Int) : Core.Types.Component = + let model = TabModel { tabs = tabs; activeIndex = activeIndex; tabWidth = 12I } + let totalWidth = (Stdlib.List.length tabs) * model.tabWidth + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0I; y = 0I }; dimensions = Core.Types.Dimensions { width = totalWidth; height = 2I } } Core.Types.Component { id = "tabs" model = model @@ -103,7 +103,7 @@ let renderTabs (component: Core.Types.Component) (context: Core.Types. let tabHeaders = model.tabs |> Stdlib.List.indexedMap (fun i tab -> - let isActive = (Builtin.unwrap (Stdlib.Int.toInt64 i)) == model.activeIndex + let isActive = i == model.activeIndex let isFocused = hasFocus && isActive let tabColor = @@ -115,15 +115,15 @@ let renderTabs (component: Core.Types.Component) (context: Core.Types. let styledTab = Core.Rendering.colorize tabColor paddedTab if isActive then - "┌" ++ Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.tabWidth - 2L)) ++ "┐" + "┌" ++ Stdlib.String.repeat "─" (model.tabWidth - 2I) ++ "┐" else - " " ++ Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (model.tabWidth - 2L)) ++ " ") + " " ++ Stdlib.String.repeat " " (model.tabWidth - 2I) ++ " ") |> Stdlib.String.join "" let tabLabels = model.tabs |> Stdlib.List.indexedMap (fun i tab -> - let isActive = (Builtin.unwrap (Stdlib.Int.toInt64 i)) == model.activeIndex + let isActive = i == model.activeIndex let isFocused = hasFocus && isActive let tabColor = @@ -131,7 +131,7 @@ let renderTabs (component: Core.Types.Component) (context: Core.Types. else if isActive then Core.Types.Color.Success else Core.Types.Color.Default - let paddedTab = Core.Rendering.padText tab (model.tabWidth - 2L) Core.Types.Alignment.Center + let paddedTab = Core.Rendering.padText tab (model.tabWidth - 2I) Core.Types.Alignment.Center let styledTab = Core.Rendering.colorize tabColor paddedTab if isActive then @@ -142,9 +142,9 @@ let renderTabs (component: Core.Types.Component) (context: Core.Types. [ tabHeaders; tabLabels ] -let selectTab (component: Core.Types.Component) (index: Int64) : Core.Types.Component = +let selectTab (component: Core.Types.Component) (index: Int) : Core.Types.Component = let model = component.model - if index >= 0L && index < (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length model.tabs))) then + if index >= 0I && index < (Stdlib.List.length model.tabs) then { component with model = { model with activeIndex = index } } else component @@ -153,11 +153,11 @@ let selectTab (component: Core.Types.Component) (index: Int64) : Core. type BreadcrumbModel = { crumbs: List separator: String - maxWidth: Int64 } + maxWidth: Int } let createBreadcrumb (crumbs: List) (separator: String) : Core.Types.Component = - let model = BreadcrumbModel { crumbs = crumbs; separator = separator; maxWidth = 50L } - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = model.maxWidth; height = 1L } } + let model = BreadcrumbModel { crumbs = crumbs; separator = separator; maxWidth = 50I } + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0I; y = 0I }; dimensions = Core.Types.Dimensions { width = model.maxWidth; height = 1I } } Core.Types.Component { id = "breadcrumb" model = model @@ -184,15 +184,15 @@ let renderBreadcrumb (component: Core.Types.Component) (context // Navigation Bar Component type NavBarModel = { items: List - selectedIndex: Int64 + selectedIndex: Int title: String } let createNavBar (title: String) (items: List) : Core.Types.Component = - let model = NavBarModel { items = items; selectedIndex = 0L; title = title } + let model = NavBarModel { items = items; selectedIndex = 0I; title = title } let totalWidth = - ((Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length title))) + 4L) + - (items |> Stdlib.List.map (fun item -> (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length item.label))) + 4L) |> Stdlib.List.fold 0L (fun acc len -> acc + len)) - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = totalWidth; height = 1L } } + ((Stdlib.String.length title) + 4I) + + (items |> Stdlib.List.map (fun item -> (Stdlib.String.length item.label) + 4I) |> Stdlib.List.fold 0I (fun acc len -> acc + len)) + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0I; y = 0I }; dimensions = Core.Types.Dimensions { width = totalWidth; height = 1I } } Core.Types.Component { id = "navbar-" ++ title model = model @@ -210,7 +210,7 @@ let renderNavBar (component: Core.Types.Component) (context: Core.T let navItems = model.items |> Stdlib.List.indexedMap (fun i item -> - let isSelected = (Builtin.unwrap (Stdlib.Int.toInt64 i)) == model.selectedIndex && hasFocus + let isSelected = i == model.selectedIndex && hasFocus let itemColor = if Stdlib.Bool.not item.enabled then Core.Types.Color.Dark else if isSelected then Core.Types.Color.Primary @@ -225,9 +225,9 @@ let renderNavBar (component: Core.Types.Component) (context: Core.T [styledTitle ++ " | " ++ navItems] -let selectNavItem (component: Core.Types.Component) (index: Int64) : Core.Types.Component = +let selectNavItem (component: Core.Types.Component) (index: Int) : Core.Types.Component = let model = component.model - if index >= 0L && index < (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length model.items))) then + if index >= 0I && index < (Stdlib.List.length model.items) then { component with model = { model with selectedIndex = index } } else component \ No newline at end of file diff --git a/packages/darklang/cli/ui/components/pagination.dark b/packages/darklang/cli/ui/components/pagination.dark index 13e0cd5071..a45c7e942c 100644 --- a/packages/darklang/cli/ui/components/pagination.dark +++ b/packages/darklang/cli/ui/components/pagination.dark @@ -2,13 +2,13 @@ module Darklang.CLI.UI.Components.Pagination // Pagination Component type PaginationModel = - { currentPage: Int64 - totalPages: Int64 - pageSize: Int64 - totalItems: Int64 + { currentPage: Int + totalPages: Int + pageSize: Int + totalItems: Int showInfo: Bool showJumper: Bool - maxVisiblePages: Int64 + maxVisiblePages: Int style: PaginationStyle } type PaginationStyle = @@ -16,12 +16,12 @@ type PaginationStyle = | Rounded | Simple -let createPagination (totalItems: Int64) (pageSize: Int64) : Core.Types.Component = - let totalPages = if pageSize > 0L then Stdlib.Int64.divide (totalItems + pageSize - 1L) pageSize else 1L - let model = PaginationModel { currentPage = 1L; totalPages = totalPages; pageSize = pageSize; totalItems = totalItems; showInfo = true; showJumper = false; maxVisiblePages = 7L; style = PaginationStyle.Standard } - let width = 60L - let height = if model.showInfo then 2L else 1L - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = width; height = height } } +let createPagination (totalItems: Int) (pageSize: Int) : Core.Types.Component = + let totalPages = if pageSize > 0I then Stdlib.Int.divide (totalItems + pageSize - 1I) pageSize else 1I + let model = PaginationModel { currentPage = 1I; totalPages = totalPages; pageSize = pageSize; totalItems = totalItems; showInfo = true; showJumper = false; maxVisiblePages = 7I; style = PaginationStyle.Standard } + let width = 60I + let height = if model.showInfo then 2I else 1I + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0I; y = 0I }; dimensions = Core.Types.Dimensions { width = width; height = height } } Core.Types.Component { id = "pagination" model = model @@ -30,8 +30,8 @@ let createPagination (totalItems: Int64) (pageSize: Int64) : Core.Types.Componen visible = true focusable = true } -let renderPageButton (style: PaginationStyle) (pageNum: Int64) (isCurrent: Bool) (isDisabled: Bool) : String = - let pageText = Stdlib.Int64.toString pageNum +let renderPageButton (style: PaginationStyle) (pageNum: Int) (isCurrent: Bool) (isDisabled: Bool) : String = + let pageText = Stdlib.Int.toString pageNum match style with | Rounded -> if isCurrent then @@ -60,20 +60,20 @@ let renderPagination (component: Core.Types.Component) (context let hasFocus = context.hasFocus && component.state == Core.Types.ComponentState.Focused let generatePageNumbers : List = - let halfVisible = Stdlib.Int64.divide model.maxVisiblePages 2L - let startPage = Stdlib.Int64.max 1L (model.currentPage - halfVisible) - let endPage = Stdlib.Int64.min model.totalPages (startPage + model.maxVisiblePages - 1L) - let adjustedStartPage = Stdlib.Int64.max 1L (endPage - model.maxVisiblePages + 1L) + let halfVisible = Stdlib.Int.divide model.maxVisiblePages 2I + let startPage = Stdlib.Int.max 1I (model.currentPage - halfVisible) + let endPage = Stdlib.Int.min model.totalPages (startPage + model.maxVisiblePages - 1I) + let adjustedStartPage = Stdlib.Int.max 1I (endPage - model.maxVisiblePages + 1I) - let pages = Stdlib.List.range (Stdlib.Int.fromInt64 adjustedStartPage) (Stdlib.Int.fromInt64 endPage) + let pages = Stdlib.List.range adjustedStartPage endPage let pageButtons = pages |> Stdlib.List.map (fun page -> - let isCurrent = (Builtin.unwrap (Stdlib.Int.toInt64 page)) == model.currentPage - renderPageButton model.style (Builtin.unwrap (Stdlib.Int.toInt64 page)) isCurrent false) + let isCurrent = page == model.currentPage + renderPageButton model.style page isCurrent false) let prevButton = - if model.currentPage > 1L then + if model.currentPage > 1I then [if model.style == PaginationStyle.Simple then "◀" else "◀ Prev"] else [Core.Rendering.colorize Core.Types.Color.Dark (if model.style == PaginationStyle.Simple then "◀" else "◀ Prev")] @@ -84,9 +84,9 @@ let renderPagination (component: Core.Types.Component) (context else [Core.Rendering.colorize Core.Types.Color.Dark (if model.style == PaginationStyle.Simple then "▶" else "Next ▶")] - let ellipsisLeft = if adjustedStartPage > 1L then ["..."] else [] + let ellipsisLeft = if adjustedStartPage > 1I then ["..."] else [] let ellipsisRight = if endPage < model.totalPages then ["..."] else [] - let firstPage = if adjustedStartPage > 1L then [renderPageButton model.style 1L false false] else [] + let firstPage = if adjustedStartPage > 1I then [renderPageButton model.style 1I false false] else [] let lastPage = if endPage < model.totalPages then [renderPageButton model.style model.totalPages false false] else [] prevButton @@ -105,9 +105,9 @@ let renderPagination (component: Core.Types.Component) (context let infoLine = if model.showInfo then - let startItem = ((model.currentPage - 1L) * model.pageSize) + 1L - let endItem = Stdlib.Int64.min (model.currentPage * model.pageSize) model.totalItems - let infoText = "Showing " ++ Stdlib.Int64.toString startItem ++ "-" ++ Stdlib.Int64.toString endItem ++ " of " ++ Stdlib.Int64.toString model.totalItems + let startItem = ((model.currentPage - 1I) * model.pageSize) + 1I + let endItem = Stdlib.Int.min (model.currentPage * model.pageSize) model.totalItems + let infoText = "Showing " ++ Stdlib.Int.toString startItem ++ "-" ++ Stdlib.Int.toString endItem ++ " of " ++ Stdlib.Int.toString model.totalItems let paddedInfo = Core.Rendering.padText infoText component.bounds.dimensions.width Core.Types.Alignment.Center [paddedInfo] else @@ -116,9 +116,9 @@ let renderPagination (component: Core.Types.Component) (context [paginationLine] |> Stdlib.List.append infoLine -let goToPage (component: Core.Types.Component) (page: Int64) : Core.Types.Component = +let goToPage (component: Core.Types.Component) (page: Int) : Core.Types.Component = let model = component.model - if page >= 1L && page <= model.totalPages then + if page >= 1I && page <= model.totalPages then { component with model = { model with currentPage = page } } else component @@ -126,20 +126,20 @@ let goToPage (component: Core.Types.Component) (page: Int64) : let nextPage (component: Core.Types.Component) : Core.Types.Component = let model = component.model if model.currentPage < model.totalPages then - { component with model = { model with currentPage = model.currentPage + 1L } } + { component with model = { model with currentPage = model.currentPage + 1I } } else component let prevPage (component: Core.Types.Component) : Core.Types.Component = let model = component.model - if model.currentPage > 1L then - { component with model = { model with currentPage = model.currentPage - 1L } } + if model.currentPage > 1I then + { component with model = { model with currentPage = model.currentPage - 1I } } else component let firstPage (component: Core.Types.Component) : Core.Types.Component = let model = component.model - { component with model = { model with currentPage = 1L } } + { component with model = { model with currentPage = 1I } } let lastPage (component: Core.Types.Component) : Core.Types.Component = let model = component.model @@ -151,7 +151,7 @@ let setPaginationStyle (component: Core.Types.Component) (style let showPaginationInfo (component: Core.Types.Component) : Core.Types.Component = let model = component.model - let newHeight = if model.showInfo then component.bounds.dimensions.height else component.bounds.dimensions.height + 1L + let newHeight = if model.showInfo then component.bounds.dimensions.height else component.bounds.dimensions.height + 1I let newBounds = Core.Types.Bounds { position = component.bounds.position; dimensions = Core.Types.Dimensions { width = component.bounds.dimensions.width; height = newHeight } } { component with model = { model with showInfo = true } @@ -159,7 +159,7 @@ let showPaginationInfo (component: Core.Types.Component) : Core let hidePaginationInfo (component: Core.Types.Component) : Core.Types.Component = let model = component.model - let newHeight = if model.showInfo then component.bounds.dimensions.height - 1L else component.bounds.dimensions.height + let newHeight = if model.showInfo then component.bounds.dimensions.height - 1I else component.bounds.dimensions.height let newBounds = Core.Types.Bounds { position = component.bounds.position; dimensions = Core.Types.Dimensions { width = component.bounds.dimensions.width; height = newHeight } } { component with model = { model with showInfo = false } @@ -175,8 +175,8 @@ type StepModel = type StepNavigationModel = { steps: List - currentStep: Int64 - width: Int64 + currentStep: Int + width: Int showNumbers: Bool style: StepStyle } @@ -185,10 +185,10 @@ type StepStyle = | Vertical | Dots -let createStepNavigation (width: Int64) (style: StepStyle) : Core.Types.Component = - let model = StepNavigationModel { steps = []; currentStep = 0L; width = width; showNumbers = true; style = style } - let height = match style with | Vertical -> 5L | _ -> 3L - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = width; height = height } } +let createStepNavigation (width: Int) (style: StepStyle) : Core.Types.Component = + let model = StepNavigationModel { steps = []; currentStep = 0I; width = width; showNumbers = true; style = style } + let height = match style with | Vertical -> 5I | _ -> 3I + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0I; y = 0I }; dimensions = Core.Types.Dimensions { width = width; height = height } } Core.Types.Component { id = "stepnav" model = model @@ -202,8 +202,8 @@ let addStep (component: Core.Types.Component) (step: StepMo let newSteps = model.steps |> Stdlib.List.append [step] let newHeight = match model.style with - | Vertical -> ((Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length newSteps))) * 2L) + 1L - | _ -> 3L + | Vertical -> ((Stdlib.List.length newSteps) * 2I) + 1I + | _ -> 3I let newBounds = Core.Types.Bounds { position = component.bounds.position; dimensions = Core.Types.Dimensions { width = model.width; height = newHeight } } { component with model = { model with steps = newSteps } @@ -218,7 +218,7 @@ let renderStepNavigation (component: Core.Types.Component) model.steps |> Stdlib.List.indexedMap (fun i step -> let stepNumber = Stdlib.Int.toString (i + 1I) - let isActive = (Builtin.unwrap (Stdlib.Int.toInt64 i)) == model.currentStep + let isActive = i == model.currentStep let stepText = if model.showNumbers then stepNumber ++ "." ++ step.title else step.title let stepColor = @@ -234,21 +234,21 @@ let renderStepNavigation (component: Core.Types.Component) let combinedSteps = Stdlib.String.join stepTexts separator let paddedSteps = Core.Rendering.padText combinedSteps model.width Core.Types.Alignment.Center - let topBorder = "┌" ++ (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L))) ++ "┐" - let bottomBorder = "└" ++ (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L))) ++ "┘" + let topBorder = "┌" ++ (Stdlib.String.repeat "─" (model.width - 2I)) ++ "┐" + let bottomBorder = "└" ++ (Stdlib.String.repeat "─" (model.width - 2I)) ++ "┘" let stepLine = "│ " ++ paddedSteps ++ " │" [topBorder; stepLine; bottomBorder] | Vertical -> - let topBorder = "┌" ++ (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L))) ++ "┐" - let bottomBorder = "└" ++ (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L))) ++ "┘" + let topBorder = "┌" ++ (Stdlib.String.repeat "─" (model.width - 2I)) ++ "┐" + let bottomBorder = "└" ++ (Stdlib.String.repeat "─" (model.width - 2I)) ++ "┘" let stepLines = model.steps |> Stdlib.List.indexedMap (fun i step -> let stepNumber = Stdlib.Int.toString (i + 1I) - let isActive = (Builtin.unwrap (Stdlib.Int.toInt64 i)) == model.currentStep + let isActive = i == model.currentStep let stepText = if model.showNumbers then stepNumber ++ ". " ++ step.title else step.title let stepColor = @@ -263,11 +263,11 @@ let renderStepNavigation (component: Core.Types.Component) else " " let styledStep = Core.Rendering.colorize stepColor (prefix ++ " " ++ stepText) - let paddedStep = Core.Rendering.padText styledStep (model.width - 4L) Core.Types.Alignment.Left + let paddedStep = Core.Rendering.padText styledStep (model.width - 4I) Core.Types.Alignment.Left let stepLine = "│ " ++ paddedStep ++ " │" if i < Stdlib.List.length model.steps - 1I then - [stepLine; "│" ++ (Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (model.width - 2L))) ++ "│"] + [stepLine; "│" ++ (Stdlib.String.repeat " " (model.width - 2I)) ++ "│"] else [stepLine]) |> Stdlib.List.fold [] Stdlib.List.append @@ -280,7 +280,7 @@ let renderStepNavigation (component: Core.Types.Component) let dotTexts = model.steps |> Stdlib.List.indexedMap (fun i step -> - let isActive = (Builtin.unwrap (Stdlib.Int.toInt64 i)) == model.currentStep + let isActive = i == model.currentStep let dot = if step.isCompleted then "●" else if isActive then "◉" @@ -299,10 +299,10 @@ let renderStepNavigation (component: Core.Types.Component) [paddedDots] -let goToStep (component: Core.Types.Component) (stepIndex: Int64) : Core.Types.Component = +let goToStep (component: Core.Types.Component) (stepIndex: Int) : Core.Types.Component = let model = component.model - if stepIndex >= 0L && stepIndex < (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length model.steps))) then - match Stdlib.List.getAt model.steps (Stdlib.Int.fromInt64 stepIndex) with + if stepIndex >= 0I && stepIndex < (Stdlib.List.length model.steps) then + match Stdlib.List.getAt model.steps stepIndex with | Some step -> if step.isDisabled then component @@ -314,15 +314,15 @@ let goToStep (component: Core.Types.Component) (stepIndex: let nextStep (component: Core.Types.Component) : Core.Types.Component = let model = component.model - if model.currentStep < (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length model.steps))) - 1L then - { component with model = { model with currentStep = model.currentStep + 1L } } + if model.currentStep < (Stdlib.List.length model.steps) - 1I then + { component with model = { model with currentStep = model.currentStep + 1I } } else component let prevStep (component: Core.Types.Component) : Core.Types.Component = let model = component.model - if model.currentStep > 0L then - { component with model = { model with currentStep = model.currentStep - 1L } } + if model.currentStep > 0I then + { component with model = { model with currentStep = model.currentStep - 1I } } else component @@ -331,7 +331,7 @@ let completeCurrentStep (component: Core.Types.Component) : let updatedSteps = model.steps |> Stdlib.List.indexedMap (fun i step -> - if (Builtin.unwrap (Stdlib.Int.toInt64 i)) == model.currentStep then + if i == model.currentStep then { step with isCompleted = true } else step) diff --git a/packages/darklang/cli/ui/components/panel.dark b/packages/darklang/cli/ui/components/panel.dark index 3e6d582e34..6c8c66958b 100644 --- a/packages/darklang/cli/ui/components/panel.dark +++ b/packages/darklang/cli/ui/components/panel.dark @@ -19,16 +19,16 @@ type PanelItemType = type PanelModel = { title: String items: List - selectedIndex: Int64 - width: Int64 + selectedIndex: Int + width: Int showHeader: Bool headerColor: Core.Types.Color borderColor: Core.Types.Color } -let createPanel (title: String) (width: Int64) : Core.Types.Component = - let model = PanelModel { title = title; items = []; selectedIndex = -1L; width = width; showHeader = true; headerColor = Core.Types.Color.Primary; borderColor = Core.Types.Color.Default } - let height = 3L - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = width; height = height } } +let createPanel (title: String) (width: Int) : Core.Types.Component = + let model = PanelModel { title = title; items = []; selectedIndex = -1I; width = width; showHeader = true; headerColor = Core.Types.Color.Primary; borderColor = Core.Types.Color.Default } + let height = 3I + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0I; y = 0I }; dimensions = Core.Types.Dimensions { width = width; height = height } } Core.Types.Component { id = "panel-" ++ title model = model @@ -40,7 +40,7 @@ let createPanel (title: String) (width: Int64) : Core.Types.Component) (item: PanelItem) : Core.Types.Component = let model = component.model let newItems = model.items |> Stdlib.List.append [item] - let newHeight = if model.showHeader then (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length newItems))) + 3L else (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length newItems))) + 2L + let newHeight = if model.showHeader then (Stdlib.List.length newItems) + 3I else (Stdlib.List.length newItems) + 2I let newBounds = Core.Types.Bounds { position = component.bounds.position; dimensions = Core.Types.Dimensions { width = model.width; height = newHeight } } { component with model = { model with items = newItems } @@ -50,15 +50,15 @@ let renderPanel (component: Core.Types.Component) (context: Core.Typ let model = component.model let hasFocus = context.hasFocus && component.state == Core.Types.ComponentState.Focused - let topBorder = "┌" ++ (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L))) ++ "┐" - let bottomBorder = "└" ++ (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L))) ++ "┘" + let topBorder = "┌" ++ (Stdlib.String.repeat "─" (model.width - 2I)) ++ "┐" + let bottomBorder = "└" ++ (Stdlib.String.repeat "─" (model.width - 2I)) ++ "┘" let headerLines = if model.showHeader then let styledTitle = Core.Rendering.colorize model.headerColor (Core.Rendering.bold model.title) - let paddedTitle = Core.Rendering.padText styledTitle (model.width - 4L) Core.Types.Alignment.Center + let paddedTitle = Core.Rendering.padText styledTitle (model.width - 4I) Core.Types.Alignment.Center let titleLine = "│ " ++ paddedTitle ++ " │" - let separatorLine = "├" ++ (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L))) ++ "┤" + let separatorLine = "├" ++ (Stdlib.String.repeat "─" (model.width - 2I)) ++ "┤" [titleLine; separatorLine] else [] @@ -67,10 +67,10 @@ let renderPanel (component: Core.Types.Component) (context: Core.Typ model.items |> Stdlib.List.indexedMap (fun i item -> if item.itemType == PanelItemType.Separator then - "├" ++ (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L))) ++ "┤" + "├" ++ (Stdlib.String.repeat "─" (model.width - 2I)) ++ "┤" else - let isSelected = (Builtin.unwrap (Stdlib.Int.toInt64 i)) == model.selectedIndex - let isHovered = hasFocus && (Builtin.unwrap (Stdlib.Int.toInt64 i)) == model.selectedIndex + let isSelected = i == model.selectedIndex + let isHovered = hasFocus && i == model.selectedIndex let prefix = if item.isDisabled then " " @@ -88,7 +88,7 @@ let renderPanel (component: Core.Types.Component) (context: Core.Typ else Core.Types.Color.Default let styledLabel = Core.Rendering.colorize itemColor labelText - let paddedLabel = Core.Rendering.padText (prefix ++ " " ++ styledLabel) (model.width - 4L) Core.Types.Alignment.Left + let paddedLabel = Core.Rendering.padText (prefix ++ " " ++ styledLabel) (model.width - 4I) Core.Types.Alignment.Left "│ " ++ paddedLabel ++ " │") [topBorder] @@ -96,10 +96,10 @@ let renderPanel (component: Core.Types.Component) (context: Core.Typ |> Stdlib.List.append itemLines |> Stdlib.List.append [bottomBorder] -let selectPanelItem (component: Core.Types.Component) (index: Int64) : Core.Types.Component = +let selectPanelItem (component: Core.Types.Component) (index: Int) : Core.Types.Component = let model = component.model - if index >= 0L && index < (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length model.items))) then - match Stdlib.List.getAt model.items (Stdlib.Int.fromInt64 index) with + if index >= 0I && index < (Stdlib.List.length model.items) then + match Stdlib.List.getAt model.items index with | Some item -> if item.isDisabled || item.itemType == PanelItemType.Separator then component @@ -119,7 +119,7 @@ let setPanelColors (component: Core.Types.Component) (headerColor: C let hideHeader (component: Core.Types.Component) : Core.Types.Component = let model = component.model - let newHeight = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length model.items))) + 2L + let newHeight = (Stdlib.List.length model.items) + 2I let newBounds = Core.Types.Bounds { position = component.bounds.position; dimensions = Core.Types.Dimensions { width = model.width; height = newHeight } } { component with model = { model with showHeader = false } @@ -128,8 +128,8 @@ let hideHeader (component: Core.Types.Component) : Core.Types.Compon // Tab Panel Component (specialized panel for tabs) type TabPanelModel = { tabs: List - activeTabIndex: Int64 - width: Int64 + activeTabIndex: Int + width: Int tabStyle: TabStyle } type TabStyle = @@ -137,10 +137,10 @@ type TabStyle = | Toggle | Pills -let createTabPanel (width: Int64) (style: TabStyle) : Core.Types.Component = - let model = TabPanelModel { tabs = []; activeTabIndex = 0L; width = width; tabStyle = style } - let height = 3L - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = width; height = height } } +let createTabPanel (width: Int) (style: TabStyle) : Core.Types.Component = + let model = TabPanelModel { tabs = []; activeTabIndex = 0I; width = width; tabStyle = style } + let height = 3I + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0I; y = 0I }; dimensions = Core.Types.Dimensions { width = width; height = height } } Core.Types.Component { id = "tabpanel" model = model @@ -160,20 +160,20 @@ let renderTabPanel (component: Core.Types.Component) (context: Co match model.tabStyle with | Boxed -> - let topBorder = "┌" ++ (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L))) ++ "┐" - let bottomBorder = "└" ++ (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L))) ++ "┘" + let topBorder = "┌" ++ (Stdlib.String.repeat "─" (model.width - 2I)) ++ "┐" + let bottomBorder = "└" ++ (Stdlib.String.repeat "─" (model.width - 2I)) ++ "┘" let tabLine = let tabTexts = model.tabs |> Stdlib.List.indexedMap (fun i tab -> - let isActive = (Builtin.unwrap (Stdlib.Int.toInt64 i)) == model.activeTabIndex + let isActive = i == model.activeTabIndex let tabColor = if isActive then Core.Types.Color.Primary else Core.Types.Color.Default let styledTab = Core.Rendering.colorize tabColor tab.label if isActive then "[" ++ styledTab ++ "]" else " " ++ styledTab ++ " ") let combinedTabs = Stdlib.String.join tabTexts " " - let paddedTabs = Core.Rendering.padText combinedTabs (model.width - 4L) Core.Types.Alignment.Center + let paddedTabs = Core.Rendering.padText combinedTabs (model.width - 4I) Core.Types.Alignment.Center "│ " ++ paddedTabs ++ " │" [topBorder; tabLine; bottomBorder] @@ -183,7 +183,7 @@ let renderTabPanel (component: Core.Types.Component) (context: Co let tabTexts = model.tabs |> Stdlib.List.indexedMap (fun i tab -> - let isActive = (Builtin.unwrap (Stdlib.Int.toInt64 i)) == model.activeTabIndex + let isActive = i == model.activeTabIndex if isActive then "●" ++ tab.label else "○" ++ tab.label) let combinedTabs = Stdlib.String.join tabTexts " │ " @@ -197,7 +197,7 @@ let renderTabPanel (component: Core.Types.Component) (context: Co let tabTexts = model.tabs |> Stdlib.List.indexedMap (fun i tab -> - let isActive = (Builtin.unwrap (Stdlib.Int.toInt64 i)) == model.activeTabIndex + let isActive = i == model.activeTabIndex let tabColor = if isActive then Core.Types.Color.Primary else Core.Types.Color.Secondary let styledTab = Core.Rendering.colorize tabColor tab.label if isActive then "(" ++ styledTab ++ ")" else " " ++ styledTab ++ " ") @@ -208,9 +208,9 @@ let renderTabPanel (component: Core.Types.Component) (context: Co [pillLine] -let setActiveTab (component: Core.Types.Component) (index: Int64) : Core.Types.Component = +let setActiveTab (component: Core.Types.Component) (index: Int) : Core.Types.Component = let model = component.model - if index >= 0L && index < (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length model.tabs))) then + if index >= 0I && index < (Stdlib.List.length model.tabs) then { component with model = { model with activeTabIndex = index } } else component @@ -218,14 +218,14 @@ let setActiveTab (component: Core.Types.Component) (index: Int64) // Filter Panel Component (specialized panel for filters) type FilterPanelModel = { filters: List - appliedFilters: List - width: Int64 + appliedFilters: List + width: Int title: String } -let createFilterPanel (title: String) (width: Int64) : Core.Types.Component = +let createFilterPanel (title: String) (width: Int) : Core.Types.Component = let model = FilterPanelModel { filters = []; appliedFilters = []; width = width; title = title } - let height = 3L - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = width; height = height } } + let height = 3I + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0I; y = 0I }; dimensions = Core.Types.Dimensions { width = width; height = height } } Core.Types.Component { id = "filterpanel-" ++ title model = model @@ -237,7 +237,7 @@ let createFilterPanel (title: String) (width: Int64) : Core.Types.Component) (filter: PanelItem) : Core.Types.Component = let model = component.model let newFilters = model.filters |> Stdlib.List.append [filter] - let newHeight = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length newFilters))) + 3L + let newHeight = (Stdlib.List.length newFilters) + 3I let newBounds = Core.Types.Bounds { position = component.bounds.position; dimensions = Core.Types.Dimensions { width = model.width; height = newHeight } } { component with model = { model with filters = newFilters } @@ -246,33 +246,33 @@ let addFilter (component: Core.Types.Component) (filter: Panel let renderFilterPanel (component: Core.Types.Component) (context: Core.Types.RenderContext) : List = let model = component.model - let topBorder = "┌" ++ (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L))) ++ "┐" - let bottomBorder = "└" ++ (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L))) ++ "┘" + let topBorder = "┌" ++ (Stdlib.String.repeat "─" (model.width - 2I)) ++ "┐" + let bottomBorder = "└" ++ (Stdlib.String.repeat "─" (model.width - 2I)) ++ "┘" let titleLine = let styledTitle = Core.Rendering.colorize Core.Types.Color.Primary (Core.Rendering.bold model.title) - let paddedTitle = Core.Rendering.padText styledTitle (model.width - 4L) Core.Types.Alignment.Left + let paddedTitle = Core.Rendering.padText styledTitle (model.width - 4I) Core.Types.Alignment.Left "│ " ++ paddedTitle ++ " │" - let separatorLine = "├" ++ (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 (model.width - 2L))) ++ "┤" + let separatorLine = "├" ++ (Stdlib.String.repeat "─" (model.width - 2I)) ++ "┤" let filterLines = model.filters |> Stdlib.List.indexedMap (fun i filter -> - let isApplied = Stdlib.List.``member`` model.appliedFilters (Builtin.unwrap (Stdlib.Int.toInt64 i)) + let isApplied = Stdlib.List.``member`` model.appliedFilters i let checkbox = if isApplied then "☑" else "☐" let filterColor = if isApplied then Core.Types.Color.Success else Core.Types.Color.Default let styledLabel = Core.Rendering.colorize filterColor (checkbox ++ " " ++ filter.label) - let paddedLabel = Core.Rendering.padText styledLabel (model.width - 4L) Core.Types.Alignment.Left + let paddedLabel = Core.Rendering.padText styledLabel (model.width - 4I) Core.Types.Alignment.Left "│ " ++ paddedLabel ++ " │") [topBorder; titleLine; separatorLine] |> Stdlib.List.append filterLines |> Stdlib.List.append [bottomBorder] -let toggleFilter (component: Core.Types.Component) (index: Int64) : Core.Types.Component = +let toggleFilter (component: Core.Types.Component) (index: Int) : Core.Types.Component = let model = component.model - if index >= 0L && index < (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length model.filters))) then + if index >= 0I && index < (Stdlib.List.length model.filters) then let isApplied = Stdlib.List.``member`` model.appliedFilters index let newAppliedFilters = if isApplied then diff --git a/packages/darklang/cli/ui/components/progress.dark b/packages/darklang/cli/ui/components/progress.dark index 29a98c5b27..7c56c3f7ac 100644 --- a/packages/darklang/cli/ui/components/progress.dark +++ b/packages/darklang/cli/ui/components/progress.dark @@ -1,15 +1,15 @@ module Darklang.CLI.UI.Components.Progress type ProgressModel = - { value: Int64 - min: Int64 - max: Int64 + { value: Int + min: Int + max: Int color: Core.Types.Color showPercentage: Bool } -let createProgressBar (value: Int64) (min: Int64) (max: Int64) (color: Core.Types.Color) : Core.Types.Component = +let createProgressBar (value: Int) (min: Int) (max: Int) (color: Core.Types.Color) : Core.Types.Component = let model = ProgressModel { value = value; min = min; max = max; color = color; showPercentage = true } - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = 20L; height = 1L } } + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0I; y = 0I }; dimensions = Core.Types.Dimensions { width = 20I; height = 1I } } Core.Types.Component { id = "progress" model = model @@ -22,22 +22,22 @@ let renderProgressBar (component: Core.Types.Component) (context: let model = component.model let range = model.max - model.min let progress = model.value - model.min - let availableWidth = component.bounds.dimensions.width - 2L - let filledWidth = if range == 0L then 0L else Stdlib.Int64.divide (progress * availableWidth) range - let filled = Stdlib.String.repeat "█" (Stdlib.Int.fromInt64 filledWidth) - let empty = Stdlib.String.repeat "░" (Stdlib.Int.fromInt64 (component.bounds.dimensions.width - 2L - filledWidth)) + let availableWidth = component.bounds.dimensions.width - 2I + let filledWidth = if range == 0I then 0I else Stdlib.Int.divide (progress * availableWidth) range + let filled = Stdlib.String.repeat "█" filledWidth + let empty = Stdlib.String.repeat "░" (component.bounds.dimensions.width - 2I - filledWidth) let progressText = "[" ++ filled ++ empty ++ "]" let coloredProgress = Core.Rendering.colorize model.color progressText if model.showPercentage then - let percentValue = if range == 0L then 0L else Stdlib.Int64.divide (progress * 100L) range - let percentText = " " ++ Stdlib.Int64.toString percentValue ++ "%" + let percentValue = if range == 0I then 0I else Stdlib.Int.divide (progress * 100I) range + let percentText = " " ++ Stdlib.Int.toString percentValue ++ "%" [ coloredProgress ++ percentText ] else [ coloredProgress ] -let updateProgressValue (component: Core.Types.Component) (value: Int64) : Core.Types.Component = +let updateProgressValue (component: Core.Types.Component) (value: Int) : Core.Types.Component = let model = component.model let clampedValue = if value < model.min then model.min @@ -45,7 +45,7 @@ let updateProgressValue (component: Core.Types.Component) (value: else value { component with model = { model with value = clampedValue } } -let setProgressRange (component: Core.Types.Component) (min: Int64) (max: Int64) : Core.Types.Component = +let setProgressRange (component: Core.Types.Component) (min: Int) (max: Int) : Core.Types.Component = let model = component.model let clampedValue = if model.value < min then min diff --git a/packages/darklang/cli/ui/components/scrollbar.dark b/packages/darklang/cli/ui/components/scrollbar.dark index 59491343e2..f8d0378acb 100644 --- a/packages/darklang/cli/ui/components/scrollbar.dark +++ b/packages/darklang/cli/ui/components/scrollbar.dark @@ -3,19 +3,19 @@ module Darklang.CLI.UI.Components.Scrollbar // Scrollbar Component type ScrollbarModel = - { position: Int64 - total: Int64 - visible: Int64 - height: Int64 + { position: Int + total: Int + visible: Int + height: Int orientation: ScrollOrientation } type ScrollOrientation = | Vertical | Horizontal -let createScrollbar (position: Int64) (total: Int64) (visible: Int64) (height: Int64) : Core.Types.Component = +let createScrollbar (position: Int) (total: Int) (visible: Int) (height: Int) : Core.Types.Component = let model = ScrollbarModel { position = position; total = total; visible = visible; height = height; orientation = ScrollOrientation.Vertical } - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = 1L; height = height } } + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0I; y = 0I }; dimensions = Core.Types.Dimensions { width = 1I; height = height } } Core.Types.Component { id = "scrollbar" model = model @@ -28,30 +28,30 @@ let renderScrollbar (component: Core.Types.Component) (context: let model = component.model if model.total <= model.visible then - let maxIndex = model.height - 1L - (Stdlib.List.range 0I (Stdlib.Int.fromInt64 maxIndex)) + let maxIndex = model.height - 1I + (Stdlib.List.range 0I maxIndex) |> Stdlib.List.map (fun _ -> "│") else - let thumbSize = Stdlib.Int64.max 1L (Stdlib.Int64.divide (model.visible * model.height) model.total) + let thumbSize = Stdlib.Int.max 1I (Stdlib.Int.divide (model.visible * model.height) model.total) let remainingSpace = model.total - model.visible let thumbPos = - if remainingSpace <= 0L then - 0L + if remainingSpace <= 0I then + 0I else let heightOffset = model.height - thumbSize - Stdlib.Int64.divide (model.position * heightOffset) remainingSpace + Stdlib.Int.divide (model.position * heightOffset) remainingSpace - let maxIndex = model.height - 1L - (Stdlib.List.range 0I (Stdlib.Int.fromInt64 maxIndex)) + let maxIndex = model.height - 1I + (Stdlib.List.range 0I maxIndex) |> Stdlib.List.map (fun i -> - if (Builtin.unwrap (Stdlib.Int.toInt64 i)) >= thumbPos && (Builtin.unwrap (Stdlib.Int.toInt64 i)) < (thumbPos + thumbSize) then + if i >= thumbPos && i < (thumbPos + thumbSize) then "█" else "░") -let createHorizontalScrollbar (position: Int64) (total: Int64) (visible: Int64) (width: Int64) : Core.Types.Component = +let createHorizontalScrollbar (position: Int) (total: Int) (visible: Int) (width: Int) : Core.Types.Component = let model = ScrollbarModel { position = position; total = total; visible = visible; height = width; orientation = ScrollOrientation.Horizontal } - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = width; height = 1L } } + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0I; y = 0I }; dimensions = Core.Types.Dimensions { width = width; height = 1I } } Core.Types.Component { id = "scrollbar-horizontal" model = model @@ -64,21 +64,21 @@ let renderHorizontalScrollbar (component: Core.Types.Component) let model = component.model if model.total <= model.visible then - [Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 model.height)] + [Stdlib.String.repeat "─" model.height] else - let thumbSize = Stdlib.Int64.max 1L (Stdlib.Int64.divide (model.visible * model.height) model.total) + let thumbSize = Stdlib.Int.max 1I (Stdlib.Int.divide (model.visible * model.height) model.total) let remainingSpace = model.total - model.visible let thumbPos = - if remainingSpace <= 0L then - 0L + if remainingSpace <= 0I then + 0I else - Stdlib.Int64.divide (model.position * (model.height - thumbSize)) remainingSpace + Stdlib.Int.divide (model.position * (model.height - thumbSize)) remainingSpace - let maxIndex = model.height - 1L + let maxIndex = model.height - 1I let scrollLine = - (Stdlib.List.range 0I (Stdlib.Int.fromInt64 maxIndex)) + (Stdlib.List.range 0I maxIndex) |> Stdlib.List.map (fun i -> - if (Builtin.unwrap (Stdlib.Int.toInt64 i)) >= thumbPos && (Builtin.unwrap (Stdlib.Int.toInt64 i)) < (thumbPos + thumbSize) then + if i >= thumbPos && i < (thumbPos + thumbSize) then "█" else "░") @@ -86,7 +86,7 @@ let renderHorizontalScrollbar (component: Core.Types.Component) [scrollLine] -let updateScrollPosition (component: Core.Types.Component) (newPosition: Int64) : Core.Types.Component = +let updateScrollPosition (component: Core.Types.Component) (newPosition: Int) : Core.Types.Component = let model = component.model - let clampedPosition = Stdlib.Int64.max 0L (Stdlib.Int64.min newPosition (model.total - model.visible)) + let clampedPosition = Stdlib.Int.max 0I (Stdlib.Int.min newPosition (model.total - model.visible)) { component with model = { model with position = clampedPosition } } \ No newline at end of file diff --git a/packages/darklang/cli/ui/components/spinner.dark b/packages/darklang/cli/ui/components/spinner.dark index 39bd446c2c..8e240b35a0 100644 --- a/packages/darklang/cli/ui/components/spinner.dark +++ b/packages/darklang/cli/ui/components/spinner.dark @@ -20,7 +20,7 @@ let getFrames (style: SpinnerStyle) : List = type SpinnerModel = { message: String style: SpinnerStyle - frameIndex: Int64 + frameIndex: Int color: Core.Types.Color running: Bool } @@ -29,14 +29,14 @@ let createSpinner (message: String) (style: SpinnerStyle) : Core.Types.Component SpinnerModel { message = message style = style - frameIndex = 0L + frameIndex = 0I color = Core.Types.Color.Primary running = true } let bounds = Core.Types.Bounds - { position = Core.Types.Position { x = 0L; y = 0L } - dimensions = Core.Types.Dimensions { width = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length message))) + 4L; height = 1L } } + { position = Core.Types.Position { x = 0I; y = 0I } + dimensions = Core.Types.Dimensions { width = (Stdlib.String.length message) + 4I; height = 1I } } Core.Types.Component { id = "spinner" @@ -57,10 +57,10 @@ let renderSpinner (component: Core.Types.Component) (context: Core let frame = let frameIndex = - match Stdlib.Int64.remainder model.frameIndex (Builtin.unwrap (Stdlib.Int.toInt64 frameCount)) with + match Stdlib.Int.remainder model.frameIndex frameCount with | Ok idx -> idx - | Error _ -> 0L - match Stdlib.List.getAt frames (Stdlib.Int.fromInt64 frameIndex) with + | Error _ -> 0I + match Stdlib.List.getAt frames frameIndex with | Some f -> f | None -> "?" @@ -73,9 +73,9 @@ let tick (component: Core.Types.Component) : Core.Types.Component< let frames = getFrames model.style let frameCount = Stdlib.List.length frames let nextIndex = - match Stdlib.Int64.remainder (model.frameIndex + 1L) (Builtin.unwrap (Stdlib.Int.toInt64 frameCount)) with + match Stdlib.Int.remainder (model.frameIndex + 1I) frameCount with | Ok idx -> idx - | Error _ -> 0L + | Error _ -> 0I { component with model = { model with frameIndex = nextIndex } } else component @@ -90,7 +90,7 @@ let setSpinnerColor (component: Core.Types.Component) (color: Core let setSpinnerStyle (component: Core.Types.Component) (style: SpinnerStyle) : Core.Types.Component = let model = component.model - { component with model = { model with style = style; frameIndex = 0L } } + { component with model = { model with style = style; frameIndex = 0I } } let startSpinner (component: Core.Types.Component) : Core.Types.Component = let model = component.model diff --git a/packages/darklang/cli/ui/components/statusbar.dark b/packages/darklang/cli/ui/components/statusbar.dark index c403810b3e..f0d88a4749 100644 --- a/packages/darklang/cli/ui/components/statusbar.dark +++ b/packages/darklang/cli/ui/components/statusbar.dark @@ -7,12 +7,12 @@ type StatusBarModel = { leftText: String rightText: String centerText: String - width: Int64 + width: Int backgroundColor: Core.Types.Color } -let createStatusBar (leftText: String) (rightText: String) (width: Int64) : Core.Types.Component = +let createStatusBar (leftText: String) (rightText: String) (width: Int) : Core.Types.Component = let model = StatusBarModel { leftText = leftText; rightText = rightText; centerText = ""; width = width; backgroundColor = Core.Types.Color.Dark } - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = width; height = 1L } } + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0I; y = 0I }; dimensions = Core.Types.Dimensions { width = width; height = 1I } } Core.Types.Component { id = "statusbar" model = model @@ -24,34 +24,34 @@ let createStatusBar (leftText: String) (rightText: String) (width: Int64) : Core let renderStatusBar (component: Core.Types.Component) (context: Core.Types.RenderContext) : List = let model = component.model - let leftLen = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length model.leftText)) - let rightLen = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length model.rightText)) - let centerLen = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length model.centerText)) + let leftLen = Stdlib.String.length model.leftText + let rightLen = Stdlib.String.length model.rightText + let centerLen = Stdlib.String.length model.centerText let line = if Stdlib.String.isEmpty model.centerText then let paddingSpace = model.width - leftLen - rightLen let padding = - if paddingSpace > 0L then - Stdlib.String.repeat " " (Stdlib.Int.fromInt64 paddingSpace) + if paddingSpace > 0I then + Stdlib.String.repeat " " paddingSpace else "" model.leftText ++ padding ++ model.rightText else let totalContentLen = leftLen + centerLen + rightLen if totalContentLen >= model.width then - Stdlib.String.slice (model.leftText ++ model.centerText ++ model.rightText) 0I (Stdlib.Int.fromInt64 model.width) + Stdlib.String.slice (model.leftText ++ model.centerText ++ model.rightText) 0I model.width else - let leftPadding = Stdlib.Int64.divide (model.width - centerLen) 2L - leftLen + let leftPadding = Stdlib.Int.divide (model.width - centerLen) 2I - leftLen let rightPadding = model.width - leftLen - centerLen - leftPadding let leftPad = - if leftPadding > 0L then - Stdlib.String.repeat " " (Stdlib.Int.fromInt64 leftPadding) + if leftPadding > 0I then + Stdlib.String.repeat " " leftPadding else "" let rightPad = - if rightPadding > 0L then - Stdlib.String.repeat " " (Stdlib.Int.fromInt64 rightPadding) + if rightPadding > 0I then + Stdlib.String.repeat " " rightPadding else "" model.leftText ++ leftPad ++ model.centerText ++ rightPad diff --git a/packages/darklang/cli/ui/components/table.dark b/packages/darklang/cli/ui/components/table.dark index 8805f58c4f..91b0dbcc54 100644 --- a/packages/darklang/cli/ui/components/table.dark +++ b/packages/darklang/cli/ui/components/table.dark @@ -2,37 +2,37 @@ module Darklang.CLI.UI.Components.Table type Column = { header: String - width: Int64 + width: Int alignment: Core.Types.Alignment } type TableModel = { columns: List rows: List> - selectedRow: Int64 + selectedRow: Int showHeader: Bool borderStyle: Core.Rendering.BoxStyle headerColor: Core.Types.Color selectedColor: Core.Types.Color } -let createColumn (header: String) (width: Int64) : Column = +let createColumn (header: String) (width: Int) : Column = Column { header = header; width = width; alignment = Core.Types.Alignment.Left } -let createColumnWithAlignment (header: String) (width: Int64) (alignment: Core.Types.Alignment) : Column = +let createColumnWithAlignment (header: String) (width: Int) (alignment: Core.Types.Alignment) : Column = Column { header = header; width = width; alignment = alignment } let createTable (columns: List) (rows: List>) : Core.Types.Component = let totalWidth = columns - |> Stdlib.List.map (fun col -> col.width + 1L) - |> Stdlib.List.fold 1L (fun acc w -> acc + w) + |> Stdlib.List.map (fun col -> col.width + 1I) + |> Stdlib.List.fold 1I (fun acc w -> acc + w) - let height = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length rows))) + 3L + let height = (Stdlib.List.length rows) + 3I let model = TableModel { columns = columns rows = rows - selectedRow = -1L + selectedRow = -1I showHeader = true borderStyle = Core.Rendering.BoxStyle.Single headerColor = Core.Types.Color.Primary @@ -40,7 +40,7 @@ let createTable (columns: List) (rows: List>) : Core.Types. let bounds = Core.Types.Bounds - { position = Core.Types.Position { x = 0L; y = 0L } + { position = Core.Types.Position { x = 0I; y = 0I } dimensions = Core.Types.Dimensions { width = totalWidth; height = height } } Core.Types.Component @@ -65,7 +65,7 @@ let renderTable (component: Core.Types.Component) (context: Core.Typ // Build column separator segments (horizontal lines for each column width) let columnSegments = - model.columns |> Stdlib.List.map (fun col -> Stdlib.String.repeat horiz (Stdlib.Int.fromInt64 col.width)) + model.columns |> Stdlib.List.map (fun col -> Stdlib.String.repeat horiz col.width) // Top border: ┌───┬───┬───┐ let topBorder = @@ -98,7 +98,7 @@ let renderTable (component: Core.Types.Component) (context: Core.Typ let dataLines = model.rows |> Stdlib.List.indexedMap (fun rowIndex row -> - let isSelected = (Builtin.unwrap (Stdlib.Int.toInt64 rowIndex)) == model.selectedRow + let isSelected = rowIndex == model.selectedRow let cellsOpt = Stdlib.List.map2 row model.columns (fun cellValue col -> @@ -131,12 +131,12 @@ let addTableRow (component: Core.Types.Component) (row: List let model = component.model { component with model = { model with rows = Stdlib.List.append model.rows [row] } } -let selectRow (component: Core.Types.Component) (index: Int64) : Core.Types.Component = +let selectRow (component: Core.Types.Component) (index: Int) : Core.Types.Component = let model = component.model - let maxIndex = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length model.rows))) - 1L + let maxIndex = (Stdlib.List.length model.rows) - 1I let clampedIndex = - if index < 0L then - 0L + if index < 0I then + 0I else if index > maxIndex then maxIndex else @@ -145,10 +145,10 @@ let selectRow (component: Core.Types.Component) (index: Int64) : Cor let selectNextRow (component: Core.Types.Component) : Core.Types.Component = let model = component.model - let maxIndex = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length model.rows))) - 1L + let maxIndex = (Stdlib.List.length model.rows) - 1I let nextIndex = if model.selectedRow < maxIndex then - model.selectedRow + 1L + model.selectedRow + 1I else model.selectedRow { component with model = { model with selectedRow = nextIndex } } @@ -156,10 +156,10 @@ let selectNextRow (component: Core.Types.Component) : Core.Types.Com let selectPreviousRow (component: Core.Types.Component) : Core.Types.Component = let model = component.model let prevIndex = - if model.selectedRow > 0L then - model.selectedRow - 1L + if model.selectedRow > 0I then + model.selectedRow - 1I else - 0L + 0I { component with model = { model with selectedRow = prevIndex } } let setTableBorderStyle (component: Core.Types.Component) (style: Core.Rendering.BoxStyle) : Core.Types.Component = @@ -180,7 +180,7 @@ let showTableHeader (component: Core.Types.Component) : Core.Types.C let getSelectedRow (component: Core.Types.Component) : Stdlib.Option.Option> = let model = component.model - if model.selectedRow >= 0L then - Stdlib.List.getAt model.rows (Stdlib.Int.fromInt64 model.selectedRow) + if model.selectedRow >= 0I then + Stdlib.List.getAt model.rows model.selectedRow else Stdlib.Option.Option.None diff --git a/packages/darklang/cli/ui/components/textblock.dark b/packages/darklang/cli/ui/components/textblock.dark index 325b0dac00..ee5244909b 100644 --- a/packages/darklang/cli/ui/components/textblock.dark +++ b/packages/darklang/cli/ui/components/textblock.dark @@ -12,10 +12,10 @@ let createTextBlock (lines: List) (color: Core.Types.Color) (alignment: let model = TextBlockModel { lines = lines; color = color; alignment = alignment; wordWrap = false } let maxWidth = lines - |> Stdlib.List.map (fun s -> Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length s))) - |> Stdlib.List.fold 0L (fun acc len -> if len > acc then len else acc) - let height = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length lines)) - let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0L; y = 0L }; dimensions = Core.Types.Dimensions { width = maxWidth; height = height } } + |> Stdlib.List.map (fun s -> Stdlib.String.length s) + |> Stdlib.List.fold 0I (fun acc len -> if len > acc then len else acc) + let height = Stdlib.List.length lines + let bounds = Core.Types.Bounds { position = Core.Types.Position { x = 0I; y = 0I }; dimensions = Core.Types.Dimensions { width = maxWidth; height = height } } Core.Types.Component { id = "textblock" model = model @@ -35,9 +35,9 @@ let setTextBlockLines (component: Core.Types.Component) (lines: let model = component.model let maxWidth = lines - |> Stdlib.List.map (fun s -> Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length s))) - |> Stdlib.List.fold 0L (fun acc len -> if len > acc then len else acc) - let height = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length lines)) + |> Stdlib.List.map (fun s -> Stdlib.String.length s) + |> Stdlib.List.fold 0I (fun acc len -> if len > acc then len else acc) + let height = Stdlib.List.length lines let newBounds = Core.Types.Bounds { position = component.bounds.position; dimensions = Core.Types.Dimensions { width = maxWidth; height = height } } { component with model = { model with lines = lines } diff --git a/packages/darklang/cli/ui/core/rendering.dark b/packages/darklang/cli/ui/core/rendering.dark index d311d87d54..c20b365b19 100644 --- a/packages/darklang/cli/ui/core/rendering.dark +++ b/packages/darklang/cli/ui/core/rendering.dark @@ -88,29 +88,26 @@ let drawBoxWithStyle (bounds: Types.Bounds) (title: String) (content: List Stdlib.List.map (fun line -> - let lineLength = - Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length line)) - let padding = if lineLength < innerWidth - 1L then Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (innerWidth - 1L - lineLength)) else "" + let lineLength = Stdlib.String.length line + let padding = if lineLength < innerWidth - 1I then Stdlib.String.repeat " " (innerWidth - 1I - lineLength) else "" vert ++ " " ++ line ++ padding ++ vert) [topBorder] @@ -122,27 +119,26 @@ let drawBoxWithStyle (bounds: Types.Bounds) (title: String) (content: List) : List = drawBoxWithStyle bounds title content BoxStyle.Single -let padText (text: String) (width: Int64) (alignment: Types.Alignment) : String = - let textLength = - Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length text)) +let padText (text: String) (width: Int) (alignment: Types.Alignment) : String = + let textLength = Stdlib.String.length text if textLength >= width then - Stdlib.String.slice text 0I (Stdlib.Int.fromInt64 width) + Stdlib.String.slice text 0I width else let padding = width - textLength match alignment with - | Left -> text ++ Stdlib.String.repeat " " (Stdlib.Int.fromInt64 padding) - | Right -> Stdlib.String.repeat " " (Stdlib.Int.fromInt64 padding) ++ text + | Left -> text ++ Stdlib.String.repeat " " padding + | Right -> Stdlib.String.repeat " " padding ++ text | Center -> - let leftPad = Stdlib.Int64.divide padding 2L + let leftPad = Stdlib.Int.divide padding 2I let rightPad = padding - leftPad - Stdlib.String.repeat " " (Stdlib.Int.fromInt64 leftPad) ++ text ++ Stdlib.String.repeat " " (Stdlib.Int.fromInt64 rightPad) - | Justify -> text ++ Stdlib.String.repeat " " (Stdlib.Int.fromInt64 padding) + Stdlib.String.repeat " " leftPad ++ text ++ Stdlib.String.repeat " " rightPad + | Justify -> text ++ Stdlib.String.repeat " " padding -let truncateText (text: String) (maxWidth: Int64) : String = - if Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length text)) <= maxWidth then +let truncateText (text: String) (maxWidth: Int) : String = + if Stdlib.String.length text <= maxWidth then text else - Stdlib.String.slice text 0I (Stdlib.Int.fromInt64 (maxWidth - 3L)) ++ "..." + Stdlib.String.slice text 0I (maxWidth - 3I) ++ "..." // Focus indicators let addFocusIndicator (text: String) (hasFocus: Bool) : String = diff --git a/packages/darklang/cli/ui/core/types.dark b/packages/darklang/cli/ui/core/types.dark index 99bce3a1c6..4e6c8c5886 100644 --- a/packages/darklang/cli/ui/core/types.dark +++ b/packages/darklang/cli/ui/core/types.dark @@ -25,8 +25,8 @@ type Alignment = | Justify // Layout Types -type Position = { x: Int64; y: Int64 } -type Dimensions = { width: Int64; height: Int64 } +type Position = { x: Int; y: Int } +type Dimensions = { width: Int; height: Int } type Bounds = { position: Position; dimensions: Dimensions } // Event Types @@ -76,7 +76,7 @@ type Component<'TModel> = // Rendering Context type RenderContext = - { availableWidth: Int64 - availableHeight: Int64 + { availableWidth: Int + availableHeight: Int hasFocus: Bool theme: String } diff --git a/packages/darklang/cli/ui/demo.dark b/packages/darklang/cli/ui/demo.dark index 3baa471438..06de19b395 100644 --- a/packages/darklang/cli/ui/demo.dark +++ b/packages/darklang/cli/ui/demo.dark @@ -5,8 +5,8 @@ module Darklang.CLI.UI.Demo let demoContext : Core.Types.RenderContext = Core.Types.RenderContext - { availableWidth = 60L - availableHeight = 20L + { availableWidth = 60I + availableHeight = 20I hasFocus = true theme = "default" } @@ -14,7 +14,7 @@ let printSection (title: String) : Unit = Stdlib.printLine "" Stdlib.printLine (Core.Rendering.bold ("━━━ " ++ title ++ " ━━━")) -let run (unit: Unit) : Int64 = +let run (unit: Unit) : Int = Stdlib.printLine (Core.Rendering.bold "Darklang CLI UI Component Demo") Stdlib.printLine (Core.Rendering.dim "Visual verification of component rendering") @@ -22,8 +22,8 @@ let run (unit: Unit) : Int64 = printSection "Box Styles" let bounds = Core.Types.Bounds - { position = Core.Types.Position { x = 0L; y = 0L } - dimensions = Core.Types.Dimensions { width = 30L; height = 5L } } + { position = Core.Types.Position { x = 0I; y = 0I } + dimensions = Core.Types.Dimensions { width = 30I; height = 5I } } let singleBox = Core.Rendering.drawBoxWithStyle bounds "Single" ["Content"] Core.Rendering.BoxStyle.Single singleBox |> Stdlib.List.iter Stdlib.printLine @@ -36,7 +36,7 @@ let run (unit: Unit) : Int64 = // Progress printSection "Progress Bar" - let progress = Components.Progress.createProgressBar 75L 0L 100L Core.Types.Color.Success + let progress = Components.Progress.createProgressBar 75I 0I 100I Core.Types.Color.Success let progressLines = Components.Progress.renderProgressBar progress demoContext progressLines |> Stdlib.List.iter Stdlib.printLine @@ -49,12 +49,12 @@ let run (unit: Unit) : Int64 = // Table printSection "Table" - let col1 = Components.Table.createColumn "Name" 15L - let col2 = Components.Table.createColumn "Status" 10L + let col1 = Components.Table.createColumn "Name" 15I + let col2 = Components.Table.createColumn "Status" 10I let cols = [col1; col2] let rows = [["Alice"; "Active"]; ["Bob"; "Pending"]; ["Charlie"; "Done"]] let table = Components.Table.createTable cols rows - let tableWithSelection = Components.Table.selectRow table 1L + let tableWithSelection = Components.Table.selectRow table 1I let tableLines = Components.Table.renderTable tableWithSelection demoContext tableLines |> Stdlib.List.iter Stdlib.printLine @@ -72,7 +72,7 @@ let run (unit: Unit) : Int64 = // Card printSection "Card" - let card = Components.Card.createCard "User Profile" ["Name: Alice"; "Role: Admin"; "Status: Active"] 35L 8L + let card = Components.Card.createCard "User Profile" ["Name: Alice"; "Role: Admin"; "Status: Active"] 35I 8I let cardWithColors = Components.Card.setCardColors card Core.Types.Color.Primary Core.Types.Color.Default let cardWithShadow = Components.Card.enableCardShadow cardWithColors let cardLines = Components.Card.renderCard cardWithShadow demoContext @@ -80,9 +80,9 @@ let run (unit: Unit) : Int64 = // Messages printSection "Messages" - let successMsg = Components.Message.createMessage "Success" "Operation completed!" Core.Types.Color.Success 40L - let warningMsg = Components.Message.createMessage "Warning" "Check your input." Core.Types.Color.Warning 40L - let errorMsg = Components.Message.createMessage "Error" "Something went wrong." Core.Types.Color.Error 40L + let successMsg = Components.Message.createMessage "Success" "Operation completed!" Core.Types.Color.Success 40I + let warningMsg = Components.Message.createMessage "Warning" "Check your input." Core.Types.Color.Warning 40I + let errorMsg = Components.Message.createMessage "Error" "Something went wrong." Core.Types.Color.Error 40I let successLines = Components.Message.renderMessage successMsg demoContext successLines |> Stdlib.List.iter Stdlib.printLine let warningLines = Components.Message.renderMessage warningMsg demoContext @@ -92,7 +92,7 @@ let run (unit: Unit) : Int64 = // Toast printSection "Toast" - let toast = Components.Message.createToast "File saved successfully" Core.Types.Color.Success 3000L + let toast = Components.Message.createToast "File saved successfully" Core.Types.Color.Success 3000I let toastLines = Components.Message.renderToast toast demoContext toastLines |> Stdlib.List.iter Stdlib.printLine @@ -104,16 +104,16 @@ let run (unit: Unit) : Int64 = Components.ListView.ListItem { text = "Item 3 (disabled)"; enabled = false; data = "3" }; Components.ListView.ListItem { text = "Item 4"; enabled = true; data = "4" } ] - let listView = Components.ListView.createListView items 30L 6L - let listViewWithSelection = Components.ListView.selectItem listView 1L + let listView = Components.ListView.createListView items 30I 6I + let listViewWithSelection = Components.ListView.selectItem listView 1I let listViewLines = Components.ListView.renderListView listViewWithSelection demoContext listViewLines |> Stdlib.List.iter Stdlib.printLine // Dividers printSection "Dividers" - let divider1 = Components.Divider.createDivider "─" 40L Core.Types.Color.Default - let divider2 = Components.Divider.createDivider "═" 40L Core.Types.Color.Primary - let divider3 = Components.Divider.createDivider "·" 40L Core.Types.Color.Secondary + let divider1 = Components.Divider.createDivider "─" 40I Core.Types.Color.Default + let divider2 = Components.Divider.createDivider "═" 40I Core.Types.Color.Primary + let divider3 = Components.Divider.createDivider "·" 40I Core.Types.Color.Secondary let divider1Lines = Components.Divider.renderDivider divider1 demoContext divider1Lines |> Stdlib.List.iter Stdlib.printLine let divider2Lines = Components.Divider.renderDivider divider2 demoContext @@ -123,15 +123,15 @@ let run (unit: Unit) : Int64 = // StatusBar printSection "StatusBar" - let statusBar = Components.StatusBar.createStatusBar "Ready" "Ln 42, Col 8" 50L + let statusBar = Components.StatusBar.createStatusBar "Ready" "Ln 42, Col 8" 50I let statusBarWithCenter = Components.StatusBar.setCenterText statusBar "main.dark" let statusBarLines = Components.StatusBar.renderStatusBar statusBarWithCenter demoContext statusBarLines |> Stdlib.List.iter Stdlib.printLine // Pagination printSection "Pagination" - let pagination = Components.Pagination.createPagination 100L 10L - let paginationPage3 = Components.Pagination.goToPage pagination 3L + let pagination = Components.Pagination.createPagination 100I 10I + let paginationPage3 = Components.Pagination.goToPage pagination 3I let paginationLines = Components.Pagination.renderPagination paginationPage3 demoContext paginationLines |> Stdlib.List.iter Stdlib.printLine @@ -140,7 +140,7 @@ let run (unit: Unit) : Int64 = // TextInput Stdlib.printLine "TextInput:" - let textInput = Components.Forms.createTextInput "Enter name..." 20L + let textInput = Components.Forms.createTextInput "Enter name..." 20I let textInputLines = Components.Forms.renderTextInput textInput demoContext textInputLines |> Stdlib.List.iter Stdlib.printLine @@ -155,7 +155,7 @@ let run (unit: Unit) : Int64 = // Radio Group Stdlib.printLine "Radio Group:" - let radio = Components.Forms.createRadioGroup ["Option A"; "Option B"; "Option C"] 1L + let radio = Components.Forms.createRadioGroup ["Option A"; "Option B"; "Option C"] 1I let radioLines = Components.Forms.renderRadioGroup radio demoContext radioLines |> Stdlib.List.iter Stdlib.printLine @@ -176,4 +176,4 @@ let run (unit: Unit) : Int64 = Stdlib.printLine "" Stdlib.printLine (Core.Rendering.dim "Demo complete.") - 0L + 0I diff --git a/packages/darklang/cli/ui/layout.dark b/packages/darklang/cli/ui/layout.dark index 370bc376e6..f1db077106 100644 --- a/packages/darklang/cli/ui/layout.dark +++ b/packages/darklang/cli/ui/layout.dark @@ -5,17 +5,17 @@ module Darklang.Cli.UI.Layout /// What a component wants. type SizeRequest = - { minRows: Int64 - minCols: Int64 - preferredRows: Int64 - preferredCols: Int64 } + { minRows: Int + minCols: Int + preferredRows: Int + preferredCols: Int } /// What a component gets. type Region = - { top: Int64 - left: Int64 - rows: Int64 - cols: Int64 } + { top: Int + left: Int + rows: Int + cols: Int } /// A renderable component that can negotiate its size. type Component = @@ -26,14 +26,14 @@ type Component = // --- Rendering primitives --- /// Move cursor to a position and print a string, truncated to fit the region. -let printAt (region: Region) (row: Int64) (col: Int64) (text: String) : Unit = - if row >= 0L && row < region.rows then +let printAt (region: Region) (row: Int) (col: Int) (text: String) : Unit = + if row >= 0I && row < region.rows then let absRow = region.top + row let absCol = region.left + col - let maxLen = Stdlib.Int64.max 0L (region.cols - col) + let maxLen = Stdlib.Int.max 0I (region.cols - col) let truncated = - if (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length text))) > maxLen then - Stdlib.String.slice text 0I (Stdlib.Int.fromInt64 maxLen) + if Stdlib.String.length text > maxLen then + Stdlib.String.slice text 0I maxLen else text Stdlib.print (Darklang.Cli.Colors.moveCursorTo absRow absCol) @@ -42,45 +42,44 @@ let printAt (region: Region) (row: Int64) (col: Int64) (text: String) : Unit = () /// Fill a row with a repeated character, within the region. -let fillRow (region: Region) (row: Int64) (ch: String) : Unit = - let line = Stdlib.String.repeat ch (Stdlib.Int.fromInt64 region.cols) - printAt region row 0L line +let fillRow (region: Region) (row: Int) (ch: String) : Unit = + let line = Stdlib.String.repeat ch region.cols + printAt region row 0I line /// Fill the entire region with spaces (clear it). let clearRegion (region: Region) : Unit = - (Stdlib.List.range 0I (Stdlib.Int.fromInt64 (region.rows - 1L))) - |> Stdlib.List.iter (fun row -> - fillRow region (Builtin.unwrap (Stdlib.Int.toInt64 row)) " ") + (Stdlib.List.range 0I (region.rows - 1I)) + |> Stdlib.List.iter (fun row -> fillRow region row " ") // --- Layout negotiation --- /// Distribute `totalRows` among components based on their size requests. /// Each gets at least min, then remaining space is split toward preferred. -let distributeRows (totalRows: Int64) (requests: List) : List = +let distributeRows (totalRows: Int) (requests: List) : List = let count = Stdlib.List.length requests if count == 0I then [] else // First pass: give everyone their minimum let mins = Stdlib.List.map requests (fun r -> r.minRows) - let totalMin = Stdlib.List.fold mins 0L (fun acc n -> acc + n) - let remaining = Stdlib.Int64.max 0L (totalRows - totalMin) + let totalMin = Stdlib.List.fold mins 0I (fun acc n -> acc + n) + let remaining = Stdlib.Int.max 0I (totalRows - totalMin) // Second pass: distribute remaining toward preferred, proportionally let wants = Stdlib.List.map requests (fun r -> - Stdlib.Int64.max 0L (r.preferredRows - r.minRows)) - let totalWant = Stdlib.List.fold wants 0L (fun acc n -> acc + n) - if totalWant == 0L then + Stdlib.Int.max 0I (r.preferredRows - r.minRows)) + let totalWant = Stdlib.List.fold wants 0I (fun acc n -> acc + n) + if totalWant == 0I then mins else // Give each component its min + share of remaining proportional to want (Stdlib.List.map2 mins wants (fun minR want -> let share = - if totalWant > 0L then - Stdlib.Int64.divide (want * remaining) totalWant + if totalWant > 0I then + Stdlib.Int.divide (want * remaining) totalWant else - 0L + 0I minR + share)) |> Stdlib.Option.withDefault mins @@ -112,22 +111,22 @@ let vstack (region: Region) (components: List) : Unit = () /// A fixed-height component: always requests exactly N rows. -let fixedSize (n: Int64) (renderFn: Region -> Unit) : Component = +let fixedSize (n: Int) (renderFn: Region -> Unit) : Component = Component { sizeRequest = fun () -> - SizeRequest { minRows = n; minCols = 0L; preferredRows = n; preferredCols = 0L } + SizeRequest { minRows = n; minCols = 0I; preferredRows = n; preferredCols = 0I } render = renderFn } /// A flexible component: needs at least `min` rows, prefers `preferred`. -let flex (min: Int64) (preferred: Int64) (renderFn: Region -> Unit) : Component = +let flex (min: Int) (preferred: Int) (renderFn: Region -> Unit) : Component = Component { sizeRequest = fun () -> - SizeRequest { minRows = min; minCols = 0L; preferredRows = preferred; preferredCols = 0L } + SizeRequest { minRows = min; minCols = 0I; preferredRows = preferred; preferredCols = 0I } render = renderFn } /// A greedy component: wants all available space, min 1 row. let greedy (renderFn: Region -> Unit) : Component = Component { sizeRequest = fun () -> - SizeRequest { minRows = 1L; minCols = 0L; preferredRows = 999L; preferredCols = 0L } + SizeRequest { minRows = 1I; minCols = 0I; preferredRows = 999I; preferredCols = 0I } render = renderFn } diff --git a/packages/darklang/cli/utils/colors.dark b/packages/darklang/cli/utils/colors.dark index 0909a0fa63..a2ff7d3a21 100644 --- a/packages/darklang/cli/utils/colors.dark +++ b/packages/darklang/cli/utils/colors.dark @@ -11,14 +11,14 @@ let reverse = "\u001b[7m" // Cursor and line control let clearLine = "\u001b[K" let carriageReturn = "\r" -let moveCursorToColumn (col: Int64) : String = $"\u001b[{Stdlib.Int64.toString col}G" -let moveCursorUp (n: Int64) : String = $"\u001b[{Stdlib.Int64.toString n}A" +let moveCursorToColumn (col: Int) : String = $"\u001b[{Stdlib.Int.toString col}G" +let moveCursorUp (n: Int) : String = $"\u001b[{Stdlib.Int.toString n}A" let saveCursor = "\u001b[s" let restoreCursor = "\u001b[u" /// Move cursor to absolute position (row, col). Used to jump to the status bar without disrupting where the user is typing. -let moveCursorTo (row: Int64) (col: Int64) : String = $"\u001b[{Stdlib.Int64.toString row};{Stdlib.Int64.toString col}H" +let moveCursorTo (row: Int) (col: Int) : String = $"\u001b[{Stdlib.Int.toString row};{Stdlib.Int.toString col}H" /// Define which rows can scroll. Content outside this region stays fixed. Used to keep the status bar pinned at the bottom. -let setScrollRegion (top: Int64) (bottom: Int64) : String = $"\u001b[{Stdlib.Int64.toString top};{Stdlib.Int64.toString bottom}r" +let setScrollRegion (top: Int) (bottom: Int) : String = $"\u001b[{Stdlib.Int.toString top};{Stdlib.Int.toString bottom}r" let resetScrollRegion = "\u001b[r" // Standard colors diff --git a/packages/darklang/cli/utils/terminal.dark b/packages/darklang/cli/utils/terminal.dark index f9df1129e2..5fa5cdb1c9 100644 --- a/packages/darklang/cli/utils/terminal.dark +++ b/packages/darklang/cli/utils/terminal.dark @@ -8,26 +8,26 @@ module Display = let exitAltScreen = "\x1b[?1049l" /// Gets terminal height -let getHeight () : Int64 = +let getHeight () : Int = Builtin.cliGetTerminalHeight () /// Gets terminal width -let getWidth () : Int64 = +let getWidth () : Int = Builtin.cliGetTerminalWidth () /// Calculates viewport height for scrollable content -let getViewportHeight (reservedLines: Int64) : Int64 = +let getViewportHeight (reservedLines: Int) : Int = let terminalHeight = getHeight () - let availableHeight = Stdlib.Int64.max 1L (terminalHeight - reservedLines) + let availableHeight = Stdlib.Int.max 1I (terminalHeight - reservedLines) availableHeight /// Calculate scroll offset bounds for safe scrolling -let calculateScrollBounds (totalItems: Int64) (viewportHeight: Int64) : (Int64 * Int64) = - let maxOffset = Stdlib.Int64.max 0L (totalItems - viewportHeight) - (0L, maxOffset) +let calculateScrollBounds (totalItems: Int) (viewportHeight: Int) : (Int * Int) = + let maxOffset = Stdlib.Int.max 0I (totalItems - viewportHeight) + (0I, maxOffset) /// Clamp scroll offset to safe bounds -let clampScrollOffset (offset: Int64) (totalItems: Int64) (viewportHeight: Int64) : Int64 = +let clampScrollOffset (offset: Int) (totalItems: Int) (viewportHeight: Int) : Int = let (minOffset, maxOffset) = calculateScrollBounds totalItems viewportHeight if offset < minOffset then minOffset else if offset > maxOffset then maxOffset From e61d5e00b0a1f402e10d625a7408434194f4bcbc Mon Sep 17 00:00:00 2001 From: OceanOak Date: Wed, 17 Jun 2026 13:55:04 +0000 Subject: [PATCH 15/61] Migrate HTTP statusCode/port/maxBodyBytes/maxAge from Int64 to Int --- .../Builtins.Http.Client/Libs/HttpClient.fs | 4 +- .../src/Builtins/Builtins.Http.Server/Http.fs | 6 +-- .../Builtins.Http.Server/Libs/HttpServer.fs | 12 +++-- backend/testfiles/execution/stdlib/http.dark | 38 +++++++-------- .../http-server/_simple-request-headers.test | 2 +- .../http-server/bad-response-just-int.test | 2 +- .../injected-icon-post-length.test | 2 +- .../injected-icon-post-roundtrip.test | 2 +- .../testfiles/http-server/query-string.test | 2 +- .../http-server/response-with-500.test | 2 +- .../simple-injected-string-post.test | 2 +- .../simple-inline-string-post.test | 2 +- .../http-server/simple-response-headers.test | 2 +- backend/testfiles/http-server/url-http.test | 2 +- backend/testfiles/http-server/url-https.test | 2 +- .../v0/_request-content-type-empty.test | 2 +- .../httpclient/v0/_uri-with-auth-both.test | 2 +- .../v0/basic-delete-helper-function.test | 2 +- .../testfiles/httpclient/v0/basic-delete.test | 2 +- .../v0/basic-get-helper-function.test | 2 +- .../testfiles/httpclient/v0/basic-get.test | 2 +- ...sic-head-returns-body-helper-function.test | 2 +- .../v0/basic-head-returns-body.test | 2 +- .../testfiles/httpclient/v0/basic-head.test | 2 +- .../v0/basic-options-helper-function.test | 2 +- .../httpclient/v0/basic-options.test | 2 +- .../testfiles/httpclient/v0/basic-patch.test | 2 +- .../v0/basic-post-helper-function.test | 2 +- .../testfiles/httpclient/v0/basic-post.test | 2 +- .../v0/basic-put-helper-function.test | 2 +- .../testfiles/httpclient/v0/basic-put.test | 2 +- .../request-content-type-unknown-charset.test | 2 +- .../v0/request-content-type-unknown-ct.test | 2 +- .../httpclient/v0/request-form-simple.test | 2 +- .../v0/request-query-param-float.test | 2 +- .../v0/request-query-param-int.test | 2 +- .../httpclient/v0/response-cookie.test | 2 +- .../v0/response-header-duplicate.test | 2 +- .../httpclient/v0/response-redirect-300.test | 2 +- .../httpclient/v0/response-redirect-301.test | 2 +- .../httpclient/v0/response-redirect-302.test | 2 +- .../httpclient/v0/response-redirect-303.test | 2 +- .../httpclient/v0/response-redirect-304.test | 2 +- .../httpclient/v0/response-redirect-305.test | 2 +- .../httpclient/v0/response-redirect-306.test | 2 +- .../httpclient/v0/response-redirect-307.test | 2 +- .../httpclient/v0/response-redirect-308.test | 2 +- .../v0/response-redirect-destination.test | 2 +- .../v0/response-redirect-to-file.test | 2 +- ...ponse-redirect-to-same-place-absolute.test | 2 +- .../request-form-with-body-and-charset.test | 2 +- ...request-form-with-body-and-no-charset.test | 2 +- ...st-header-override-content-length-get.test | 2 +- ...ader-override-content-length-post-bad.test | 2 +- ...t-header-override-content-length-post.test | 2 +- .../todo/request-header-override-default.test | 2 +- .../v0/todo/request-header-string.test | 2 +- ...-multipart-form-with-body-and-charset.test | 2 +- .../v0/todo/request-query-param-list.test | 2 +- .../v0/todo/request-query-param-null.test | 2 +- .../request-query-param-string-basic.test | 2 +- .../request-query-param-string-emoji-key.test | 2 +- ...equest-query-param-string-emoji-value.test | 2 +- .../request-query-param-string-empty-key.test | 2 +- ...equest-query-param-string-empty-value.test | 2 +- ...quest-query-param-string-empty-values.test | 2 +- ...st-query-param-string-punctuation-key.test | 2 +- ...-query-param-string-punctuation-value.test | 2 +- ...request-query-param-string-spaces-key.test | 2 +- ...quest-query-param-string-spaces-value.test | 2 +- .../v0/todo/response-body-invalid-string.test | 2 +- .../v0/todo/response-body-unicode.test | 2 +- .../response-content-encoding-brotli.test | 2 +- .../response-content-encoding-deflate.test | 2 +- .../response-content-encoding-gzipped.test | 2 +- .../todo/response-content-type-invalid.test | 2 +- .../v0/todo/response-form-encoded.test | 2 +- .../response-form-with-body-and-charset.test | 2 +- .../response-form-with-body-no-charset.test | 2 +- .../v0/todo/response-header-empty.test | 2 +- .../v0/todo/response-header-int.test | 2 +- .../v0/todo/response-header-lowercase.test | 2 +- .../v0/todo/response-header-object.test | 2 +- .../v0/todo/response-header-string.test | 2 +- ...nse-redirect-conflicting-charset-dest.test | 2 +- ...response-redirect-conflicting-charset.test | 2 +- ...-form-urlencoded-content-type-no-body.test | 2 +- ...orm-urlencoded-content-type-with-body.test | 2 +- ...t-post-with-json-content-type-no-body.test | 2 +- ...post-with-json-content-type-with-body.test | 2 +- ...est-post-with-no-content-type-no-body.test | 2 +- ...t-post-with-no-content-type-with-body.test | 2 +- ...-post-with-plain-content-type-no-body.test | 2 +- ...ost-with-plain-content-type-with-body.test | 2 +- ...-post-with-weird-content-type-no-body.test | 2 +- ...ost-with-weird-content-type-with-body.test | 2 +- ...ct-dest-put-with-content-type-no-body.test | 2 +- ...-dest-put-with-content-type-with-body.test | 2 +- ...sponse-redirect-dest-with-auth-header.test | 2 +- .../response-redirect-dest-with-cookies.test | 2 +- ...ponse-redirect-dest-with-query-params.test | 2 +- ...-form-urlencoded-content-type-no-body.test | 2 +- ...orm-urlencoded-content-type-with-body.test | 2 +- ...t-post-with-json-content-type-no-body.test | 2 +- ...post-with-json-content-type-with-body.test | 2 +- ...ect-post-with-no-content-type-no-body.test | 2 +- ...t-post-with-no-content-type-with-body.test | 2 +- ...-post-with-plain-content-type-no-body.test | 2 +- ...ost-with-plain-content-type-with-body.test | 2 +- ...-post-with-weird-content-type-no-body.test | 2 +- ...ost-with-weird-content-type-with-body.test | 2 +- ...edirect-put-with-content-type-no-body.test | 2 +- ...irect-put-with-content-type-with-body.test | 2 +- .../response-redirect-to-http-absolute.test | 2 +- ...esponse-redirect-to-http-relative-200.test | 2 +- .../response-redirect-with-auth-header.test | 2 +- .../todo/response-redirect-with-cookies.test | 2 +- .../response-redirect-with-query-params.test | 2 +- .../v0/todo/uri-with-auth-emoji-password.test | 2 +- .../v0/todo/uri-with-auth-emoji-username.test | 2 +- .../v0/todo/uri-with-auth-just-password.test | 2 +- ...ri-with-auth-just-username-with-colon.test | 2 +- .../v0/todo/uri-with-auth-just-username.test | 2 +- .../v0/todo/uri-with-auth-plus-header.test | 2 +- .../httpclient/v0/uri-with-path-basic.test | 2 +- .../httpclient/v0/uri-with-path-dots.test | 2 +- .../httpclient/v0/uri-with-path-fragment.test | 2 +- .../httpclient/v0/uri-with-path-slash.test | 2 +- backend/tests/Tests/HttpServer.Tests.fs | 2 +- packages/darklang/cli/http/serve.dark | 18 ++++---- .../darklang/demo-data/httpserver-test.dark | 6 +-- packages/darklang/discord.dark | 6 +-- .../internal/dark-packages/dark-packages.dark | 38 +++++++-------- .../darklang/llm/internal/http-errors.dark | 20 ++++---- packages/darklang/stdlib/http.dark | 28 +++++------ packages/darklang/stdlib/httpclient.dark | 4 +- packages/darklang/stdlib/httpserver.dark | 8 ++-- packages/darklang/wip/ai/openai/chat.dark | 46 +++++++++---------- .../darklang/wip/ai/openai/embeddings.dark | 12 ++--- packages/darklang/wip/ai/openai/models.dark | 22 ++++----- .../darklang/wip/ai/openai/responses.dark | 32 ++++++------- .../push-notification/tools/ntfy.dark | 4 +- .../push-notification/tools/pushover.dark | 4 +- packages/stachu/jsoncanvas.dark | 8 ++-- 144 files changed, 285 insertions(+), 281 deletions(-) diff --git a/backend/src/Builtins/Builtins.Http.Client/Libs/HttpClient.fs b/backend/src/Builtins/Builtins.Http.Client/Libs/HttpClient.fs index 725dabff76..d2329019d3 100644 --- a/backend/src/Builtins/Builtins.Http.Client/Libs/HttpClient.fs +++ b/backend/src/Builtins/Builtins.Http.Client/Libs/HttpClient.fs @@ -737,7 +737,7 @@ let fns (config : Configuration) : List = ) let fields = - [ ("statusCode", DInt64(int64 response.statusCode)) + [ ("statusCode", Dval.int (bigint response.statusCode)) ("headers", responseHeaders) ("body", Blob.newEphemeral response.body) ] @@ -894,7 +894,7 @@ let fns (config : Configuration) : List = let typ = streamResponseType () let fields = - [ ("statusCode", DInt64(int64 response.StatusCode)) + [ ("statusCode", Dval.int (bigint (int response.StatusCode))) ("headers", headersDval) ("body", body) ] return DRecord(typ, typ, [], Map fields) |> resultOk diff --git a/backend/src/Builtins/Builtins.Http.Server/Http.fs b/backend/src/Builtins/Builtins.Http.Server/Http.fs index 7925d6ef29..2732603c49 100644 --- a/backend/src/Builtins/Builtins.Http.Server/Http.fs +++ b/backend/src/Builtins/Builtins.Http.Server/Http.fs @@ -57,7 +57,7 @@ module Response = let body = Map.get "body" fields match code, headers, body with - | Some(RT.DInt64 code), Some(RT.DList(_, headers)), Some(RT.DBlob bodyRef) -> + | Some(RT.DInt code), Some(RT.DList(_, headers)), Some(RT.DBlob bodyRef) -> let headers = headers |> List.fold @@ -74,7 +74,7 @@ module Response = | Ok headers -> let! body = Blob.readBytes state bodyRef return - { statusCode = int code + { statusCode = int (RT.DarkInt.toBigInt code) headers = lowercaseHeaderKeys headers body = body } | Error msg -> @@ -106,7 +106,7 @@ module Response = "" "HTTP handlers should return results in the form:" " Darklang.Stdlib.Http.Response {" - " statusCode : Int64" + " statusCode : Int" " headers : List" " body : Blob" " }" ] diff --git a/backend/src/Builtins/Builtins.Http.Server/Libs/HttpServer.fs b/backend/src/Builtins/Builtins.Http.Server/Libs/HttpServer.fs index de61a3c4d6..459f162f0c 100644 --- a/backend/src/Builtins/Builtins.Http.Server/Libs/HttpServer.fs +++ b/backend/src/Builtins/Builtins.Http.Server/Libs/HttpServer.fs @@ -320,7 +320,7 @@ let fns () : List = [ { name = fn "httpServerServe" 0 typeParams = [] parameters = - [ Param.make "port" TInt64 "TCP port to listen on" + [ Param.make "port" TInt "TCP port to listen on" Param.makeWithArgs "handler" // CLEANUP real types @@ -329,7 +329,7 @@ let fns () : List = [ "request" ] Param.make "maxBodyBytes" - TInt64 + TInt "Maximum request body size in bytes (over-limit → 413)" Param.make "injectStandardHeaders" @@ -351,13 +351,17 @@ let fns () : List = | exeState, _, _, - [ DInt64 port + [ DInt portArg DApplicable handler - DInt64 maxBodyBytes + DInt maxBodyBytesArg DBool injectStandardHeaders DBool canonicalizeFromForwardedProto DBool logRequests ] -> uply { + // port/maxBodyBytes are the arbitrary-precision Int; the listener + // plumbing below uses int64. + let port = int64 (DarkInt.toBigInt portArg) + let maxBodyBytes = int64 (DarkInt.toBigInt maxBodyBytesArg) use _serveSpan = Telemetry.span "httpserver.serve" [ "port", string port ] diff --git a/backend/testfiles/execution/stdlib/http.dark b/backend/testfiles/execution/stdlib/http.dark index 91cd8e2886..8cfaa3d445 100644 --- a/backend/testfiles/execution/stdlib/http.dark +++ b/backend/testfiles/execution/stdlib/http.dark @@ -20,63 +20,63 @@ Stdlib.Http.badRequest_v0 "Your request resulted in an error" = Stdlib.Http.Response - { statusCode = 400L + { statusCode = 400I headers = [] body = Stdlib.String.toBlob "Your request resulted in an error" } -Stdlib.Http.response (Stdlib.String.toBlob "test") 200L = +Stdlib.Http.response (Stdlib.String.toBlob "test") 200I = Stdlib.Http.Response - { statusCode = 200L + { statusCode = 200I headers = [] body = Stdlib.String.toBlob "test" } Stdlib.Http.responseWithHeaders (Stdlib.String.toBlob "test") [ ("Content-Type", "text/html; charset=utf-8") ] - 200L = + 200I = Stdlib.Http.Response - { statusCode = 200L + { statusCode = 200I headers = [ ("Content-Type", "text/html; charset=utf-8") ] body = Stdlib.String.toBlob "test" } -Stdlib.Http.notFound () = Stdlib.Http.response Stdlib.Blob.empty 404L +Stdlib.Http.notFound () = Stdlib.Http.response Stdlib.Blob.empty 404I -Stdlib.Http.unauthorized () = Stdlib.Http.response Stdlib.Blob.empty 401L +Stdlib.Http.unauthorized () = Stdlib.Http.response Stdlib.Blob.empty 401I -Stdlib.Http.forbidden () = Stdlib.Http.response Stdlib.Blob.empty 403L +Stdlib.Http.forbidden () = Stdlib.Http.response Stdlib.Blob.empty 403I Stdlib.Http.success (Stdlib.String.toBlob "test") = - Stdlib.Http.response (Stdlib.String.toBlob "test") 200L + Stdlib.Http.response (Stdlib.String.toBlob "test") 200I -Stdlib.Http.responseWithHtml "test" 200L = +Stdlib.Http.responseWithHtml "test" 200I = Stdlib.Http.responseWithHeaders (Stdlib.String.toBlob "test") [ ("Content-Type", "text/html; charset=utf-8") ] - 200L + 200I -Stdlib.Http.responseWithText "test" 200L = +Stdlib.Http.responseWithText "test" 200I = Stdlib.Http.responseWithHeaders (Stdlib.String.toBlob "test") [ ("Content-Type", "text/plain; charset=utf-8") ] - 200L + 200I -Stdlib.Http.responseWithJson "test" 200L = +Stdlib.Http.responseWithJson "test" 200I = (Stdlib.Http.responseWithHeaders (Stdlib.String.toBlob "test") [ ("Content-Type", "application/json") ] - 200L) + 200I) (Stdlib.Http.redirectTo "") = - Stdlib.Http.responseWithHeaders Stdlib.Blob.empty [ ("Location", "") ] 302L + Stdlib.Http.responseWithHeaders Stdlib.Blob.empty [ ("Location", "") ] 302I (Stdlib.Http.redirectTo "bad url") = - Stdlib.Http.responseWithHeaders Stdlib.Blob.empty [ ("Location", "bad url") ] 302L + Stdlib.Http.responseWithHeaders Stdlib.Blob.empty [ ("Location", "bad url") ] 302I (Stdlib.Http.redirectTo_v0 "http://someothersite.com") = - Stdlib.Http.responseWithHeaders Stdlib.Blob.empty [ ("Location", "http://someothersite.com") ] 302L + Stdlib.Http.responseWithHeaders Stdlib.Blob.empty [ ("Location", "http://someothersite.com") ] 302I (Stdlib.Http.redirectTo_v0 "/relativeUrl") = - Stdlib.Http.responseWithHeaders Stdlib.Blob.empty [ ("Location", "/relativeUrl") ] 302L + Stdlib.Http.responseWithHeaders Stdlib.Blob.empty [ ("Location", "/relativeUrl") ] 302I // parseQueryString: ports the old _middleware.dark fixture. diff --git a/backend/testfiles/http-server/_simple-request-headers.test b/backend/testfiles/http-server/_simple-request-headers.test index ffc9678342..8cf7ad5226 100644 --- a/backend/testfiles/http-server/_simple-request-headers.test +++ b/backend/testfiles/http-server/_simple-request-headers.test @@ -5,7 +5,7 @@ let body = |> Darklang.Stdlib.List.map (fun (k,v) -> "(\"" ++ k ++ "\", \"" ++ v ++ "\")") |> Darklang.Stdlib.String.join ",\n" |> Darklang.Stdlib.String.toBlob -Darklang.Stdlib.Http.response body 200L) +Darklang.Stdlib.Http.response body 200) [request] GET / HTTP/1.1 diff --git a/backend/testfiles/http-server/bad-response-just-int.test b/backend/testfiles/http-server/bad-response-just-int.test index 491df0cc44..85c48bf57f 100644 --- a/backend/testfiles/http-server/bad-response-just-int.test +++ b/backend/testfiles/http-server/bad-response-just-int.test @@ -23,7 +23,7 @@ type Int: HTTP handlers should return results in the form: Darklang.Stdlib.Http.Response { - statusCode : Int64 + statusCode : Int headers : List body : Blob } \ No newline at end of file diff --git a/backend/testfiles/http-server/injected-icon-post-length.test b/backend/testfiles/http-server/injected-icon-post-length.test index d98e6584e5..8191fb9df7 100644 --- a/backend/testfiles/http-server/injected-icon-post-length.test +++ b/backend/testfiles/http-server/injected-icon-post-length.test @@ -1,6 +1,6 @@ [http-handler POST /] (let body = (request.body |> Darklang.Stdlib.Blob.length |> Darklang.Stdlib.Int.toString |> Darklang.Stdlib.String.toBlob) -Darklang.Stdlib.Http.response body 200L) +Darklang.Stdlib.Http.response body 200) [request] POST / HTTP/1.1 diff --git a/backend/testfiles/http-server/injected-icon-post-roundtrip.test b/backend/testfiles/http-server/injected-icon-post-roundtrip.test index adaac0aad8..1305cdd912 100644 --- a/backend/testfiles/http-server/injected-icon-post-roundtrip.test +++ b/backend/testfiles/http-server/injected-icon-post-roundtrip.test @@ -1,5 +1,5 @@ [http-handler POST /] -Darklang.Stdlib.Http.response request.body 200L +Darklang.Stdlib.Http.response request.body 200 [request] POST / HTTP/1.1 diff --git a/backend/testfiles/http-server/query-string.test b/backend/testfiles/http-server/query-string.test index 5dba6155d7..ec1a56efd9 100644 --- a/backend/testfiles/http-server/query-string.test +++ b/backend/testfiles/http-server/query-string.test @@ -1,5 +1,5 @@ [http-handler GET /] -Darklang.Stdlib.Http.response (request.url |> Darklang.Stdlib.String.toBlob) 200L +Darklang.Stdlib.Http.response (request.url |> Darklang.Stdlib.String.toBlob) 200 [request] GET /?key=value HTTP/1.1 diff --git a/backend/testfiles/http-server/response-with-500.test b/backend/testfiles/http-server/response-with-500.test index 852a00d9d1..ee77b7de98 100644 --- a/backend/testfiles/http-server/response-with-500.test +++ b/backend/testfiles/http-server/response-with-500.test @@ -1,6 +1,6 @@ [http-handler POST /] (let body = (request.body |> Darklang.Stdlib.Blob.length |> Darklang.Stdlib.Int.toString |> Darklang.Stdlib.String.toBlob) -Darklang.Stdlib.Http.response body 500L) +Darklang.Stdlib.Http.response body 500) [request] POST / HTTP/1.1 diff --git a/backend/testfiles/http-server/simple-injected-string-post.test b/backend/testfiles/http-server/simple-injected-string-post.test index 6960ab67f4..7e675fe131 100644 --- a/backend/testfiles/http-server/simple-injected-string-post.test +++ b/backend/testfiles/http-server/simple-injected-string-post.test @@ -1,6 +1,6 @@ [http-handler POST /] (let body = (request.body |> Darklang.Stdlib.Blob.length |> Darklang.Stdlib.Int.toString |> Darklang.Stdlib.String.toBlob) -Darklang.Stdlib.Http.response body 200L) +Darklang.Stdlib.Http.response body 200) [request] POST / HTTP/1.1 diff --git a/backend/testfiles/http-server/simple-inline-string-post.test b/backend/testfiles/http-server/simple-inline-string-post.test index cd73ce0239..0387ed793b 100644 --- a/backend/testfiles/http-server/simple-inline-string-post.test +++ b/backend/testfiles/http-server/simple-inline-string-post.test @@ -1,6 +1,6 @@ [http-handler POST /] (let body = (request.body |> Darklang.Stdlib.Blob.length |> Darklang.Stdlib.Int.toString |> Darklang.Stdlib.String.toBlob) - Darklang.Stdlib.Http.response body 200L) + Darklang.Stdlib.Http.response body 200) [request] POST / HTTP/1.1 diff --git a/backend/testfiles/http-server/simple-response-headers.test b/backend/testfiles/http-server/simple-response-headers.test index cb63ce618c..93f317637c 100644 --- a/backend/testfiles/http-server/simple-response-headers.test +++ b/backend/testfiles/http-server/simple-response-headers.test @@ -1,7 +1,7 @@ [http-handler GET /] (let body = (Darklang.Stdlib.String.toBlob "1") let headers = [("header1", "value1"); ("Header2", "Value2"); ("Header-3", "Value-3")] - Darklang.Stdlib.Http.responseWithHeaders body headers 200L) + Darklang.Stdlib.Http.responseWithHeaders body headers 200) [request] GET / HTTP/1.1 diff --git a/backend/testfiles/http-server/url-http.test b/backend/testfiles/http-server/url-http.test index 9999d298ef..fa88f06843 100644 --- a/backend/testfiles/http-server/url-http.test +++ b/backend/testfiles/http-server/url-http.test @@ -1,5 +1,5 @@ [http-handler GET /a] -Darklang.Stdlib.Http.response (Darklang.Stdlib.String.toBlob request.url) 200L +Darklang.Stdlib.Http.response (Darklang.Stdlib.String.toBlob request.url) 200 [request] GET /a HTTP/1.1 diff --git a/backend/testfiles/http-server/url-https.test b/backend/testfiles/http-server/url-https.test index f4beadfe48..2207f5c432 100644 --- a/backend/testfiles/http-server/url-https.test +++ b/backend/testfiles/http-server/url-https.test @@ -1,5 +1,5 @@ [http-handler GET /a] -Darklang.Stdlib.Http.response (Darklang.Stdlib.String.toBlob request.url) 200L +Darklang.Stdlib.Http.response (Darklang.Stdlib.String.toBlob request.url) 200 [request] GET /a HTTP/1.1 diff --git a/backend/testfiles/httpclient/v0/_request-content-type-empty.test b/backend/testfiles/httpclient/v0/_request-content-type-empty.test index d9319f79d4..da9f3e0caa 100644 --- a/backend/testfiles/httpclient/v0/_request-content-type-empty.test +++ b/backend/testfiles/httpclient/v0/_request-content-type-empty.test @@ -18,7 +18,7 @@ Hello back {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response { - statusCode = 200L + statusCode = 200 headers = [ ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/_uri-with-auth-both.test b/backend/testfiles/httpclient/v0/_uri-with-auth-both.test index d2fa445be9..4e7a669185 100644 --- a/backend/testfiles/httpclient/v0/_uri-with-auth-both.test +++ b/backend/testfiles/httpclient/v0/_uri-with-auth-both.test @@ -18,7 +18,7 @@ Hello back let respHeaders = response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date") {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 200L + { statusCode = 200 headers = [ ("server", "kestrel") diff --git a/backend/testfiles/httpclient/v0/basic-delete-helper-function.test b/backend/testfiles/httpclient/v0/basic-delete-helper-function.test index 8d081f3d6d..5728bcc951 100644 --- a/backend/testfiles/httpclient/v0/basic-delete-helper-function.test +++ b/backend/testfiles/httpclient/v0/basic-delete-helper-function.test @@ -16,7 +16,7 @@ Hello back let respHeaders = (response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date")) {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 200L + { statusCode = 200 headers = [ ("server", "kestrel") ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/basic-delete.test b/backend/testfiles/httpclient/v0/basic-delete.test index d297438497..4119ccaa5b 100644 --- a/backend/testfiles/httpclient/v0/basic-delete.test +++ b/backend/testfiles/httpclient/v0/basic-delete.test @@ -16,7 +16,7 @@ Hello back let respHeaders = (response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date")) {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 200L + { statusCode = 200 headers = [ ("server", "kestrel") ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/basic-get-helper-function.test b/backend/testfiles/httpclient/v0/basic-get-helper-function.test index 4f4066b799..de1135d80a 100644 --- a/backend/testfiles/httpclient/v0/basic-get-helper-function.test +++ b/backend/testfiles/httpclient/v0/basic-get-helper-function.test @@ -16,7 +16,7 @@ Hello back let respHeaders = (response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date")) { response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 200L + { statusCode = 200 headers = [ ("server", "kestrel") ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/basic-get.test b/backend/testfiles/httpclient/v0/basic-get.test index f32520f562..166d5959ab 100644 --- a/backend/testfiles/httpclient/v0/basic-get.test +++ b/backend/testfiles/httpclient/v0/basic-get.test @@ -16,7 +16,7 @@ Hello back let respHeaders = (response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date")) {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 200L + { statusCode = 200 headers = [ ("server", "kestrel") ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/basic-head-returns-body-helper-function.test b/backend/testfiles/httpclient/v0/basic-head-returns-body-helper-function.test index b43634d7ef..6c2434c863 100644 --- a/backend/testfiles/httpclient/v0/basic-head-returns-body-helper-function.test +++ b/backend/testfiles/httpclient/v0/basic-head-returns-body-helper-function.test @@ -19,7 +19,7 @@ Here's a body! let respHeaders = (response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date")) {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 200L + { statusCode = 200 headers = [ ("server", "kestrel") ("content-length", "15") diff --git a/backend/testfiles/httpclient/v0/basic-head-returns-body.test b/backend/testfiles/httpclient/v0/basic-head-returns-body.test index 5c596ad697..1dc4463c0d 100644 --- a/backend/testfiles/httpclient/v0/basic-head-returns-body.test +++ b/backend/testfiles/httpclient/v0/basic-head-returns-body.test @@ -19,7 +19,7 @@ Here's a body! let respHeaders = (response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date")) {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 200L + { statusCode = 200 headers = [ ("server", "kestrel") ("content-length", "15") diff --git a/backend/testfiles/httpclient/v0/basic-head.test b/backend/testfiles/httpclient/v0/basic-head.test index 945d70fed4..2fe8e8f9d1 100644 --- a/backend/testfiles/httpclient/v0/basic-head.test +++ b/backend/testfiles/httpclient/v0/basic-head.test @@ -15,7 +15,7 @@ Content-Length: 568 let respHeaders = (response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date")) {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 200L + { statusCode = 200 headers = [ ("server", "kestrel") ("content-length", "568") diff --git a/backend/testfiles/httpclient/v0/basic-options-helper-function.test b/backend/testfiles/httpclient/v0/basic-options-helper-function.test index 73cf968878..6ec3c9a1f2 100644 --- a/backend/testfiles/httpclient/v0/basic-options-helper-function.test +++ b/backend/testfiles/httpclient/v0/basic-options-helper-function.test @@ -16,7 +16,7 @@ Hello back let respHeaders = (response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date")) {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 200L + { statusCode = 200 headers = [ ("server", "kestrel") ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/basic-options.test b/backend/testfiles/httpclient/v0/basic-options.test index b7b18d07c9..991ed940a6 100644 --- a/backend/testfiles/httpclient/v0/basic-options.test +++ b/backend/testfiles/httpclient/v0/basic-options.test @@ -16,7 +16,7 @@ Hello back let respHeaders = (response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date")) {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 200L + { statusCode = 200 headers = [ ("server", "kestrel") ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/basic-patch.test b/backend/testfiles/httpclient/v0/basic-patch.test index 65ca3d6691..e174c247bf 100644 --- a/backend/testfiles/httpclient/v0/basic-patch.test +++ b/backend/testfiles/httpclient/v0/basic-patch.test @@ -18,7 +18,7 @@ Hello back let respHeaders = (response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date")) {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 200L + { statusCode = 200 headers = [ ("server", "kestrel") ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/basic-post-helper-function.test b/backend/testfiles/httpclient/v0/basic-post-helper-function.test index 35923f1f88..7f1e945cfd 100644 --- a/backend/testfiles/httpclient/v0/basic-post-helper-function.test +++ b/backend/testfiles/httpclient/v0/basic-post-helper-function.test @@ -17,7 +17,7 @@ Hello back let respHeaders = (response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date")) {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 200L + { statusCode = 200 headers = [ ("server", "kestrel") ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/basic-post.test b/backend/testfiles/httpclient/v0/basic-post.test index 3b96a100ee..3d243c40fd 100644 --- a/backend/testfiles/httpclient/v0/basic-post.test +++ b/backend/testfiles/httpclient/v0/basic-post.test @@ -17,7 +17,7 @@ Hello back let respHeaders = (response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date")) {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 200L + { statusCode = 200 headers = [ ("server", "kestrel") ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/basic-put-helper-function.test b/backend/testfiles/httpclient/v0/basic-put-helper-function.test index 836f33d00e..3e6023092f 100644 --- a/backend/testfiles/httpclient/v0/basic-put-helper-function.test +++ b/backend/testfiles/httpclient/v0/basic-put-helper-function.test @@ -19,7 +19,7 @@ Hello back let respHeaders = (response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date")) {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 200L + { statusCode = 200 headers = [ ("server", "kestrel") ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/basic-put.test b/backend/testfiles/httpclient/v0/basic-put.test index 65589490af..21f0ae6017 100644 --- a/backend/testfiles/httpclient/v0/basic-put.test +++ b/backend/testfiles/httpclient/v0/basic-put.test @@ -19,7 +19,7 @@ Hello back let respHeaders = (response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date")) {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 200L + { statusCode = 200 headers = [ ("server", "kestrel") ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/request-content-type-unknown-charset.test b/backend/testfiles/httpclient/v0/request-content-type-unknown-charset.test index 86c4766b46..9bb191e2df 100644 --- a/backend/testfiles/httpclient/v0/request-content-type-unknown-charset.test +++ b/backend/testfiles/httpclient/v0/request-content-type-unknown-charset.test @@ -19,7 +19,7 @@ Hello back let respHeaders = (response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date")) {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 200L + { statusCode = 200 headers = [ ("server", "kestrel") diff --git a/backend/testfiles/httpclient/v0/request-content-type-unknown-ct.test b/backend/testfiles/httpclient/v0/request-content-type-unknown-ct.test index adfcbd2126..7d224b3ec0 100644 --- a/backend/testfiles/httpclient/v0/request-content-type-unknown-ct.test +++ b/backend/testfiles/httpclient/v0/request-content-type-unknown-ct.test @@ -19,7 +19,7 @@ Hello back let respHeaders = (response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date")) {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 200L + { statusCode = 200 headers = [ ("server", "kestrel") diff --git a/backend/testfiles/httpclient/v0/request-form-simple.test b/backend/testfiles/httpclient/v0/request-form-simple.test index daa040981c..dee90e7099 100644 --- a/backend/testfiles/httpclient/v0/request-form-simple.test +++ b/backend/testfiles/httpclient/v0/request-form-simple.test @@ -17,7 +17,7 @@ Content-Length: 0 let respHeaders = (response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date")) {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 200L + { statusCode = 200 headers = [ ("server", "kestrel") diff --git a/backend/testfiles/httpclient/v0/request-query-param-float.test b/backend/testfiles/httpclient/v0/request-query-param-float.test index a389fa4e61..e994d36323 100644 --- a/backend/testfiles/httpclient/v0/request-query-param-float.test +++ b/backend/testfiles/httpclient/v0/request-query-param-float.test @@ -16,7 +16,7 @@ Content-Length: LENGTH let respHeaders = (response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date")) {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 200L + { statusCode = 200 headers = [ ("server", "kestrel") diff --git a/backend/testfiles/httpclient/v0/request-query-param-int.test b/backend/testfiles/httpclient/v0/request-query-param-int.test index 8e4128aa64..133b3c783a 100644 --- a/backend/testfiles/httpclient/v0/request-query-param-int.test +++ b/backend/testfiles/httpclient/v0/request-query-param-int.test @@ -17,7 +17,7 @@ Hello back let respHeaders = (response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date")) {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 200L + { statusCode = 200 headers = [ ("server", "kestrel") diff --git a/backend/testfiles/httpclient/v0/response-cookie.test b/backend/testfiles/httpclient/v0/response-cookie.test index 99a2b88591..e38150d7d2 100644 --- a/backend/testfiles/httpclient/v0/response-cookie.test +++ b/backend/testfiles/httpclient/v0/response-cookie.test @@ -20,7 +20,7 @@ Hello back let respHeaders = response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date") {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 200L + { statusCode = 200 headers = [ ("server", "kestrel") diff --git a/backend/testfiles/httpclient/v0/response-header-duplicate.test b/backend/testfiles/httpclient/v0/response-header-duplicate.test index ea7b465378..27235357e1 100644 --- a/backend/testfiles/httpclient/v0/response-header-duplicate.test +++ b/backend/testfiles/httpclient/v0/response-header-duplicate.test @@ -18,7 +18,7 @@ Hello back let respHeaders = (response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date")) {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 200L + { statusCode = 200 headers = [ ("server", "kestrel") diff --git a/backend/testfiles/httpclient/v0/response-redirect-300.test b/backend/testfiles/httpclient/v0/response-redirect-300.test index b2c07203d8..ab1bb9d25d 100644 --- a/backend/testfiles/httpclient/v0/response-redirect-300.test +++ b/backend/testfiles/httpclient/v0/response-redirect-300.test @@ -14,7 +14,7 @@ Location: /v0/response-redirect-destination let respHeaders = (response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date")) {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 300L + { statusCode = 300 headers = [ ("server", "kestrel") diff --git a/backend/testfiles/httpclient/v0/response-redirect-301.test b/backend/testfiles/httpclient/v0/response-redirect-301.test index 3004dca9af..fb54ba53c5 100644 --- a/backend/testfiles/httpclient/v0/response-redirect-301.test +++ b/backend/testfiles/httpclient/v0/response-redirect-301.test @@ -14,7 +14,7 @@ Location: /v0/response-redirect-destination let respHeaders = (response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date")) {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 301L + { statusCode = 301 headers = [ ("server", "kestrel") diff --git a/backend/testfiles/httpclient/v0/response-redirect-302.test b/backend/testfiles/httpclient/v0/response-redirect-302.test index 334b1d595c..7e98b7650a 100644 --- a/backend/testfiles/httpclient/v0/response-redirect-302.test +++ b/backend/testfiles/httpclient/v0/response-redirect-302.test @@ -14,7 +14,7 @@ Location: /v0/response-redirect-destination let respHeaders = (response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date")) {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 302L + { statusCode = 302 headers = [ ("server", "kestrel") diff --git a/backend/testfiles/httpclient/v0/response-redirect-303.test b/backend/testfiles/httpclient/v0/response-redirect-303.test index 8857a6a143..68731f7fef 100644 --- a/backend/testfiles/httpclient/v0/response-redirect-303.test +++ b/backend/testfiles/httpclient/v0/response-redirect-303.test @@ -14,7 +14,7 @@ Location: /v0/response-redirect-destination let respHeaders = (response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date")) {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 303L + { statusCode = 303 headers = [ ("server", "kestrel") diff --git a/backend/testfiles/httpclient/v0/response-redirect-304.test b/backend/testfiles/httpclient/v0/response-redirect-304.test index 2799f8ce06..47ec9f75d5 100644 --- a/backend/testfiles/httpclient/v0/response-redirect-304.test +++ b/backend/testfiles/httpclient/v0/response-redirect-304.test @@ -14,7 +14,7 @@ Location: /v0/response-redirect-destination let respHeaders = response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date") {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 304L + { statusCode = 304 headers = [ ("server", "kestrel") diff --git a/backend/testfiles/httpclient/v0/response-redirect-305.test b/backend/testfiles/httpclient/v0/response-redirect-305.test index 625d28db5f..a321e2e32f 100644 --- a/backend/testfiles/httpclient/v0/response-redirect-305.test +++ b/backend/testfiles/httpclient/v0/response-redirect-305.test @@ -14,7 +14,7 @@ Location: /v0/response-redirect-destination let respHeaders = (response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date")) {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 305L + { statusCode = 305 headers = [ ("server", "kestrel") diff --git a/backend/testfiles/httpclient/v0/response-redirect-306.test b/backend/testfiles/httpclient/v0/response-redirect-306.test index f733afbf81..45c6682de8 100644 --- a/backend/testfiles/httpclient/v0/response-redirect-306.test +++ b/backend/testfiles/httpclient/v0/response-redirect-306.test @@ -14,7 +14,7 @@ Location: /v0/response-redirect-destination let respHeaders = (response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date")) {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 306L + { statusCode = 306 headers = [ ("server", "kestrel") diff --git a/backend/testfiles/httpclient/v0/response-redirect-307.test b/backend/testfiles/httpclient/v0/response-redirect-307.test index 7715b6dc9b..398f89e208 100644 --- a/backend/testfiles/httpclient/v0/response-redirect-307.test +++ b/backend/testfiles/httpclient/v0/response-redirect-307.test @@ -14,7 +14,7 @@ Location: /v0/response-redirect-destination let respHeaders = (response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date")) {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 307L + { statusCode = 307 headers = [ ("server", "kestrel") diff --git a/backend/testfiles/httpclient/v0/response-redirect-308.test b/backend/testfiles/httpclient/v0/response-redirect-308.test index 42abb93258..790616a186 100644 --- a/backend/testfiles/httpclient/v0/response-redirect-308.test +++ b/backend/testfiles/httpclient/v0/response-redirect-308.test @@ -14,7 +14,7 @@ Location: /v0/response-redirect-destination let respHeaders = (response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date")) {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 308L + { statusCode = 308 headers = [ ("server", "kestrel") diff --git a/backend/testfiles/httpclient/v0/response-redirect-destination.test b/backend/testfiles/httpclient/v0/response-redirect-destination.test index 615aa70ec8..3a9d1f28ec 100644 --- a/backend/testfiles/httpclient/v0/response-redirect-destination.test +++ b/backend/testfiles/httpclient/v0/response-redirect-destination.test @@ -18,7 +18,7 @@ Redirect destination reached let respHeaders = response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date") {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 200L + { statusCode = 200 headers = [ ("server", "kestrel") diff --git a/backend/testfiles/httpclient/v0/response-redirect-to-file.test b/backend/testfiles/httpclient/v0/response-redirect-to-file.test index 1055fab2c6..4a19acaae8 100644 --- a/backend/testfiles/httpclient/v0/response-redirect-to-file.test +++ b/backend/testfiles/httpclient/v0/response-redirect-to-file.test @@ -14,7 +14,7 @@ Location: file:////etc/passwd let respHeaders = (response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date")) {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 301L + { statusCode = 301 headers = [ ("server", "kestrel") diff --git a/backend/testfiles/httpclient/v0/response-redirect-to-same-place-absolute.test b/backend/testfiles/httpclient/v0/response-redirect-to-same-place-absolute.test index 963d157dce..b861ae4c1b 100644 --- a/backend/testfiles/httpclient/v0/response-redirect-to-same-place-absolute.test +++ b/backend/testfiles/httpclient/v0/response-redirect-to-same-place-absolute.test @@ -14,7 +14,7 @@ Location: http://URL let respHeaders = response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date") {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 302L + { statusCode = 302 headers = [ ("server", "kestrel") diff --git a/backend/testfiles/httpclient/v0/todo/request-form-with-body-and-charset.test b/backend/testfiles/httpclient/v0/todo/request-form-with-body-and-charset.test index 351296261e..3046c62578 100644 --- a/backend/testfiles/httpclient/v0/todo/request-form-with-body-and-charset.test +++ b/backend/testfiles/httpclient/v0/todo/request-form-with-body-and-charset.test @@ -24,7 +24,7 @@ Content-Length: LENGTH {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "" - statusCode = 200L + statusCode = 200 headers = [ ("content-type", "text/plain; charset=utf-8") diff --git a/backend/testfiles/httpclient/v0/todo/request-form-with-body-and-no-charset.test b/backend/testfiles/httpclient/v0/todo/request-form-with-body-and-no-charset.test index d305d34a1a..6a17bd1383 100644 --- a/backend/testfiles/httpclient/v0/todo/request-form-with-body-and-no-charset.test +++ b/backend/testfiles/httpclient/v0/todo/request-form-with-body-and-no-charset.test @@ -21,7 +21,7 @@ var1=2&var2=[] {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "var1=2&var2=[]" - statusCode = 200L + statusCode = 200 headers = [ ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/todo/request-header-override-content-length-get.test b/backend/testfiles/httpclient/v0/todo/request-header-override-content-length-get.test index 9e76157cfd..e7240bc19f 100644 --- a/backend/testfiles/httpclient/v0/todo/request-header-override-content-length-get.test +++ b/backend/testfiles/httpclient/v0/todo/request-header-override-content-length-get.test @@ -20,7 +20,7 @@ Content-Length: LENGTH {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "\"Hello back\"" - statusCode = 200L + statusCode = 200 headers = [ ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/todo/request-header-override-content-length-post-bad.test b/backend/testfiles/httpclient/v0/todo/request-header-override-content-length-post-bad.test index 2decd2dd9e..356bfc307f 100644 --- a/backend/testfiles/httpclient/v0/todo/request-header-override-content-length-post-bad.test +++ b/backend/testfiles/httpclient/v0/todo/request-header-override-content-length-post-bad.test @@ -21,7 +21,7 @@ Content-Length: LENGTH {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "\"Hello back\"" - statusCode = 200L + statusCode = 200 headers = [ ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/todo/request-header-override-content-length-post.test b/backend/testfiles/httpclient/v0/todo/request-header-override-content-length-post.test index 2decd2dd9e..356bfc307f 100644 --- a/backend/testfiles/httpclient/v0/todo/request-header-override-content-length-post.test +++ b/backend/testfiles/httpclient/v0/todo/request-header-override-content-length-post.test @@ -21,7 +21,7 @@ Content-Length: LENGTH {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "\"Hello back\"" - statusCode = 200L + statusCode = 200 headers = [ ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/todo/request-header-override-default.test b/backend/testfiles/httpclient/v0/todo/request-header-override-default.test index 73ac69ed7d..d8ebac0363 100644 --- a/backend/testfiles/httpclient/v0/todo/request-header-override-default.test +++ b/backend/testfiles/httpclient/v0/todo/request-header-override-default.test @@ -20,7 +20,7 @@ Content-Length: LENGTH {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "\"Hello back\"" - statusCode = 200L + statusCode = 200 headers = [ ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/todo/request-header-string.test b/backend/testfiles/httpclient/v0/todo/request-header-string.test index 9de28b174a..1c4198a6f7 100644 --- a/backend/testfiles/httpclient/v0/todo/request-header-string.test +++ b/backend/testfiles/httpclient/v0/todo/request-header-string.test @@ -21,7 +21,7 @@ Content-Length: LENGTH {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "\"Hello back\"" - statusCode = 200L + statusCode = 200 headers = [ ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/todo/request-multipart-form-with-body-and-charset.test b/backend/testfiles/httpclient/v0/todo/request-multipart-form-with-body-and-charset.test index aab985a37c..88ea500240 100644 --- a/backend/testfiles/httpclient/v0/todo/request-multipart-form-with-body-and-charset.test +++ b/backend/testfiles/httpclient/v0/todo/request-multipart-form-with-body-and-charset.test @@ -20,7 +20,7 @@ Content-Length: LENGTH {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "" - statusCode = 200L + statusCode = 200 headers = [ ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/todo/request-query-param-list.test b/backend/testfiles/httpclient/v0/todo/request-query-param-list.test index cacb8edd6d..6a68908d71 100644 --- a/backend/testfiles/httpclient/v0/todo/request-query-param-list.test +++ b/backend/testfiles/httpclient/v0/todo/request-query-param-list.test @@ -20,7 +20,7 @@ Content-Length: LENGTH {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "\"Hello back\"" - statusCode = 200L + statusCode = 200 headers = [ ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/todo/request-query-param-null.test b/backend/testfiles/httpclient/v0/todo/request-query-param-null.test index b0022c54ef..9f993851bb 100644 --- a/backend/testfiles/httpclient/v0/todo/request-query-param-null.test +++ b/backend/testfiles/httpclient/v0/todo/request-query-param-null.test @@ -19,7 +19,7 @@ Content-Length: LENGTH {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "\"Hello back\"" - statusCode = 200L + statusCode = 200 headers = [ ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/todo/request-query-param-string-basic.test b/backend/testfiles/httpclient/v0/todo/request-query-param-string-basic.test index 46ab4e5e23..8afcf5b04c 100644 --- a/backend/testfiles/httpclient/v0/todo/request-query-param-string-basic.test +++ b/backend/testfiles/httpclient/v0/todo/request-query-param-string-basic.test @@ -21,7 +21,7 @@ Content-Length: LENGTH {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "\"Hello back\"" - statusCode = 200L + statusCode = 200 headers = [ ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/todo/request-query-param-string-emoji-key.test b/backend/testfiles/httpclient/v0/todo/request-query-param-string-emoji-key.test index 41a6a3aed4..3dc9197aa1 100644 --- a/backend/testfiles/httpclient/v0/todo/request-query-param-string-emoji-key.test +++ b/backend/testfiles/httpclient/v0/todo/request-query-param-string-emoji-key.test @@ -21,7 +21,7 @@ Content-Length: LENGTH {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "\"Hello back\"" - statusCode = 200L + statusCode = 200 headers = [ ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/todo/request-query-param-string-emoji-value.test b/backend/testfiles/httpclient/v0/todo/request-query-param-string-emoji-value.test index 67e1b9671e..8aeccc00e8 100644 --- a/backend/testfiles/httpclient/v0/todo/request-query-param-string-emoji-value.test +++ b/backend/testfiles/httpclient/v0/todo/request-query-param-string-emoji-value.test @@ -22,7 +22,7 @@ Content-Length: LENGTH {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "\"Hello back\"" - statusCode = 200L + statusCode = 200 headers = [ ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/todo/request-query-param-string-empty-key.test b/backend/testfiles/httpclient/v0/todo/request-query-param-string-empty-key.test index 0a24207516..d5fef41d40 100644 --- a/backend/testfiles/httpclient/v0/todo/request-query-param-string-empty-key.test +++ b/backend/testfiles/httpclient/v0/todo/request-query-param-string-empty-key.test @@ -21,7 +21,7 @@ Content-Length: LENGTH {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "\"Hello back\"" - statusCode = 200L + statusCode = 200 headers = [ ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/todo/request-query-param-string-empty-value.test b/backend/testfiles/httpclient/v0/todo/request-query-param-string-empty-value.test index 700b86291f..ca21c34ae2 100644 --- a/backend/testfiles/httpclient/v0/todo/request-query-param-string-empty-value.test +++ b/backend/testfiles/httpclient/v0/todo/request-query-param-string-empty-value.test @@ -21,7 +21,7 @@ Content-Length: LENGTH {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "\"Hello back\"" - statusCode = 200L + statusCode = 200 headers = [ ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/todo/request-query-param-string-empty-values.test b/backend/testfiles/httpclient/v0/todo/request-query-param-string-empty-values.test index 9a99b8aa12..cb4a0fec2c 100644 --- a/backend/testfiles/httpclient/v0/todo/request-query-param-string-empty-values.test +++ b/backend/testfiles/httpclient/v0/todo/request-query-param-string-empty-values.test @@ -22,7 +22,7 @@ Content-Length: LENGTH {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "\"Hello back\"" - statusCode = 200L + statusCode = 200 headers = [ ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/todo/request-query-param-string-punctuation-key.test b/backend/testfiles/httpclient/v0/todo/request-query-param-string-punctuation-key.test index c21f3fa0db..1551a67ff0 100644 --- a/backend/testfiles/httpclient/v0/todo/request-query-param-string-punctuation-key.test +++ b/backend/testfiles/httpclient/v0/todo/request-query-param-string-punctuation-key.test @@ -21,7 +21,7 @@ Content-Length: LENGTH {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "\"Hello back\"" - statusCode = 200L + statusCode = 200 headers = [ ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/todo/request-query-param-string-punctuation-value.test b/backend/testfiles/httpclient/v0/todo/request-query-param-string-punctuation-value.test index 0937966017..d3ecac7532 100644 --- a/backend/testfiles/httpclient/v0/todo/request-query-param-string-punctuation-value.test +++ b/backend/testfiles/httpclient/v0/todo/request-query-param-string-punctuation-value.test @@ -21,7 +21,7 @@ Content-Length: LENGTH {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "\"Hello back\"" - statusCode = 200L + statusCode = 200 headers = [ ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/todo/request-query-param-string-spaces-key.test b/backend/testfiles/httpclient/v0/todo/request-query-param-string-spaces-key.test index 86d3a4f1f9..08196dfa29 100644 --- a/backend/testfiles/httpclient/v0/todo/request-query-param-string-spaces-key.test +++ b/backend/testfiles/httpclient/v0/todo/request-query-param-string-spaces-key.test @@ -21,7 +21,7 @@ Content-Length: LENGTH {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "\"Hello back\"" - statusCode = 200L + statusCode = 200 headers = [ ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/todo/request-query-param-string-spaces-value.test b/backend/testfiles/httpclient/v0/todo/request-query-param-string-spaces-value.test index 13ca844aa9..4d43ba4331 100644 --- a/backend/testfiles/httpclient/v0/todo/request-query-param-string-spaces-value.test +++ b/backend/testfiles/httpclient/v0/todo/request-query-param-string-spaces-value.test @@ -21,7 +21,7 @@ Content-Length: LENGTH {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "\"Hello back\"" - statusCode = 200L + statusCode = 200 headers = [ ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/todo/response-body-invalid-string.test b/backend/testfiles/httpclient/v0/todo/response-body-invalid-string.test index 36e6ea7e33..eab3f53855 100644 --- a/backend/testfiles/httpclient/v0/todo/response-body-invalid-string.test +++ b/backend/testfiles/httpclient/v0/todo/response-body-invalid-string.test @@ -19,7 +19,7 @@ RANDOM_BYTES {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "utf-8 decoding error" - statusCode = 200L + statusCode = 200 headers = [ ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/todo/response-body-unicode.test b/backend/testfiles/httpclient/v0/todo/response-body-unicode.test index b808a0da10..b7896a3176 100644 --- a/backend/testfiles/httpclient/v0/todo/response-body-unicode.test +++ b/backend/testfiles/httpclient/v0/todo/response-body-unicode.test @@ -18,7 +18,7 @@ Content-Length: LENGTH {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = """👱👱🏻👱🏼👱🏽👱🏾👱🏿", "👨‍❤️‍💋‍👨", "﷽﷽﷽""" - statusCode = 200L + statusCode = 200 headers = [ ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/todo/response-content-encoding-brotli.test b/backend/testfiles/httpclient/v0/todo/response-content-encoding-brotli.test index ea88854c59..8669bb5f1a 100644 --- a/backend/testfiles/httpclient/v0/todo/response-content-encoding-brotli.test +++ b/backend/testfiles/httpclient/v0/todo/response-content-encoding-brotli.test @@ -20,7 +20,7 @@ Content-Encoding: br {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "\"Hello back\"" - statusCode = 200L + statusCode = 200 headers = [ "Transfer-Encoding" = "chunked" diff --git a/backend/testfiles/httpclient/v0/todo/response-content-encoding-deflate.test b/backend/testfiles/httpclient/v0/todo/response-content-encoding-deflate.test index 0801db662c..8cb4191e55 100644 --- a/backend/testfiles/httpclient/v0/todo/response-content-encoding-deflate.test +++ b/backend/testfiles/httpclient/v0/todo/response-content-encoding-deflate.test @@ -20,7 +20,7 @@ Content-Encoding: deflate {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "\"Hello back\"" - statusCode = 200L + statusCode = 200 headers = [ "Transfer-Encoding" = "chunked" diff --git a/backend/testfiles/httpclient/v0/todo/response-content-encoding-gzipped.test b/backend/testfiles/httpclient/v0/todo/response-content-encoding-gzipped.test index bc92274624..3a8adf7500 100644 --- a/backend/testfiles/httpclient/v0/todo/response-content-encoding-gzipped.test +++ b/backend/testfiles/httpclient/v0/todo/response-content-encoding-gzipped.test @@ -20,7 +20,7 @@ Content-Encoding: gzip {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "\"Hello back\"" - statusCode = 200L + statusCode = 200 headers = [ "Transfer-Encoding" = "chunked" diff --git a/backend/testfiles/httpclient/v0/todo/response-content-type-invalid.test b/backend/testfiles/httpclient/v0/todo/response-content-type-invalid.test index 0b3561dc6e..e38e0325c4 100644 --- a/backend/testfiles/httpclient/v0/todo/response-content-type-invalid.test +++ b/backend/testfiles/httpclient/v0/todo/response-content-type-invalid.test @@ -20,7 +20,7 @@ Content-Length: LENGTH {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "\"Hello back\"" - statusCode = 200L + statusCode = 200 headers = [ ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/todo/response-form-encoded.test b/backend/testfiles/httpclient/v0/todo/response-form-encoded.test index fb9ddd5be6..8b6d2040f2 100644 --- a/backend/testfiles/httpclient/v0/todo/response-form-encoded.test +++ b/backend/testfiles/httpclient/v0/todo/response-form-encoded.test @@ -21,7 +21,7 @@ var1=2&var2=[] {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "var1=2&var2=[]" - statusCode = 200L + statusCode = 200 headers = [ ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/todo/response-form-with-body-and-charset.test b/backend/testfiles/httpclient/v0/todo/response-form-with-body-and-charset.test index fb9ddd5be6..8b6d2040f2 100644 --- a/backend/testfiles/httpclient/v0/todo/response-form-with-body-and-charset.test +++ b/backend/testfiles/httpclient/v0/todo/response-form-with-body-and-charset.test @@ -21,7 +21,7 @@ var1=2&var2=[] {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "var1=2&var2=[]" - statusCode = 200L + statusCode = 200 headers = [ ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/todo/response-form-with-body-no-charset.test b/backend/testfiles/httpclient/v0/todo/response-form-with-body-no-charset.test index f954299608..e86ff458ab 100644 --- a/backend/testfiles/httpclient/v0/todo/response-form-with-body-no-charset.test +++ b/backend/testfiles/httpclient/v0/todo/response-form-with-body-no-charset.test @@ -22,7 +22,7 @@ var1=2&var2=[] {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "var1=2&var2=[]" - statusCode = 200L + statusCode = 200 headers = [ ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/todo/response-header-empty.test b/backend/testfiles/httpclient/v0/todo/response-header-empty.test index 1b9ec6b1cf..60f69928f2 100644 --- a/backend/testfiles/httpclient/v0/todo/response-header-empty.test +++ b/backend/testfiles/httpclient/v0/todo/response-header-empty.test @@ -20,7 +20,7 @@ Some-Header: {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "\"Hello back\"" - statusCode = 200L + statusCode = 200 headers = [ "Some-Header" = "" diff --git a/backend/testfiles/httpclient/v0/todo/response-header-int.test b/backend/testfiles/httpclient/v0/todo/response-header-int.test index c917775e5b..358f48998f 100644 --- a/backend/testfiles/httpclient/v0/todo/response-header-int.test +++ b/backend/testfiles/httpclient/v0/todo/response-header-int.test @@ -20,7 +20,7 @@ Some-Header: 5 {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "\"Hello back\"" - statusCode = 200L + statusCode = 200 headers = [ "Some-Header" = "5" diff --git a/backend/testfiles/httpclient/v0/todo/response-header-lowercase.test b/backend/testfiles/httpclient/v0/todo/response-header-lowercase.test index 0be44cc040..076a84608c 100644 --- a/backend/testfiles/httpclient/v0/todo/response-header-lowercase.test +++ b/backend/testfiles/httpclient/v0/todo/response-header-lowercase.test @@ -22,7 +22,7 @@ OneVVord: MixedCase {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "\"Hello back\"" - statusCode = 200L + statusCode = 200 headers = [ "some-header" = "string" diff --git a/backend/testfiles/httpclient/v0/todo/response-header-object.test b/backend/testfiles/httpclient/v0/todo/response-header-object.test index 436e935361..a7bde4a4c3 100644 --- a/backend/testfiles/httpclient/v0/todo/response-header-object.test +++ b/backend/testfiles/httpclient/v0/todo/response-header-object.test @@ -20,7 +20,7 @@ Some-Header: {} {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "\"Hello back\"" - statusCode = 200L + statusCode = 200 headers = [ "Some-Header" = "{}" diff --git a/backend/testfiles/httpclient/v0/todo/response-header-string.test b/backend/testfiles/httpclient/v0/todo/response-header-string.test index 1d5ab3dce7..d5ed990371 100644 --- a/backend/testfiles/httpclient/v0/todo/response-header-string.test +++ b/backend/testfiles/httpclient/v0/todo/response-header-string.test @@ -20,7 +20,7 @@ Some-Header: string {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "\"Hello back\"" - statusCode = 200L + statusCode = 200 headers = [ "Some-Header" = "string" diff --git a/backend/testfiles/httpclient/v0/todo/response-redirect-conflicting-charset-dest.test b/backend/testfiles/httpclient/v0/todo/response-redirect-conflicting-charset-dest.test index 8df0e3271d..23afc323ad 100644 --- a/backend/testfiles/httpclient/v0/todo/response-redirect-conflicting-charset-dest.test +++ b/backend/testfiles/httpclient/v0/todo/response-redirect-conflicting-charset-dest.test @@ -21,7 +21,7 @@ Redirect destination reached {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "Redirect destination reached" - statusCode = 200L + statusCode = 200 headers = [ "Arbitrary-header" = "Test value" diff --git a/backend/testfiles/httpclient/v0/todo/response-redirect-conflicting-charset.test b/backend/testfiles/httpclient/v0/todo/response-redirect-conflicting-charset.test index 7e9cad082a..be6a8aca89 100644 --- a/backend/testfiles/httpclient/v0/todo/response-redirect-conflicting-charset.test +++ b/backend/testfiles/httpclient/v0/todo/response-redirect-conflicting-charset.test @@ -19,7 +19,7 @@ Date: xxx, xx xxx xxxx xx:xx:xx xxx {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "Redirect destination reached" - statusCode = 200L + statusCode = 200 error = "" headers = [ diff --git a/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-form-urlencoded-content-type-no-body.test b/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-form-urlencoded-content-type-no-body.test index c3abe381db..b4a79c4f1f 100644 --- a/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-form-urlencoded-content-type-no-body.test +++ b/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-form-urlencoded-content-type-no-body.test @@ -22,7 +22,7 @@ Redirect destination reached {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "Redirect destination reached" - statusCode = 200L + statusCode = 200 headers = [ "Arbitrary-header" = "Test value" diff --git a/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-form-urlencoded-content-type-with-body.test b/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-form-urlencoded-content-type-with-body.test index 0765e0c5e0..89b2ce0273 100644 --- a/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-form-urlencoded-content-type-with-body.test +++ b/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-form-urlencoded-content-type-with-body.test @@ -22,7 +22,7 @@ Redirect destination reached {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "Redirect destination reached" - statusCode = 200L + statusCode = 200 headers = [ "Arbitrary-header" = "Test value" diff --git a/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-json-content-type-no-body.test b/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-json-content-type-no-body.test index b0f0024dba..f5dc56e014 100644 --- a/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-json-content-type-no-body.test +++ b/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-json-content-type-no-body.test @@ -22,7 +22,7 @@ Redirect destination reached {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "Redirect destination reached" - statusCode = 200L + statusCode = 200 headers = [ "Arbitrary-header" = "Test value" diff --git a/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-json-content-type-with-body.test b/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-json-content-type-with-body.test index 281ddcbff0..bc907cb66c 100644 --- a/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-json-content-type-with-body.test +++ b/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-json-content-type-with-body.test @@ -22,7 +22,7 @@ Redirect destination reached {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "Redirect destination reached" - statusCode = 200L + statusCode = 200 headers = [ "Arbitrary-header" = "Test value" diff --git a/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-no-content-type-no-body.test b/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-no-content-type-no-body.test index 9d49dde534..a1913e68ac 100644 --- a/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-no-content-type-no-body.test +++ b/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-no-content-type-no-body.test @@ -22,7 +22,7 @@ Redirect destination reached {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "Redirect destination reached" - statusCode = 200L + statusCode = 200 headers = [ "Arbitrary-header" = "Test value" diff --git a/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-no-content-type-with-body.test b/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-no-content-type-with-body.test index 2245a67e83..3aabecc868 100644 --- a/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-no-content-type-with-body.test +++ b/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-no-content-type-with-body.test @@ -22,7 +22,7 @@ Redirect destination reached {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "Redirect destination reached" - statusCode = 200L + statusCode = 200 headers = [ "Arbitrary-header" = "Test value" diff --git a/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-plain-content-type-no-body.test b/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-plain-content-type-no-body.test index b409014ed9..635567fbeb 100644 --- a/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-plain-content-type-no-body.test +++ b/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-plain-content-type-no-body.test @@ -22,7 +22,7 @@ Redirect destination reached {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "Redirect destination reached" - statusCode = 200L + statusCode = 200 headers = [ "Arbitrary-header" = "Test value" diff --git a/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-plain-content-type-with-body.test b/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-plain-content-type-with-body.test index 64ab3a0dd2..f3b0ee5537 100644 --- a/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-plain-content-type-with-body.test +++ b/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-plain-content-type-with-body.test @@ -22,7 +22,7 @@ Redirect destination reached {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "Redirect destination reached" - statusCode = 200L + statusCode = 200 headers = [ "Arbitrary-header" = "Test value" diff --git a/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-weird-content-type-no-body.test b/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-weird-content-type-no-body.test index 6cd61edc68..68cd9e4aa6 100644 --- a/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-weird-content-type-no-body.test +++ b/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-weird-content-type-no-body.test @@ -22,7 +22,7 @@ Redirect destination reached {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "Redirect destination reached" - statusCode = 200L + statusCode = 200 headers = [ "Arbitrary-header" = "Test value" diff --git a/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-weird-content-type-with-body.test b/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-weird-content-type-with-body.test index 49e58da538..eb7616d51e 100644 --- a/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-weird-content-type-with-body.test +++ b/backend/testfiles/httpclient/v0/todo/response-redirect-dest-post-with-weird-content-type-with-body.test @@ -22,7 +22,7 @@ Redirect destination reached {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "Redirect destination reached" - statusCode = 200L + statusCode = 200 headers = [ "Arbitrary-header" = "Test value" diff --git a/backend/testfiles/httpclient/v0/todo/response-redirect-dest-put-with-content-type-no-body.test b/backend/testfiles/httpclient/v0/todo/response-redirect-dest-put-with-content-type-no-body.test index f825b99b9e..927fb592ba 100644 --- a/backend/testfiles/httpclient/v0/todo/response-redirect-dest-put-with-content-type-no-body.test +++ b/backend/testfiles/httpclient/v0/todo/response-redirect-dest-put-with-content-type-no-body.test @@ -22,7 +22,7 @@ Redirect destination reached {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "Redirect destination reached" - statusCode = 200L + statusCode = 200 headers = [ "Arbitrary-header" = "Test value" diff --git a/backend/testfiles/httpclient/v0/todo/response-redirect-dest-put-with-content-type-with-body.test b/backend/testfiles/httpclient/v0/todo/response-redirect-dest-put-with-content-type-with-body.test index f825b99b9e..927fb592ba 100644 --- a/backend/testfiles/httpclient/v0/todo/response-redirect-dest-put-with-content-type-with-body.test +++ b/backend/testfiles/httpclient/v0/todo/response-redirect-dest-put-with-content-type-with-body.test @@ -22,7 +22,7 @@ Redirect destination reached {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "Redirect destination reached" - statusCode = 200L + statusCode = 200 headers = [ "Arbitrary-header" = "Test value" diff --git a/backend/testfiles/httpclient/v0/todo/response-redirect-dest-with-auth-header.test b/backend/testfiles/httpclient/v0/todo/response-redirect-dest-with-auth-header.test index e2483b3f2e..876aee5599 100644 --- a/backend/testfiles/httpclient/v0/todo/response-redirect-dest-with-auth-header.test +++ b/backend/testfiles/httpclient/v0/todo/response-redirect-dest-with-auth-header.test @@ -23,7 +23,7 @@ Redirect destination reached with auth {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "Redirect destination reached with auth" - statusCode = 200L + statusCode = 200 headers = [ "Arbitrary-header" = "Test value" diff --git a/backend/testfiles/httpclient/v0/todo/response-redirect-dest-with-cookies.test b/backend/testfiles/httpclient/v0/todo/response-redirect-dest-with-cookies.test index 03cf45bb3f..4c356c0858 100644 --- a/backend/testfiles/httpclient/v0/todo/response-redirect-dest-with-cookies.test +++ b/backend/testfiles/httpclient/v0/todo/response-redirect-dest-with-cookies.test @@ -23,7 +23,7 @@ Redirect destination reached with cookies {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "Redirect destination reached with cookies" - statusCode = 200L + statusCode = 200 headers = [ "Arbitrary-header" = "Test value" diff --git a/backend/testfiles/httpclient/v0/todo/response-redirect-dest-with-query-params.test b/backend/testfiles/httpclient/v0/todo/response-redirect-dest-with-query-params.test index 7023032661..ec95b77531 100644 --- a/backend/testfiles/httpclient/v0/todo/response-redirect-dest-with-query-params.test +++ b/backend/testfiles/httpclient/v0/todo/response-redirect-dest-with-query-params.test @@ -20,7 +20,7 @@ Redirect destination reached with params {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "Redirect destination reached with params" - statusCode = 200L + statusCode = 200 headers = [ "Arbitrary-header" = "Test value" diff --git a/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-form-urlencoded-content-type-no-body.test b/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-form-urlencoded-content-type-no-body.test index c228614ce5..900659c6ba 100644 --- a/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-form-urlencoded-content-type-no-body.test +++ b/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-form-urlencoded-content-type-no-body.test @@ -18,7 +18,7 @@ Location: /v0/response-redirect-dest-post-with-form-urlencoded-content-type-no-b {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "Redirect destination reached" - statusCode = 200L + statusCode = 200 headers = [ "Arbitrary-header" = "Test value" diff --git a/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-form-urlencoded-content-type-with-body.test b/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-form-urlencoded-content-type-with-body.test index 591b498f94..8d433da766 100644 --- a/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-form-urlencoded-content-type-with-body.test +++ b/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-form-urlencoded-content-type-with-body.test @@ -18,7 +18,7 @@ Location: /v0/response-redirect-dest-post-with-form-urlencoded-content-type-with {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "Redirect destination reached" - statusCode = 200L + statusCode = 200 headers = [ "Arbitrary-header" = "Test value" diff --git a/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-json-content-type-no-body.test b/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-json-content-type-no-body.test index 51499bde4c..dc0cc751f2 100644 --- a/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-json-content-type-no-body.test +++ b/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-json-content-type-no-body.test @@ -18,7 +18,7 @@ Location: /v0/response-redirect-dest-post-with-json-content-type-no-body {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "Redirect destination reached" - statusCode = 200L + statusCode = 200 headers = [ "Arbitrary-header" = "Test value" diff --git a/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-json-content-type-with-body.test b/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-json-content-type-with-body.test index 72423fafa2..452eea589e 100644 --- a/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-json-content-type-with-body.test +++ b/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-json-content-type-with-body.test @@ -18,7 +18,7 @@ Location: /v0/response-redirect-dest-post-with-json-content-type-with-body {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "Redirect destination reached" - statusCode = 200L + statusCode = 200 headers = [ "Arbitrary-header" = "Test value" diff --git a/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-no-content-type-no-body.test b/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-no-content-type-no-body.test index 85a0dfeda2..178cd5e844 100644 --- a/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-no-content-type-no-body.test +++ b/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-no-content-type-no-body.test @@ -18,7 +18,7 @@ Location: /v0/response-redirect-dest-post-with-no-content-type-no-body {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "Redirect destination reached" - statusCode = 200L + statusCode = 200 headers = [ "Arbitrary-header" = "Test value" diff --git a/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-no-content-type-with-body.test b/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-no-content-type-with-body.test index 8d09b23717..d184f3dd8c 100644 --- a/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-no-content-type-with-body.test +++ b/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-no-content-type-with-body.test @@ -18,7 +18,7 @@ Location: /v0/response-redirect-dest-post-with-no-content-type-with-body {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "Redirect destination reached" - statusCode = 200L + statusCode = 200 headers = [ "Arbitrary-header" = "Test value" diff --git a/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-plain-content-type-no-body.test b/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-plain-content-type-no-body.test index 924dc23317..2a77607320 100644 --- a/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-plain-content-type-no-body.test +++ b/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-plain-content-type-no-body.test @@ -18,7 +18,7 @@ Location: /v0/response-redirect-dest-post-with-plain-content-type-no-body {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "Redirect destination reached" - statusCode = 200L + statusCode = 200 headers = [ "Arbitrary-header" = "Test value" diff --git a/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-plain-content-type-with-body.test b/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-plain-content-type-with-body.test index 5ea7b4af3c..78070f9a93 100644 --- a/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-plain-content-type-with-body.test +++ b/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-plain-content-type-with-body.test @@ -18,7 +18,7 @@ Location: /v0/response-redirect-dest-post-with-plain-content-type-with-body {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "Redirect destination reached" - statusCode = 200L + statusCode = 200 headers = [ "Arbitrary-header" = "Test value" diff --git a/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-weird-content-type-no-body.test b/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-weird-content-type-no-body.test index 4b74964f0c..3fa2dd4386 100644 --- a/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-weird-content-type-no-body.test +++ b/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-weird-content-type-no-body.test @@ -18,7 +18,7 @@ Location: /v0/response-redirect-dest-post-with-weird-content-type-no-body {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "Redirect destination reached" - statusCode = 200L + statusCode = 200 headers = [ "Arbitrary-header" = "Test value" diff --git a/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-weird-content-type-with-body.test b/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-weird-content-type-with-body.test index 6251a71824..8434fe7bec 100644 --- a/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-weird-content-type-with-body.test +++ b/backend/testfiles/httpclient/v0/todo/response-redirect-post-with-weird-content-type-with-body.test @@ -18,7 +18,7 @@ Location: /v0/response-redirect-dest-post-with-weird-content-type-with-body {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "Redirect destination reached" - statusCode = 200L + statusCode = 200 headers = [ "Arbitrary-header" = "Test value" diff --git a/backend/testfiles/httpclient/v0/todo/response-redirect-put-with-content-type-no-body.test b/backend/testfiles/httpclient/v0/todo/response-redirect-put-with-content-type-no-body.test index f4fbe62ccd..d8d8191395 100644 --- a/backend/testfiles/httpclient/v0/todo/response-redirect-put-with-content-type-no-body.test +++ b/backend/testfiles/httpclient/v0/todo/response-redirect-put-with-content-type-no-body.test @@ -18,7 +18,7 @@ Location: /v0/response-redirect-dest-put-with-content-type-no-body {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "Redirect destination reached" - statusCode = 200L + statusCode = 200 headers = [ "Arbitrary-header" = "Test value" diff --git a/backend/testfiles/httpclient/v0/todo/response-redirect-put-with-content-type-with-body.test b/backend/testfiles/httpclient/v0/todo/response-redirect-put-with-content-type-with-body.test index a156441da0..560ab0e4be 100644 --- a/backend/testfiles/httpclient/v0/todo/response-redirect-put-with-content-type-with-body.test +++ b/backend/testfiles/httpclient/v0/todo/response-redirect-put-with-content-type-with-body.test @@ -18,7 +18,7 @@ Location: /v0/response-redirect-dest-put-with-content-type-with-body {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "Redirect destination reached" - statusCode = 200L + statusCode = 200 headers = [ "Arbitrary-header" = "Test value" diff --git a/backend/testfiles/httpclient/v0/todo/response-redirect-to-http-absolute.test b/backend/testfiles/httpclient/v0/todo/response-redirect-to-http-absolute.test index eee0632137..4630a4f661 100644 --- a/backend/testfiles/httpclient/v0/todo/response-redirect-to-http-absolute.test +++ b/backend/testfiles/httpclient/v0/todo/response-redirect-to-http-absolute.test @@ -18,7 +18,7 @@ Location: https://httpbin.org/status/200L {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "" - statusCode = 200L + statusCode = 200 error = "" headers = { diff --git a/backend/testfiles/httpclient/v0/todo/response-redirect-to-http-relative-200.test b/backend/testfiles/httpclient/v0/todo/response-redirect-to-http-relative-200.test index 86eabcdaee..66da701829 100644 --- a/backend/testfiles/httpclient/v0/todo/response-redirect-to-http-relative-200.test +++ b/backend/testfiles/httpclient/v0/todo/response-redirect-to-http-relative-200.test @@ -17,7 +17,7 @@ Location: /v0/response-redirect-destination {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "Redirect destination reached" - statusCode = 200L + statusCode = 200 error = "" headers = [ diff --git a/backend/testfiles/httpclient/v0/todo/response-redirect-with-auth-header.test b/backend/testfiles/httpclient/v0/todo/response-redirect-with-auth-header.test index 14fc25ecfa..3ba67e8d45 100644 --- a/backend/testfiles/httpclient/v0/todo/response-redirect-with-auth-header.test +++ b/backend/testfiles/httpclient/v0/todo/response-redirect-with-auth-header.test @@ -20,7 +20,7 @@ Location: /v0/response-redirect-dest-with-auth-header {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "Redirect destination reached with auth" - statusCode = 200L + statusCode = 200 headers = [ "Arbitrary-header" = "Test value" diff --git a/backend/testfiles/httpclient/v0/todo/response-redirect-with-cookies.test b/backend/testfiles/httpclient/v0/todo/response-redirect-with-cookies.test index 4326bb534b..30f6e05d2b 100644 --- a/backend/testfiles/httpclient/v0/todo/response-redirect-with-cookies.test +++ b/backend/testfiles/httpclient/v0/todo/response-redirect-with-cookies.test @@ -20,7 +20,7 @@ Location: /v0/response-redirect-dest-with-cookies {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "Redirect destination reached with cookies" - statusCode = 200L + statusCode = 200 headers = [ "Arbitrary-header" = "Test value" diff --git a/backend/testfiles/httpclient/v0/todo/response-redirect-with-query-params.test b/backend/testfiles/httpclient/v0/todo/response-redirect-with-query-params.test index baf4162a82..01de67192c 100644 --- a/backend/testfiles/httpclient/v0/todo/response-redirect-with-query-params.test +++ b/backend/testfiles/httpclient/v0/todo/response-redirect-with-query-params.test @@ -18,7 +18,7 @@ Location: /v0/response-redirect-dest-with-query-params?value=x {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "Redirect destination reached with params" - statusCode = 200L + statusCode = 200 headers = [ "Arbitrary-header" = "Test value" diff --git a/backend/testfiles/httpclient/v0/todo/uri-with-auth-emoji-password.test b/backend/testfiles/httpclient/v0/todo/uri-with-auth-emoji-password.test index 74af168b3c..5f539d0ad2 100644 --- a/backend/testfiles/httpclient/v0/todo/uri-with-auth-emoji-password.test +++ b/backend/testfiles/httpclient/v0/todo/uri-with-auth-emoji-password.test @@ -21,7 +21,7 @@ Content-Length: LENGTH {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "\"Hello back\"" - statusCode = 200L + statusCode = 200 headers = [ ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/todo/uri-with-auth-emoji-username.test b/backend/testfiles/httpclient/v0/todo/uri-with-auth-emoji-username.test index abc47ef484..3fc3ee4b8f 100644 --- a/backend/testfiles/httpclient/v0/todo/uri-with-auth-emoji-username.test +++ b/backend/testfiles/httpclient/v0/todo/uri-with-auth-emoji-username.test @@ -21,7 +21,7 @@ Content-Length: LENGTH {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "\"Hello back\"" - statusCode = 200L + statusCode = 200 headers = [ ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/todo/uri-with-auth-just-password.test b/backend/testfiles/httpclient/v0/todo/uri-with-auth-just-password.test index c5fab51e59..2707d767a4 100644 --- a/backend/testfiles/httpclient/v0/todo/uri-with-auth-just-password.test +++ b/backend/testfiles/httpclient/v0/todo/uri-with-auth-just-password.test @@ -21,7 +21,7 @@ Content-Length: LENGTH {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "\"Hello back\"" - statusCode = 200L + statusCode = 200 headers = [ ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/todo/uri-with-auth-just-username-with-colon.test b/backend/testfiles/httpclient/v0/todo/uri-with-auth-just-username-with-colon.test index 05933384d5..014b201a2d 100644 --- a/backend/testfiles/httpclient/v0/todo/uri-with-auth-just-username-with-colon.test +++ b/backend/testfiles/httpclient/v0/todo/uri-with-auth-just-username-with-colon.test @@ -21,7 +21,7 @@ Content-Length: LENGTH {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "\"Hello back\"" - statusCode = 200L + statusCode = 200 headers = [ ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/todo/uri-with-auth-just-username.test b/backend/testfiles/httpclient/v0/todo/uri-with-auth-just-username.test index e04b8bdb8c..918b00efbf 100644 --- a/backend/testfiles/httpclient/v0/todo/uri-with-auth-just-username.test +++ b/backend/testfiles/httpclient/v0/todo/uri-with-auth-just-username.test @@ -21,7 +21,7 @@ Content-Length: LENGTH {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "\"Hello back\"" - statusCode = 200L + statusCode = 200 headers = [ ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/todo/uri-with-auth-plus-header.test b/backend/testfiles/httpclient/v0/todo/uri-with-auth-plus-header.test index cb481b8536..aac8cffe9b 100644 --- a/backend/testfiles/httpclient/v0/todo/uri-with-auth-plus-header.test +++ b/backend/testfiles/httpclient/v0/todo/uri-with-auth-plus-header.test @@ -22,7 +22,7 @@ Content-Length: LENGTH {response with headers = respHeaders}) = Darklang.Stdlib.HttpClient.Response { body = "\"Hello back\"" - statusCode = 200L + statusCode = 200 headers = [ ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/uri-with-path-basic.test b/backend/testfiles/httpclient/v0/uri-with-path-basic.test index 637f9a4d81..3cd4019554 100644 --- a/backend/testfiles/httpclient/v0/uri-with-path-basic.test +++ b/backend/testfiles/httpclient/v0/uri-with-path-basic.test @@ -17,7 +17,7 @@ Hello back let respHeaders = (response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date")) {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 200L + { statusCode = 200 headers = [ ("server", "kestrel") ("content-length", "LENGTH") diff --git a/backend/testfiles/httpclient/v0/uri-with-path-dots.test b/backend/testfiles/httpclient/v0/uri-with-path-dots.test index 7e9f459c2e..14efaaaf3c 100644 --- a/backend/testfiles/httpclient/v0/uri-with-path-dots.test +++ b/backend/testfiles/httpclient/v0/uri-with-path-dots.test @@ -17,7 +17,7 @@ Hello back let respHeaders = (response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date")) {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 200L + { statusCode = 200 headers = [ ("server", "kestrel") diff --git a/backend/testfiles/httpclient/v0/uri-with-path-fragment.test b/backend/testfiles/httpclient/v0/uri-with-path-fragment.test index e255fc93c4..7b2de51eee 100644 --- a/backend/testfiles/httpclient/v0/uri-with-path-fragment.test +++ b/backend/testfiles/httpclient/v0/uri-with-path-fragment.test @@ -17,7 +17,7 @@ Hello back let respHeaders = response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date") {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 200L + { statusCode = 200 headers = [ ("server", "kestrel") diff --git a/backend/testfiles/httpclient/v0/uri-with-path-slash.test b/backend/testfiles/httpclient/v0/uri-with-path-slash.test index 08c2190288..31b8ce985d 100644 --- a/backend/testfiles/httpclient/v0/uri-with-path-slash.test +++ b/backend/testfiles/httpclient/v0/uri-with-path-slash.test @@ -17,7 +17,7 @@ Hello back let respHeaders = (response.headers |> Darklang.Stdlib.List.filter (fun h -> (Darklang.Stdlib.Tuple2.first h) != "date")) {response with headers = respHeaders}) == Darklang.Stdlib.HttpClient.Response - { statusCode = 200L + { statusCode = 200 headers = [ ("server", "kestrel") diff --git a/backend/tests/Tests/HttpServer.Tests.fs b/backend/tests/Tests/HttpServer.Tests.fs index 0298f7a0ec..c6ef353a10 100644 --- a/backend/tests/Tests/HttpServer.Tests.fs +++ b/backend/tests/Tests/HttpServer.Tests.fs @@ -460,7 +460,7 @@ let private concurrentEphemeralBlobRequests = [ { version = Http route = "/" method = "POST" - code = "Darklang.Stdlib.Http.response request.body 200L" } ] + code = "Darklang.Stdlib.Http.response request.body 200" } ] request = [||] expectedResponse = [||] } let! handler = buildRouterForTest exeState test diff --git a/packages/darklang/cli/http/serve.dark b/packages/darklang/cli/http/serve.dark index b3e92ec10c..9e5daad1d3 100644 --- a/packages/darklang/cli/http/serve.dark +++ b/packages/darklang/cli/http/serve.dark @@ -6,14 +6,14 @@ module Darklang.Cli.Http.Serve /// Parsed flags + positional. `routerPath = ""` means "no router given". type Args = { routerPath: String - port: Int64 - maxBodyBytes: Int64 + port: Int + maxBodyBytes: Int error: Stdlib.Option.Option } let defaultArgs (): Args = Args { routerPath = "" - port = 8080L + port = 8080I maxBodyBytes = Stdlib.HttpServer.Config.defaultMaxBodyBytes error = Stdlib.Option.Option.None } @@ -24,12 +24,12 @@ let rec parseArgs (rest: List) (acc: Args) : Args = match rest with | [] -> acc | "--port" :: value :: tail -> - match Stdlib.Int64.parse value with + match Stdlib.Int.parse value with | Error _ -> { acc with error = Stdlib.Option.Option.Some $"Invalid --port: {value}" } | Ok p -> parseArgs tail { acc with port = p } | "--max-body-bytes" :: value :: tail -> - match Stdlib.Int64.parse value with + match Stdlib.Int.parse value with | Error _ -> Args { acc with @@ -85,8 +85,8 @@ let execute (state: Cli.AppState) (args: List) : Cli.AppState = "Missing router path. Usage: serve [--port N] [--max-body-bytes N]") state else - let portStr = Stdlib.Int64.toString parsed.port - let maxBytesStr = Stdlib.Int64.toString parsed.maxBodyBytes + let portStr = Stdlib.Int.toString parsed.port + let maxBytesStr = Stdlib.Int.toString parsed.maxBodyBytes [ $"Using router: {parsed.routerPath}" $"Max body bytes: {maxBytesStr}" @@ -99,9 +99,9 @@ let execute (state: Cli.AppState) (args: List) : Cli.AppState = // serve via the stdlib helper; only a non-default max body needs a record-update on the config. let configExpr = if parsed.maxBodyBytes == Stdlib.HttpServer.Config.defaultMaxBodyBytes then - $"Stdlib.HttpServer.Config.defaults {portStr}L" + $"Stdlib.HttpServer.Config.defaults {portStr}I" else - $"{{ Stdlib.HttpServer.Config.defaults {portStr}L with maxBodyBytes = {maxBytesStr}L }}" + $"{{ Stdlib.HttpServer.Config.defaults {portStr}I with maxBodyBytes = {maxBytesStr}I }}" let expr = $"Stdlib.HttpServer.serve ({configExpr}) {parsed.routerPath}" diff --git a/packages/darklang/demo-data/httpserver-test.dark b/packages/darklang/demo-data/httpserver-test.dark index 9c068b54b0..1c8908c9f4 100644 --- a/packages/darklang/demo-data/httpserver-test.dark +++ b/packages/darklang/demo-data/httpserver-test.dark @@ -3,7 +3,7 @@ module Darklang.DemoData.HttpServerTest // Test handlers and router for the HTTP server let helloHandlerFn (req: Stdlib.Http.Request) : Stdlib.Http.Response = - Stdlib.Http.responseWithText "Hello, World!" 200L + Stdlib.Http.responseWithText "Hello, World!" 200I let helloHandler: Stdlib.HttpServer.Handler = Stdlib.HttpServer.Handler @@ -14,7 +14,7 @@ let helloHandler: Stdlib.HttpServer.Handler = let echoHandlerFn (req: Stdlib.Http.Request) : Stdlib.Http.Response = let bodyText = Stdlib.String.fromBlobWithReplacement req.body - Stdlib.Http.responseWithText bodyText 200L + Stdlib.Http.responseWithText bodyText 200I let echoHandler: Stdlib.HttpServer.Handler = Stdlib.HttpServer.Handler @@ -24,7 +24,7 @@ let echoHandler: Stdlib.HttpServer.Handler = let rootHandlerFn (req: Stdlib.Http.Request) : Stdlib.Http.Response = - Stdlib.Http.responseWithText "Welcome to Darklang HTTP Server!" 200L + Stdlib.Http.responseWithText "Welcome to Darklang HTTP Server!" 200I let rootHandler: Stdlib.HttpServer.Handler = Stdlib.HttpServer.Handler diff --git a/packages/darklang/discord.dark b/packages/darklang/discord.dark index 956b1a309d..53b7ca186c 100644 --- a/packages/darklang/discord.dark +++ b/packages/darklang/discord.dark @@ -68,7 +68,7 @@ type Error = | RequestFailed of Stdlib.HttpClient.RequestError /// Discord returned a non-2xx response. /// Common cases: 401 invalid token, 404 unknown webhook, 429 rate limited. - | DiscordError of statusCode: Int64 * body: String + | DiscordError of statusCode: Int * body: String let toString (e: Error) : String = @@ -76,7 +76,7 @@ let toString (e: Error) : String = | RequestFailed re -> "HTTP request failed: " ++ Stdlib.HttpClient.toString re | DiscordError(code, body) -> - $"Discord returned {Stdlib.Int64.toString code}: {body}" + $"Discord returned {Stdlib.Int.toString code}: {body}" /// Build a minimal message with just text content. @@ -242,7 +242,7 @@ let post match Stdlib.HttpClient.post webhookUrl headers body with | Ok response -> - if response.statusCode >= 200L && response.statusCode < 300L then + if response.statusCode >= 200I && response.statusCode < 300I then Stdlib.Result.Result.Ok() else let bodyStr = diff --git a/packages/darklang/internal/dark-packages/dark-packages.dark b/packages/darklang/internal/dark-packages/dark-packages.dark index 1b8cf9851c..9fe9d36120 100644 --- a/packages/darklang/internal/dark-packages/dark-packages.dark +++ b/packages/darklang/internal/dark-packages/dark-packages.dark @@ -101,7 +101,7 @@ let serverBranchId: Uuid = SCM.Branch.mainBranchId // ────────────────────────── handlers ────────────────────────── let pingHandlerFn (req: HttpRequest) : HttpResponse = - Stdlib.Http.responseWithText "pong" 200L + Stdlib.Http.responseWithText "pong" 200I let pingHandler: Handler = Handler { route = "/ping"; method = "GET"; handler = pingHandlerFn } @@ -114,7 +114,7 @@ let opsPostHandlerFn (req: HttpRequest) : HttpResponse = match SCM.PackageOps.add serverBranchId ops with | Ok insertedCount -> let countStr = Stdlib.Int64.toString insertedCount - Stdlib.Http.responseWithText $"Successfully received and applied {countStr} ops" 200L + Stdlib.Http.responseWithText $"Successfully received and applied {countStr} ops" 200I | Error errorMsg -> Stdlib.Http.serverError errorMsg | Error _err -> Stdlib.Http.badRequest "Invalid request body. Expected JSON list of PackageOp." @@ -132,7 +132,7 @@ let opsGetHandlerFn (req: HttpRequest) : HttpResponse = | Ok limit -> let ops = SCM.PackageOps.getRecent limit let json = ops |> Stdlib.Json.serialize> - Stdlib.Http.responseWithJson json 200L + Stdlib.Http.responseWithJson json 200I let opsGetHandler: Handler = Handler { route = "/ops"; method = "GET"; handler = opsGetHandlerFn } @@ -145,7 +145,7 @@ let statsHandlerFn (req: HttpRequest) : HttpResponse = - types: {stats.types |> Stdlib.Int64.toString} - fns: {stats.fns |> Stdlib.Int64.toString} - values: {stats.values |> Stdlib.Int64.toString}" - Stdlib.Http.responseWithText body 200L + Stdlib.Http.responseWithText body 200I let statsHandler: Handler = Handler @@ -198,7 +198,7 @@ let searchHandlerFn (req: HttpRequest) : HttpResponse = let results = Builtin.pmSearch serverBranchId query let json = results |> Stdlib.Json.serialize - Stdlib.Http.responseWithJson json 200L + Stdlib.Http.responseWithJson json 200I let searchHandler: Handler = Handler { route = "/search"; method = "GET"; handler = searchHandlerFn } @@ -233,7 +233,7 @@ let locationHandlerFn (req: HttpRequest) : HttpResponse = let results = Builtin.pmSearch serverBranchId searchQuery let json = results |> Stdlib.Json.serialize - Stdlib.Http.responseWithJson json 200L + Stdlib.Http.responseWithJson json 200I else match parseNameToLocation location with | Error errorMsg -> Stdlib.Http.badRequest errorMsg @@ -246,19 +246,19 @@ let locationHandlerFn (req: HttpRequest) : HttpResponse = match Builtin.pmGetFn hash with | Some fn -> let json = fn |> Stdlib.Json.serialize - Stdlib.Http.responseWithJson json 200L + Stdlib.Http.responseWithJson json 200I | None -> Stdlib.Http.notFound () | Type -> match Builtin.pmGetType hash with | Some t -> let json = t |> Stdlib.Json.serialize - Stdlib.Http.responseWithJson json 200L + Stdlib.Http.responseWithJson json 200I | None -> Stdlib.Http.notFound () | Value -> match Builtin.pmGetValue hash with | Some v -> let json = v |> Stdlib.Json.serialize - Stdlib.Http.responseWithJson json 200L + Stdlib.Http.responseWithJson json 200I | None -> Stdlib.Http.notFound () | None -> // Not a leaf — treat the whole path as a module to browse. @@ -273,7 +273,7 @@ let locationHandlerFn (req: HttpRequest) : HttpResponse = let json = results |> Stdlib.Json.serialize - Stdlib.Http.responseWithJson json 200L + Stdlib.Http.responseWithJson json 200I let locationHandler: Handler = Handler @@ -299,7 +299,7 @@ let typeFindHandlerFn (req: HttpRequest) : HttpResponse = | Ok location -> match Builtin.pmFindType serverBranchId location with | Some hash -> - Stdlib.Http.responseWithJson (hash |> Stdlib.Json.serialize) 200L + Stdlib.Http.responseWithJson (hash |> Stdlib.Json.serialize) 200I | None -> Stdlib.Http.notFound () let typeFindHandler: Handler = @@ -315,7 +315,7 @@ let typeGetHandlerFn (req: HttpRequest) : HttpResponse = match Builtin.pmGetType hash with | Some t -> let json = t |> Stdlib.Json.serialize - Stdlib.Http.responseWithJson json 200L + Stdlib.Http.responseWithJson json 200I | None -> Stdlib.Http.notFound () let typeGetHandler: Handler = @@ -335,7 +335,7 @@ let typeGetWithLocationHandlerFn let json = locatedItem |> Stdlib.Json.serialize> - Stdlib.Http.responseWithJson json 200L + Stdlib.Http.responseWithJson json 200I | None -> Stdlib.Http.notFound () let typeGetWithLocationHandler: Handler = @@ -355,7 +355,7 @@ let valueFindHandlerFn (req: HttpRequest) : HttpResponse = | Ok location -> match Builtin.pmFindValue serverBranchId location with | Some hash -> - Stdlib.Http.responseWithJson (hash |> Stdlib.Json.serialize) 200L + Stdlib.Http.responseWithJson (hash |> Stdlib.Json.serialize) 200I | None -> Stdlib.Http.notFound () let valueFindHandler: Handler = @@ -372,7 +372,7 @@ let valueGetHandlerFn (req: HttpRequest) : HttpResponse = match Builtin.pmGetValue hash with | Some v -> let json = v |> Stdlib.Json.serialize - Stdlib.Http.responseWithJson json 200L + Stdlib.Http.responseWithJson json 200I | None -> Stdlib.Http.notFound () let valueGetHandler: Handler = @@ -393,7 +393,7 @@ let valueGetWithLocationHandlerFn let json = locatedItem |> Stdlib.Json.serialize> - Stdlib.Http.responseWithJson json 200L + Stdlib.Http.responseWithJson json 200I | None -> Stdlib.Http.notFound () let valueGetWithLocationHandler: Handler = @@ -413,7 +413,7 @@ let functionFindHandlerFn (req: HttpRequest) : HttpResponse = | Ok location -> match Builtin.pmFindFn serverBranchId location with | Some hash -> - Stdlib.Http.responseWithJson (hash |> Stdlib.Json.serialize) 200L + Stdlib.Http.responseWithJson (hash |> Stdlib.Json.serialize) 200I | None -> Stdlib.Http.notFound () let functionFindHandler: Handler = @@ -432,7 +432,7 @@ let functionGetHandlerFn (req: HttpRequest) : HttpResponse = match Builtin.pmGetFn hash with | Some f -> let json = f |> Stdlib.Json.serialize - Stdlib.Http.responseWithJson json 200L + Stdlib.Http.responseWithJson json 200I | None -> Stdlib.Http.notFound () let functionGetHandler: Handler = @@ -457,7 +457,7 @@ let functionGetWithLocationHandlerFn let json = locatedItem |> Stdlib.Json.serialize> - Stdlib.Http.responseWithJson json 200L + Stdlib.Http.responseWithJson json 200I | None -> Stdlib.Http.notFound () let functionGetWithLocationHandler: Handler = diff --git a/packages/darklang/llm/internal/http-errors.dark b/packages/darklang/llm/internal/http-errors.dark index 2df0794f46..02b5516e74 100644 --- a/packages/darklang/llm/internal/http-errors.dark +++ b/packages/darklang/llm/internal/http-errors.dark @@ -9,24 +9,24 @@ type ProviderError = Darklang.LLM.Provider.ProviderError /// Map an HTTP status code to a ProviderError /// This provides consistent error semantics across all providers. -let mapStatusToError (statusCode: Int64) (body: String) : ProviderError = +let mapStatusToError (statusCode: Int) (body: String) : ProviderError = match statusCode with - | 400L -> ProviderError.InvalidRequestError body - | 401L -> ProviderError.AuthenticationError "Invalid API key" - | 403L -> ProviderError.AuthenticationError "Access forbidden" - | 404L -> ProviderError.InvalidRequestError "Resource not found" - | 429L -> ProviderError.RateLimitError "Rate limit exceeded" - | code when code >= 500L && code < 600L -> ProviderError.ServerError body - | code -> ProviderError.Unknown("HTTP " ++ Stdlib.Int64.toString code ++ ": " ++ body) + | 400I -> ProviderError.InvalidRequestError body + | 401I -> ProviderError.AuthenticationError "Invalid API key" + | 403I -> ProviderError.AuthenticationError "Access forbidden" + | 404I -> ProviderError.InvalidRequestError "Resource not found" + | 429I -> ProviderError.RateLimitError "Rate limit exceeded" + | code when code >= 500I && code < 600I -> ProviderError.ServerError body + | code -> ProviderError.Unknown("HTTP " ++ Stdlib.Int.toString code ++ ": " ++ body) /// Handle an HTTP response, returning Ok for success or mapped error let handleResponse - (statusCode: Int64) + (statusCode: Int) (body: String) (parseSuccess: String -> Stdlib.Result.Result<'a, ProviderError>) : Stdlib.Result.Result<'a, ProviderError> = - if statusCode >= 200L && statusCode < 300L then + if statusCode >= 200I && statusCode < 300I then parseSuccess body else Stdlib.Result.Result.Error(mapStatusToError statusCode body) diff --git a/packages/darklang/stdlib/http.dark b/packages/darklang/stdlib/http.dark index bd1a90e59d..f7903412bc 100644 --- a/packages/darklang/stdlib/http.dark +++ b/packages/darklang/stdlib/http.dark @@ -161,13 +161,13 @@ module Request = type Response = - { statusCode: Int64 + { statusCode: Int headers: List body: Blob } /// Returns a that can be returned from an HTTP handler to /// respond with HTTP status and body. -let response (body: Blob) (statusCode: Int64) : Stdlib.Http.Response = +let response (body: Blob) (statusCode: Int) : Stdlib.Http.Response = Stdlib.Http.Response { statusCode = statusCode headers = [] @@ -179,7 +179,7 @@ let response (body: Blob) (statusCode: Int64) : Stdlib.Http.Response = let responseWithHeaders (body: Blob) (headers: List) - (statusCode: Int64) + (statusCode: Int) : Stdlib.Http.Response = Stdlib.Http.Response { statusCode = statusCode @@ -190,7 +190,7 @@ let responseWithHeaders /// respond with HTTP status 200 and body. let success (body: Blob) : Stdlib.Http.Response = Stdlib.Http.Response - { statusCode = 200L + { statusCode = 200I headers = [] body = body } @@ -199,7 +199,7 @@ let success (body: Blob) : Stdlib.Http.Response = /// Content-Type header set to "text/html; charset=utf-8". let responseWithHtml (body: String) - (statusCode: Int64) + (statusCode: Int) : Stdlib.Http.Response = Stdlib.Http.Response { statusCode = statusCode @@ -212,7 +212,7 @@ let responseWithHtml /// Content-Type header set to "text/plain; charset=utf-8". let responseWithText (text: String) - (statusCode: Int64) + (statusCode: Int) : Stdlib.Http.Response = Stdlib.Http.Response { statusCode = statusCode @@ -224,7 +224,7 @@ let responseWithText /// Content-Type header set to "application/json". let responseWithJson (json: String) - (statusCode: Int64) + (statusCode: Int) : Stdlib.Http.Response = Stdlib.Http.Response { statusCode = statusCode @@ -235,7 +235,7 @@ let responseWithJson /// respond with {{302}} status code and redirect to . let redirectTo (url: String) : Stdlib.Http.Response = Stdlib.Http.Response - { statusCode = 302L + { statusCode = 302I headers = [ ("Location", url) ] body = Stdlib.Blob.empty } @@ -243,7 +243,7 @@ let redirectTo (url: String) : Stdlib.Http.Response = /// respond with {{400}} status code and body. let badRequest (error: String) : Stdlib.Http.Response = Stdlib.Http.Response - { statusCode = 400L + { statusCode = 400I headers = [] body = Stdlib.String.toBlob error } @@ -251,7 +251,7 @@ let badRequest (error: String) : Stdlib.Http.Response = /// respond with {{404}} status code. let notFound () : Stdlib.Http.Response = Stdlib.Http.Response - { statusCode = 404L + { statusCode = 404I headers = [] body = Stdlib.Blob.empty } @@ -259,7 +259,7 @@ let notFound () : Stdlib.Http.Response = /// respond with {{401}} status code. let unauthorized () : Stdlib.Http.Response = Stdlib.Http.Response - { statusCode = 401L + { statusCode = 401I headers = [] body = Stdlib.Blob.empty } @@ -267,7 +267,7 @@ let unauthorized () : Stdlib.Http.Response = /// respond with {{403}} status code. let forbidden () : Stdlib.Http.Response = Stdlib.Http.Response - { statusCode = 403L + { statusCode = 403I headers = [] body = Stdlib.Blob.empty } @@ -275,13 +275,13 @@ let forbidden () : Stdlib.Http.Response = /// respond with {{500}} status code and body. let serverError (error: String) : Stdlib.Http.Response = Stdlib.Http.Response - { statusCode = 500L + { statusCode = 500I headers = [] body = Stdlib.String.toBlob error } type Cookie = { expires: DateTime - maxAge: Int64 + maxAge: Int domain: String path: String secure: Bool diff --git a/packages/darklang/stdlib/httpclient.dark b/packages/darklang/stdlib/httpclient.dark index db0434624a..0b04a871b5 100644 --- a/packages/darklang/stdlib/httpclient.dark +++ b/packages/darklang/stdlib/httpclient.dark @@ -46,7 +46,7 @@ let toString (e: RequestError) : String = /// The response from a HTTP request type Response = - { statusCode: Int64 + { statusCode: Int headers: List<(String * String)> body: Blob } @@ -56,7 +56,7 @@ type Response = /// The underlying HTTP response is released when the stream is /// drained to completion or `Builtin.streamClose`d. type StreamResponse = - { statusCode: Int64 + { statusCode: Int headers: List<(String * String)> body: Stream } diff --git a/packages/darklang/stdlib/httpserver.dark b/packages/darklang/stdlib/httpserver.dark index ad1ba12843..a8f531dc06 100644 --- a/packages/darklang/stdlib/httpserver.dark +++ b/packages/darklang/stdlib/httpserver.dark @@ -192,9 +192,9 @@ let getPathParam (req: Http.Request) (routePattern: String) (paramName: String) /// record-update, e.g. `{ HttpServer.Config.defaults 8080L with logRequests = false }`. module Config = type Config = - { port: Int64 + { port: Int /// Maximum request body size in bytes (over-limit → 413). - maxBodyBytes: Int64 + maxBodyBytes: Int /// Auto-add `Server: darklang` + HSTS unless the handler set them. injectStandardHeaders: Bool /// Rewrite request.url to https:// when X-Forwarded-Proto: https is present. @@ -203,10 +203,10 @@ module Config = logRequests: Bool } /// Default max request body size: 30 MB. - let defaultMaxBodyBytes : Int64 = 31457280L + let defaultMaxBodyBytes : Int = 31457280I /// Sensible serve defaults for `port`: 30 MB max body, standard headers, proto canonicalization, logging. - let defaults (port: Int64) : Config = + let defaults (port: Int) : Config = Config { port = port maxBodyBytes = defaultMaxBodyBytes diff --git a/packages/darklang/wip/ai/openai/chat.dark b/packages/darklang/wip/ai/openai/chat.dark index 4a8d953a85..3616ec2ba9 100644 --- a/packages/darklang/wip/ai/openai/chat.dark +++ b/packages/darklang/wip/ai/openai/chat.dark @@ -1216,13 +1216,13 @@ let send (apiKey: String) (req: Request) : Stdlib.Result.Result= 200L && code < 300L -> + | code when code >= 200I && code < 300I -> match Stdlib.AltJson.parse bodyStr with | Ok json -> parseResponse json | Error e -> Stdlib.Result.Result.Error("Failed to parse response: " ++ e) - | 401L -> Stdlib.Result.Result.Error "Authentication failed: Invalid API key" - | 429L -> Stdlib.Result.Result.Error "Rate limit exceeded" - | code when code >= 500L -> Stdlib.Result.Result.Error("OpenAI server error: " ++ bodyStr) + | 401I -> Stdlib.Result.Result.Error "Authentication failed: Invalid API key" + | 429I -> Stdlib.Result.Result.Error "Rate limit exceeded" + | code when code >= 500I -> Stdlib.Result.Result.Error("OpenAI server error: " ++ bodyStr) | _ -> match Stdlib.AltJson.parse bodyStr with | Ok (Object fields) -> @@ -1300,7 +1300,7 @@ let list let bodyStr = Stdlib.String.fromBlobWithReplacement response.body match response.statusCode with - | code when code >= 200L && code < 300L -> + | code when code >= 200I && code < 300I -> match Stdlib.AltJson.parse bodyStr with | Ok (Object fields) -> let dataArray = Stdlib.AltJson.Helpers.getArray "data" fields @@ -1320,8 +1320,8 @@ let list else Stdlib.Result.Result.Error("Failed to parse completions: " ++ Stdlib.String.join errors ", ") | _ -> Stdlib.Result.Result.Error "Invalid response format" - | 401L -> Stdlib.Result.Result.Error "Authentication failed: Invalid API key" - | 429L -> Stdlib.Result.Result.Error "Rate limit exceeded" + | 401I -> Stdlib.Result.Result.Error "Authentication failed: Invalid API key" + | 429I -> Stdlib.Result.Result.Error "Rate limit exceeded" | _ -> Stdlib.Result.Result.Error("API error: " ++ bodyStr) /// Get a chat completion by ID @@ -1339,13 +1339,13 @@ let get (apiKey: String) (completionId: String) : Stdlib.Result.Result= 200L && code < 300L -> + | code when code >= 200I && code < 300I -> match Stdlib.AltJson.parse bodyStr with | Ok json -> parseResponse json | Error e -> Stdlib.Result.Result.Error("Failed to parse response: " ++ e) - | 401L -> Stdlib.Result.Result.Error "Authentication failed: Invalid API key" - | 404L -> Stdlib.Result.Result.Error("Chat completion not found: " ++ completionId) - | 429L -> Stdlib.Result.Result.Error "Rate limit exceeded" + | 401I -> Stdlib.Result.Result.Error "Authentication failed: Invalid API key" + | 404I -> Stdlib.Result.Result.Error("Chat completion not found: " ++ completionId) + | 429I -> Stdlib.Result.Result.Error "Rate limit exceeded" | _ -> Stdlib.Result.Result.Error("API error: " ++ bodyStr) /// Update a chat completion's metadata @@ -1371,13 +1371,13 @@ let update let bodyStr = Stdlib.String.fromBlobWithReplacement response.body match response.statusCode with - | code when code >= 200L && code < 300L -> + | code when code >= 200I && code < 300I -> match Stdlib.AltJson.parse bodyStr with | Ok json -> parseResponse json | Error e -> Stdlib.Result.Result.Error("Failed to parse response: " ++ e) - | 401L -> Stdlib.Result.Result.Error "Authentication failed: Invalid API key" - | 404L -> Stdlib.Result.Result.Error("Chat completion not found: " ++ completionId) - | 429L -> Stdlib.Result.Result.Error "Rate limit exceeded" + | 401I -> Stdlib.Result.Result.Error "Authentication failed: Invalid API key" + | 404I -> Stdlib.Result.Result.Error("Chat completion not found: " ++ completionId) + | 429I -> Stdlib.Result.Result.Error "Rate limit exceeded" | _ -> Stdlib.Result.Result.Error("API error: " ++ bodyStr) /// Delete a chat completion @@ -1395,7 +1395,7 @@ let delete (apiKey: String) (completionId: String) : Stdlib.Result.Result= 200L && code < 300L -> + | code when code >= 200I && code < 300I -> match Stdlib.AltJson.parse bodyStr with | Ok (Object fields) -> match (Stdlib.AltJson.Helpers.getString "id" fields, @@ -1406,9 +1406,9 @@ let delete (apiKey: String) (completionId: String) : Stdlib.Result.Result Stdlib.Result.Result.Error "Invalid delete response format" | _ -> Stdlib.Result.Result.Error "Invalid response format" - | 401L -> Stdlib.Result.Result.Error "Authentication failed: Invalid API key" - | 404L -> Stdlib.Result.Result.Error("Chat completion not found: " ++ completionId) - | 429L -> Stdlib.Result.Result.Error "Rate limit exceeded" + | 401I -> Stdlib.Result.Result.Error "Authentication failed: Invalid API key" + | 404I -> Stdlib.Result.Result.Error("Chat completion not found: " ++ completionId) + | 429I -> Stdlib.Result.Result.Error "Rate limit exceeded" | _ -> Stdlib.Result.Result.Error("API error: " ++ bodyStr) /// Parse a stored message from JSON fields @@ -1458,7 +1458,7 @@ let getMessages let bodyStr = Stdlib.String.fromBlobWithReplacement response.body match response.statusCode with - | code when code >= 200L && code < 300L -> + | code when code >= 200I && code < 300I -> match Stdlib.AltJson.parse bodyStr with | Ok (Object fields) -> let dataArray = Stdlib.AltJson.Helpers.getArray "data" fields @@ -1484,9 +1484,9 @@ let getMessages else Stdlib.Result.Result.Error("Failed to parse messages: " ++ Stdlib.String.join errors ", ") | _ -> Stdlib.Result.Result.Error "Invalid response format" - | 401L -> Stdlib.Result.Result.Error "Authentication failed: Invalid API key" - | 404L -> Stdlib.Result.Result.Error("Chat completion not found: " ++ completionId) - | 429L -> Stdlib.Result.Result.Error "Rate limit exceeded" + | 401I -> Stdlib.Result.Result.Error "Authentication failed: Invalid API key" + | 404I -> Stdlib.Result.Result.Error("Chat completion not found: " ++ completionId) + | 429I -> Stdlib.Result.Result.Error "Rate limit exceeded" | _ -> Stdlib.Result.Result.Error("API error: " ++ bodyStr) diff --git a/packages/darklang/wip/ai/openai/embeddings.dark b/packages/darklang/wip/ai/openai/embeddings.dark index adcbdf850c..4cd8684083 100644 --- a/packages/darklang/wip/ai/openai/embeddings.dark +++ b/packages/darklang/wip/ai/openai/embeddings.dark @@ -139,7 +139,7 @@ let createWithOptions let bodyStr = Stdlib.String.fromBlobWithReplacement response.body match response.statusCode with - | code when code >= 200L && code < 300L -> + | code when code >= 200I && code < 300I -> match Stdlib.AltJson.parse bodyStr with | Ok (Object fields) -> let dataArray = Stdlib.AltJson.Helpers.getArray "data" fields @@ -157,8 +157,8 @@ let createWithOptions usage = usage }) | _ -> Stdlib.Result.Result.Error "Missing required fields in response" | _ -> Stdlib.Result.Result.Error "Invalid response format" - | 401L -> Stdlib.Result.Result.Error "Authentication failed: Invalid API key" - | 429L -> Stdlib.Result.Result.Error "Rate limit exceeded" + | 401I -> Stdlib.Result.Result.Error "Authentication failed: Invalid API key" + | 429I -> Stdlib.Result.Result.Error "Rate limit exceeded" | _ -> Stdlib.Result.Result.Error("API error: " ++ bodyStr) /// Generate embeddings for text @@ -258,7 +258,7 @@ let createBatchWithOptions let bodyStr = Stdlib.String.fromBlobWithReplacement response.body match response.statusCode with - | code when code >= 200L && code < 300L -> + | code when code >= 200I && code < 300I -> match Stdlib.AltJson.parse bodyStr with | Ok (Object fields) -> let dataArray = Stdlib.AltJson.Helpers.getArray "data" fields @@ -276,8 +276,8 @@ let createBatchWithOptions usage = usage }) | _ -> Stdlib.Result.Result.Error "Missing required fields in response" | _ -> Stdlib.Result.Result.Error "Invalid response format" - | 401L -> Stdlib.Result.Result.Error "Authentication failed: Invalid API key" - | 429L -> Stdlib.Result.Result.Error "Rate limit exceeded" + | 401I -> Stdlib.Result.Result.Error "Authentication failed: Invalid API key" + | 429I -> Stdlib.Result.Result.Error "Rate limit exceeded" | _ -> Stdlib.Result.Result.Error("API error: " ++ bodyStr) /// Generate embeddings for multiple texts (uses text-embedding-3-small) diff --git a/packages/darklang/wip/ai/openai/models.dark b/packages/darklang/wip/ai/openai/models.dark index 9688026559..709c4cb171 100644 --- a/packages/darklang/wip/ai/openai/models.dark +++ b/packages/darklang/wip/ai/openai/models.dark @@ -43,7 +43,7 @@ let list let bodyStr = Stdlib.String.fromBlobWithReplacement response.body match response.statusCode with - | code when code >= 200L && code < 300L -> + | code when code >= 200I && code < 300I -> match Stdlib.AltJson.parse bodyStr with | Ok (Object fields) -> let dataArray = Stdlib.AltJson.Helpers.getArray "data" fields @@ -62,8 +62,8 @@ let list | _ -> Stdlib.Option.Option.None) Stdlib.Result.Result.Ok models | _ -> Stdlib.Result.Result.Error "Invalid response format" - | 401L -> Stdlib.Result.Result.Error "Authentication failed: Invalid API key" - | 429L -> Stdlib.Result.Result.Error "Rate limit exceeded" + | 401I -> Stdlib.Result.Result.Error "Authentication failed: Invalid API key" + | 429I -> Stdlib.Result.Result.Error "Rate limit exceeded" | _ -> Stdlib.Result.Result.Error("API error: " ++ bodyStr) | Error e -> Stdlib.Result.Result.Error("HTTP request failed: " ++ Stdlib.HttpClient.toString e) @@ -84,7 +84,7 @@ let get let bodyStr = Stdlib.String.fromBlobWithReplacement response.body match response.statusCode with - | code when code >= 200L && code < 300L -> + | code when code >= 200I && code < 300I -> match Stdlib.AltJson.parse bodyStr with | Ok (Object fields) -> match (Stdlib.AltJson.Helpers.getString "id" fields, @@ -96,9 +96,9 @@ let get Model { id = id; created = created; object_ = obj; ownedBy = ownedBy }) | _ -> Stdlib.Result.Result.Error "Invalid model response format" | _ -> Stdlib.Result.Result.Error "Invalid response format" - | 401L -> Stdlib.Result.Result.Error "Authentication failed: Invalid API key" - | 404L -> Stdlib.Result.Result.Error("Model not found: " ++ modelId) - | 429L -> Stdlib.Result.Result.Error "Rate limit exceeded" + | 401I -> Stdlib.Result.Result.Error "Authentication failed: Invalid API key" + | 404I -> Stdlib.Result.Result.Error("Model not found: " ++ modelId) + | 429I -> Stdlib.Result.Result.Error "Rate limit exceeded" | _ -> Stdlib.Result.Result.Error("API error: " ++ bodyStr) | Error e -> Stdlib.Result.Result.Error("HTTP request failed: " ++ Stdlib.HttpClient.toString e) @@ -119,7 +119,7 @@ let delete let bodyStr = Stdlib.String.fromBlobWithReplacement response.body match response.statusCode with - | code when code >= 200L && code < 300L -> + | code when code >= 200I && code < 300I -> match Stdlib.AltJson.parse bodyStr with | Ok (Object fields) -> match (Stdlib.AltJson.Helpers.getString "id" fields, @@ -130,9 +130,9 @@ let delete ModelDeleted { id = id; deleted = deleted; object_ = obj }) | _ -> Stdlib.Result.Result.Error "Invalid delete response format" | _ -> Stdlib.Result.Result.Error "Invalid response format" - | 401L -> Stdlib.Result.Result.Error "Authentication failed: Invalid API key" - | 404L -> Stdlib.Result.Result.Error("Model not found: " ++ modelId) - | 429L -> Stdlib.Result.Result.Error "Rate limit exceeded" + | 401I -> Stdlib.Result.Result.Error "Authentication failed: Invalid API key" + | 404I -> Stdlib.Result.Result.Error("Model not found: " ++ modelId) + | 429I -> Stdlib.Result.Result.Error "Rate limit exceeded" | _ -> Stdlib.Result.Result.Error("API error: " ++ bodyStr) | Error e -> Stdlib.Result.Result.Error("HTTP request failed: " ++ Stdlib.HttpClient.toString e) diff --git a/packages/darklang/wip/ai/openai/responses.dark b/packages/darklang/wip/ai/openai/responses.dark index c3655a7c63..5256546b72 100644 --- a/packages/darklang/wip/ai/openai/responses.dark +++ b/packages/darklang/wip/ai/openai/responses.dark @@ -831,13 +831,13 @@ let send let bodyStr = Stdlib.String.fromBlobWithReplacement response.body match response.statusCode with - | code when code >= 200L && code < 300L -> + | code when code >= 200I && code < 300I -> match Stdlib.AltJson.parse bodyStr with | Ok json -> parseResponse json | Error e -> Stdlib.Result.Result.Error("Failed to parse response: " ++ e) - | 401L -> Stdlib.Result.Result.Error "Authentication failed: Invalid API key" - | 429L -> Stdlib.Result.Result.Error "Rate limit exceeded" - | code when code >= 500L -> Stdlib.Result.Result.Error("OpenAI server error: " ++ bodyStr) + | 401I -> Stdlib.Result.Result.Error "Authentication failed: Invalid API key" + | 429I -> Stdlib.Result.Result.Error "Rate limit exceeded" + | code when code >= 500I -> Stdlib.Result.Result.Error("OpenAI server error: " ++ bodyStr) | _ -> match Stdlib.AltJson.parse bodyStr with | Ok (Object fields) -> @@ -866,13 +866,13 @@ let get let bodyStr = Stdlib.String.fromBlobWithReplacement response.body match response.statusCode with - | code when code >= 200L && code < 300L -> + | code when code >= 200I && code < 300I -> match Stdlib.AltJson.parse bodyStr with | Ok json -> parseResponse json | Error e -> Stdlib.Result.Result.Error("Failed to parse response: " ++ e) - | 401L -> Stdlib.Result.Result.Error "Authentication failed: Invalid API key" - | 404L -> Stdlib.Result.Result.Error("Response not found: " ++ responseId) - | 429L -> Stdlib.Result.Result.Error "Rate limit exceeded" + | 401I -> Stdlib.Result.Result.Error "Authentication failed: Invalid API key" + | 404I -> Stdlib.Result.Result.Error("Response not found: " ++ responseId) + | 429I -> Stdlib.Result.Result.Error "Rate limit exceeded" | _ -> Stdlib.Result.Result.Error("API error: " ++ bodyStr) /// Delete a response by ID @@ -892,11 +892,11 @@ let delete let bodyStr = Stdlib.String.fromBlobWithReplacement response.body match response.statusCode with - | code when code >= 200L && code < 300L -> + | code when code >= 200I && code < 300I -> Stdlib.Result.Result.Ok() - | 401L -> Stdlib.Result.Result.Error "Authentication failed: Invalid API key" - | 404L -> Stdlib.Result.Result.Error("Response not found: " ++ responseId) - | 429L -> Stdlib.Result.Result.Error "Rate limit exceeded" + | 401I -> Stdlib.Result.Result.Error "Authentication failed: Invalid API key" + | 404I -> Stdlib.Result.Result.Error("Response not found: " ++ responseId) + | 429I -> Stdlib.Result.Result.Error "Rate limit exceeded" | _ -> Stdlib.Result.Result.Error("API error: " ++ bodyStr) /// Input items response @@ -924,7 +924,7 @@ let listInputItems let bodyStr = Stdlib.String.fromBlobWithReplacement response.body match response.statusCode with - | code when code >= 200L && code < 300L -> + | code when code >= 200I && code < 300I -> match Stdlib.AltJson.parse bodyStr with | Ok (Object fields) -> let object_ = Stdlib.Option.withDefault (Stdlib.AltJson.Helpers.getString "object" fields) "list" @@ -941,9 +941,9 @@ let listInputItems lastId = lastId hasMore = hasMore }) | _ -> Stdlib.Result.Result.Error "Invalid response format" - | 401L -> Stdlib.Result.Result.Error "Authentication failed: Invalid API key" - | 404L -> Stdlib.Result.Result.Error("Response not found: " ++ responseId) - | 429L -> Stdlib.Result.Result.Error "Rate limit exceeded" + | 401I -> Stdlib.Result.Result.Error "Authentication failed: Invalid API key" + | 404I -> Stdlib.Result.Result.Error("Response not found: " ++ responseId) + | 429I -> Stdlib.Result.Result.Error "Rate limit exceeded" | _ -> Stdlib.Result.Result.Error("API error: " ++ bodyStr) diff --git a/packages/feriel/modelContextProtocol/push-notification/tools/ntfy.dark b/packages/feriel/modelContextProtocol/push-notification/tools/ntfy.dark index 3691fded1f..c4c7774a52 100644 --- a/packages/feriel/modelContextProtocol/push-notification/tools/ntfy.dark +++ b/packages/feriel/modelContextProtocol/push-notification/tools/ntfy.dark @@ -12,10 +12,10 @@ let sendNotification (topic: String) (message: String) (title: String) : String match Darklang.Stdlib.HttpClient.post url headers body with | Ok response -> - if response.statusCode == 200L then + if response.statusCode == 200I then "Notification sent successfully to topic: " ++ topic else - "Failed to send notification. Status: " ++ (Darklang.Stdlib.Int64.toString response.statusCode) + "Failed to send notification. Status: " ++ (Darklang.Stdlib.Int.toString response.statusCode) | Error err -> "Error sending notification: " ++ (Darklang.Stdlib.HttpClient.toString err) diff --git a/packages/feriel/modelContextProtocol/push-notification/tools/pushover.dark b/packages/feriel/modelContextProtocol/push-notification/tools/pushover.dark index 13b806bd64..bb0ba7e30e 100644 --- a/packages/feriel/modelContextProtocol/push-notification/tools/pushover.dark +++ b/packages/feriel/modelContextProtocol/push-notification/tools/pushover.dark @@ -18,10 +18,10 @@ let sendNotification (message: String) (title: String) : String = (match Darklang.Stdlib.HttpClient.post url headers body with | Ok response -> - if response.statusCode == 200L then + if response.statusCode == 200I then "Pushover notification sent successfully" else - "Failed to send Pushover notification. Status: " ++ (Darklang.Stdlib.Int64.toString response.statusCode) + "Failed to send Pushover notification. Status: " ++ (Darklang.Stdlib.Int.toString response.statusCode) | Error err -> "Error sending Pushover notification: " ++ (Darklang.Stdlib.HttpClient.toString err)) | None -> diff --git a/packages/stachu/jsoncanvas.dark b/packages/stachu/jsoncanvas.dark index bc8af3e414..9449c55281 100644 --- a/packages/stachu/jsoncanvas.dark +++ b/packages/stachu/jsoncanvas.dark @@ -516,7 +516,7 @@ loadCanvas('example');" module Server = let indexHandler (req: Stdlib.Http.Request) : Stdlib.Http.Response = - Stdlib.Http.responseWithHtml (Viewer.html ()) 200L + Stdlib.Http.responseWithHtml (Viewer.html ()) 200I // Pre-rendered JSON — httpServerServe's executeNamedFn doesn't support // lambdas (e.g. List.map) in the handler call chain, so we inline the @@ -531,13 +531,13 @@ module Server = "{\"nodes\":[{\"id\":\"step1\",\"type\":\"text\",\"x\":50,\"y\":50,\"width\":180,\"height\":80,\"text\":\"Receive Request\"},{\"id\":\"step2\",\"type\":\"text\",\"x\":50,\"y\":180,\"width\":180,\"height\":80,\"text\":\"Parse JSON\"},{\"id\":\"step3\",\"type\":\"text\",\"x\":50,\"y\":310,\"width\":180,\"height\":80,\"text\":\"Validate Data\"},{\"id\":\"step4\",\"type\":\"text\",\"x\":50,\"y\":440,\"width\":180,\"height\":80,\"text\":\"Process & Respond\"},{\"id\":\"error\",\"type\":\"text\",\"x\":300,\"y\":250,\"width\":180,\"height\":80,\"text\":\"Return Error\"}],\"edges\":[{\"id\":\"f1\",\"fromNode\":\"step1\",\"toNode\":\"step2\"},{\"id\":\"f2\",\"fromNode\":\"step2\",\"toNode\":\"step3\"},{\"id\":\"f3\",\"fromNode\":\"step3\",\"toNode\":\"step4\",\"label\":\"valid\"},{\"id\":\"f4\",\"fromNode\":\"step3\",\"toNode\":\"error\",\"label\":\"invalid\"}]}" let exampleHandler (req: Stdlib.Http.Request) : Stdlib.Http.Response = - Stdlib.Http.responseWithJson exampleJson 200L + Stdlib.Http.responseWithJson exampleJson 200I let mindmapHandler (req: Stdlib.Http.Request) : Stdlib.Http.Response = - Stdlib.Http.responseWithJson mindmapJson 200L + Stdlib.Http.responseWithJson mindmapJson 200I let workflowHandler (req: Stdlib.Http.Request) : Stdlib.Http.Response = - Stdlib.Http.responseWithJson workflowJson 200L + Stdlib.Http.responseWithJson workflowJson 200I // Simple path-based routing (no Stdlib.HttpServer.routeRequest because // it uses lambdas internally, which don't work in httpServerServe context) From d80619d9f396184e2e5ad85e1847e587886a11b2 Mon Sep 17 00:00:00 2001 From: OceanOak Date: Wed, 17 Jun 2026 13:59:03 +0000 Subject: [PATCH 16/61] Migrate the AltJson + AI/LLM client stack from Int64 to Int --- .../src/Builtins/Builtins.Pure/Libs/Int.fs | 18 +++ packages/darklang/llm/agent.dark | 8 +- packages/darklang/llm/examples/explainer.dark | 2 +- .../llm/examples/image-describer.dark | 2 +- .../darklang/llm/examples/multi-model.dark | 6 +- packages/darklang/llm/examples/research.dark | 2 +- .../darklang/llm/internal/agent-loop.dark | 2 +- packages/darklang/llm/provider.dark | 44 +++---- .../darklang/llm/providers/anthropic.dark | 10 +- packages/darklang/llm/providers/openai.dark | 4 +- packages/darklang/stdlib/alt-json.dark | 20 +-- packages/darklang/stdlib/int.dark | 4 + packages/darklang/wip/ai/anthropic/batch.dark | 32 ++--- packages/darklang/wip/ai/anthropic/chat.dark | 67 +++++----- .../darklang/wip/ai/anthropic/content.dark | 66 +++++----- .../wip/ai/anthropic/integration-tests.dark | 120 +++++++++--------- .../darklang/wip/ai/anthropic/response.dark | 46 +++---- packages/darklang/wip/ai/anthropic/tools.dark | 60 ++++----- packages/darklang/wip/ai/openai/audio.dark | 26 ++-- packages/darklang/wip/ai/openai/chat.dark | 62 ++++----- .../darklang/wip/ai/openai/embeddings.dark | 26 ++-- packages/darklang/wip/ai/openai/images.dark | 46 +++---- .../darklang/wip/ai/openai/responses.dark | 34 ++--- .../darklang/wip/ai/openai/web-search.dark | 12 +- 24 files changed, 377 insertions(+), 342 deletions(-) diff --git a/backend/src/Builtins/Builtins.Pure/Libs/Int.fs b/backend/src/Builtins/Builtins.Pure/Libs/Int.fs index dabd438f2f..57eeef0d52 100644 --- a/backend/src/Builtins/Builtins.Pure/Libs/Int.fs +++ b/backend/src/Builtins/Builtins.Pure/Libs/Int.fs @@ -330,6 +330,24 @@ let fns () : List = deprecated = NotDeprecated } + { name = fn "intFromFloat" 0 + typeParams = [] + parameters = [ Param.make "a" TFloat "" ] + returnType = TInt + description = + "Converts a to an , truncating toward zero. + Unlike going via Int64, this preserves the full integer part of the + float (no 64-bit clamp)." + fn = + (function + | _, _, _, [ DFloat f ] -> Ply(Dval.int (bigint f)) + | _ -> incorrectArgs ()) + sqlSpec = NotQueryable + previewable = Pure + capabilities = LibExecution.Capabilities.noCaps + deprecated = NotDeprecated } + + { name = fn "intParse" 0 typeParams = [] parameters = [ Param.make "s" TString "" ] diff --git a/packages/darklang/llm/agent.dark b/packages/darklang/llm/agent.dark index 0073aa1f9e..67ab5b57ac 100644 --- a/packages/darklang/llm/agent.dark +++ b/packages/darklang/llm/agent.dark @@ -24,7 +24,7 @@ /// // Anthropic-specific features /// Agent.create () /// |> Agent.withModel Models.Anthropic.opus46 -/// |> Agent.withThinking 8000L +/// |> Agent.withThinking 8000I /// |> Agent.withWebSearch /// |> Agent.run "Research this topic..." /// @@ -215,7 +215,7 @@ let withParallelTools (agent: Agent) : Agent = // ANTHROPIC-SPECIFIC: EXTENDED THINKING /// Enable extended thinking with a token budget (Anthropic only) -let withThinking (agent: Agent) (budgetTokens: Int64) : Agent = +let withThinking (agent: Agent) (budgetTokens: Int) : Agent = { agent with thinking = Stdlib.Option.Option.Some(Darklang.LLM.Provider.ThinkingConfig.Enabled budgetTokens) } @@ -246,7 +246,7 @@ let withWebSearchDomains (agent: Agent) (domains: List) : Agent = allowedDomains = Stdlib.Option.Option.Some domains }) } /// Enable web search with a maximum number of searches (Anthropic only) -let withWebSearchLimit (agent: Agent) (maxUses: Int64) : Agent = +let withWebSearchLimit (agent: Agent) (maxUses: Int) : Agent = { agent with webSearch = Stdlib.Option.Option.Some( @@ -513,7 +513,7 @@ let askWith (model: Model) (question: String) : Stdlib.Result.Result = (create ()) |> withThinking budgetTokens |> run question diff --git a/packages/darklang/llm/examples/explainer.dark b/packages/darklang/llm/examples/explainer.dark index d94f0e18cf..c043dce158 100644 --- a/packages/darklang/llm/examples/explainer.dark +++ b/packages/darklang/llm/examples/explainer.dark @@ -13,7 +13,7 @@ Format: ## Concept → ### Core Idea → ### How It Works → ### Example → ## let thinkingAgent = (Darklang.LLM.Agent.create ()) |> Darklang.LLM.Agent.withSystemPrompt systemPrompt - |> Darklang.LLM.Agent.withThinking 2000L + |> Darklang.LLM.Agent.withThinking 2000I |> Darklang.LLM.Agent.withMaxTokens 4000L diff --git a/packages/darklang/llm/examples/image-describer.dark b/packages/darklang/llm/examples/image-describer.dark index ab4e0db884..6546e0dbcc 100644 --- a/packages/darklang/llm/examples/image-describer.dark +++ b/packages/darklang/llm/examples/image-describer.dark @@ -24,7 +24,7 @@ let sendImageRequest let request = (Darklang.WIP.AI.Anthropic.Chat.Request.create ()) |> Darklang.WIP.AI.Anthropic.Chat.Request.withModelString Darklang.LLM.Models.Anthropic.sonnet45.id - |> Darklang.WIP.AI.Anthropic.Chat.Request.withMaxTokens 500L + |> Darklang.WIP.AI.Anthropic.Chat.Request.withMaxTokens 500I |> Darklang.WIP.AI.Anthropic.Chat.Request.withBlockMessages [ userMessage ] let request = diff --git a/packages/darklang/llm/examples/multi-model.dark b/packages/darklang/llm/examples/multi-model.dark index 1a8648aacc..cb3c7a8f41 100644 --- a/packages/darklang/llm/examples/multi-model.dark +++ b/packages/darklang/llm/examples/multi-model.dark @@ -8,8 +8,8 @@ module Darklang.LLM.Examples.MultiModel type ModelResponse = { model: String response: String - inputTokens: Int64 - outputTokens: Int64 } + inputTokens: Int + outputTokens: Int } /// Ask a single model and get response with stats @@ -36,7 +36,7 @@ let askModel /// Format a model result for display let formatResult (name: String) (result: Stdlib.Result.Result) : String = match result with - | Ok r -> $"## {name} ({r.model})\n{r.response}\n\n*Tokens: {Stdlib.Int64.toString r.inputTokens} in / {Stdlib.Int64.toString r.outputTokens} out*" + | Ok r -> $"## {name} ({r.model})\n{r.response}\n\n*Tokens: {Stdlib.Int.toString r.inputTokens} in / {Stdlib.Int.toString r.outputTokens} out*" | Error e -> $"## {name}\nError: {e}" diff --git a/packages/darklang/llm/examples/research.dark b/packages/darklang/llm/examples/research.dark index 9bb8b688a7..1da9dc5ce5 100644 --- a/packages/darklang/llm/examples/research.dark +++ b/packages/darklang/llm/examples/research.dark @@ -16,7 +16,7 @@ let agent = |> Darklang.LLM.Agent.useSonnet |> Darklang.LLM.Agent.withWebSearch |> Darklang.LLM.Agent.withWebFetchCitations - |> Darklang.LLM.Agent.withThinking 4000L + |> Darklang.LLM.Agent.withThinking 4000I |> Darklang.LLM.Agent.withMaxTokens 8000L |> Darklang.LLM.Agent.withMaxTurns 3L diff --git a/packages/darklang/llm/internal/agent-loop.dark b/packages/darklang/llm/internal/agent-loop.dark index f5e6705956..840f22a1b5 100644 --- a/packages/darklang/llm/internal/agent-loop.dark +++ b/packages/darklang/llm/internal/agent-loop.dark @@ -161,7 +161,7 @@ let buildRequest (config: AgentConfig) (state: LoopState) : Provider.Request = (Provider.createRequest config.model.id) |> Provider.withMessages state.messages |> Provider.withTools toolSchemas - |> Provider.withMaxTokens config.maxTokens + |> Provider.withMaxTokens (Stdlib.Int.fromInt64 config.maxTokens) let request = match config.systemPrompt with diff --git a/packages/darklang/llm/provider.dark b/packages/darklang/llm/provider.dark index 3a55ced9bc..56bb586d96 100644 --- a/packages/darklang/llm/provider.dark +++ b/packages/darklang/llm/provider.dark @@ -218,7 +218,7 @@ type Request = messages: List systemPrompt: Stdlib.Option.Option tools: List - maxTokens: Int64 + maxTokens: Int temperature: Stdlib.Option.Option stopSequences: List } @@ -229,7 +229,7 @@ let createRequest (model: String) : Request = messages = [] systemPrompt = Stdlib.Option.Option.None tools = [] - maxTokens = 4096L + maxTokens = 4096I temperature = Stdlib.Option.Option.None stopSequences = [] } @@ -246,7 +246,7 @@ let withTools (req: Request) (tools: List) : Request = { req with tools = tools } /// Set max tokens for a request -let withMaxTokens (req: Request) (tokens: Int64) : Request = +let withMaxTokens (req: Request) (tokens: Int) : Request = { req with maxTokens = tokens } /// Set temperature for a request @@ -289,19 +289,19 @@ module StopReason = /// Token usage information type Usage = - { inputTokens: Int64 - outputTokens: Int64 + { inputTokens: Int + outputTokens: Int /// Tokens used to create prompt cache (Anthropic) - cacheCreationTokens: Int64 + cacheCreationTokens: Int /// Tokens read from prompt cache (Anthropic) - cacheReadTokens: Int64 } + cacheReadTokens: Int } let emptyUsage : Usage = Usage - { inputTokens = 0L - outputTokens = 0L - cacheCreationTokens = 0L - cacheReadTokens = 0L } + { inputTokens = 0I + outputTokens = 0I + cacheCreationTokens = 0I + cacheReadTokens = 0I } let addUsage (a: Usage) (b: Usage) : Usage = Usage @@ -362,7 +362,7 @@ type Capabilities = supportsStreaming: Bool supportsSystemPrompt: Bool supportsImages: Bool - maxContextTokens: Int64 } + maxContextTokens: Int } // PROVIDER INTERFACE @@ -397,15 +397,15 @@ type Provider = /// NOTE: Retries happen immediately (no backoff delay). /// When a sleep builtin is available, delay fields can be added. type RetryConfig = - { maxRetries: Int64 } + { maxRetries: Int } /// Default retry configuration (3 retries, no delay) let defaultRetryConfig : RetryConfig = - RetryConfig { maxRetries = 3L } + RetryConfig { maxRetries = 3I } /// Retry state for tracking attempts type RetryState<'a> = - { attempt: Int64 + { attempt: Int lastError: Stdlib.Option.Option result: Stdlib.Option.Option> isDone: Bool } @@ -435,7 +435,7 @@ let doRetryAttempt | Error e -> if ProviderError.isRetryable e then { state with - attempt = state.attempt + 1L + attempt = state.attempt + 1I lastError = Stdlib.Option.Option.Some e } else { state with @@ -465,7 +465,7 @@ let retry : Stdlib.Result.Result<'a, ProviderError> = let initialState = RetryState - { attempt = 0L + { attempt = 0I lastError = Stdlib.Option.Option.None result = Stdlib.Option.Option.None isDone = false } @@ -492,12 +492,12 @@ type ToolChoice = /// Thinking configuration type ThinkingConfig = | Disabled - | Enabled of budgetTokens: Int64 + | Enabled of budgetTokens: Int | Adaptive // Let the model decide (Anthropic Opus 4.6+) /// Web search configuration type WebSearchConfig = - { maxUses: Stdlib.Option.Option + { maxUses: Stdlib.Option.Option allowedDomains: Stdlib.Option.Option> blockedDomains: Stdlib.Option.Option> } @@ -509,7 +509,7 @@ let defaultWebSearch : WebSearchConfig = /// Web fetch configuration type WebFetchConfig = - { maxUses: Stdlib.Option.Option + { maxUses: Stdlib.Option.Option allowedDomains: Stdlib.Option.Option> blockedDomains: Stdlib.Option.Option> enableCitations: Bool } @@ -583,8 +583,8 @@ type Citation = url: Stdlib.Option.Option title: Stdlib.Option.Option citedText: Stdlib.Option.Option - startIndex: Stdlib.Option.Option - endIndex: Stdlib.Option.Option } + startIndex: Stdlib.Option.Option + endIndex: Stdlib.Option.Option } /// Extended response with provider-specific data type ResponseExtended = diff --git a/packages/darklang/llm/providers/anthropic.dark b/packages/darklang/llm/providers/anthropic.dark index b6d902ea69..d865085b7b 100644 --- a/packages/darklang/llm/providers/anthropic.dark +++ b/packages/darklang/llm/providers/anthropic.dark @@ -270,7 +270,7 @@ let thinkingConfigToJson (config: Provider.ThinkingConfig) : Json = | Enabled budgetTokens -> Json.Object [ ("type", Json.String "enabled") - ("budget_tokens", Json.Number(Stdlib.Int64.toFloat budgetTokens)) ] + ("budget_tokens", Json.Number(Stdlib.Int.toFloat budgetTokens)) ] | Adaptive -> Json.Object [ ("type", Json.String "adaptive") ] @@ -279,13 +279,13 @@ let thinkingConfigToJson (config: Provider.ThinkingConfig) : Json = /// Shared by web_search and web_fetch config builders let buildDomainConstraints (baseFields: List<(String * Json)>) - (maxUses: Stdlib.Option.Option) + (maxUses: Stdlib.Option.Option) (allowedDomains: Stdlib.Option.Option>) (blockedDomains: Stdlib.Option.Option>) : List<(String * Json)> = let withMaxUses = match maxUses with - | Some n -> Stdlib.List.append baseFields [ ("max_uses", Json.Number(Stdlib.Int64.toFloat n)) ] + | Some n -> Stdlib.List.append baseFields [ ("max_uses", Json.Number(Stdlib.Int.toFloat n)) ] | None -> baseFields let withAllowed = @@ -509,11 +509,11 @@ let extractCitationsFromBlock (fields: List<(String * Json)>) : List Stdlib.Option.Option.None) diff --git a/packages/darklang/llm/providers/openai.dark b/packages/darklang/llm/providers/openai.dark index 101ad8a2e0..441dc7f67c 100644 --- a/packages/darklang/llm/providers/openai.dark +++ b/packages/darklang/llm/providers/openai.dark @@ -296,7 +296,7 @@ let extractUsage (fields: List<(String * Json)>) : Provider.Usage = Provider.Usage { inputTokens = promptTokens outputTokens = completionTokens - cacheCreationTokens = 0L // OpenAI doesn't track cache creation separately + cacheCreationTokens = 0I // OpenAI doesn't track cache creation separately cacheReadTokens = cachedTokens } @@ -381,7 +381,7 @@ let buildExtendedRequest let baseFields = [ ("model", Json.String req.model) - ("max_tokens", Json.Number (Stdlib.Int64.toFloat req.maxTokens)) + ("max_tokens", Json.Number (Stdlib.Int.toFloat req.maxTokens)) ("messages", Json.Array messages) ] // Add tools if present, with parallel_tool_calls control diff --git a/packages/darklang/stdlib/alt-json.dark b/packages/darklang/stdlib/alt-json.dark index 494cc71e43..8f8f6f21d9 100644 --- a/packages/darklang/stdlib/alt-json.dark +++ b/packages/darklang/stdlib/alt-json.dark @@ -74,28 +74,28 @@ module Helpers = /// Get an integer value from a JSON object's fields (returns 0 if not found) - let getInt (key: String) (fields: List<(String * Json)>) : Int64 = + let getInt (key: String) (fields: List<(String * Json)>) : Int = let found = List.findFirst fields (fun (k, _) -> k == key) match found with | Some pair -> match Tuple2.second pair with - | Number n -> Int64.fromFloat n - | _ -> 0L - | None -> 0L + | Number n -> Int.fromFloat n + | _ -> 0I + | None -> 0I /// Get an optional integer value from a JSON object's fields let getIntOption (key: String) (fields: List<(String * Json)>) - : Option.Option = + : Option.Option = let found = List.findFirst fields (fun (k, _) -> k == key) match found with | Some pair -> match Tuple2.second pair with - | Number n -> Option.Option.Some(Int64.fromFloat n) + | Number n -> Option.Option.Some(Int.fromFloat n) | _ -> Option.Option.None | None -> Option.Option.None @@ -163,8 +163,8 @@ module Builder = List.append fields [ (key, Json.Number value) ] /// Add a required int field (converts to float for JSON) - let addInt (fields: Fields) (key: String) (value: Int64) : Fields = - List.append fields [ (key, Json.Number (Int64.toFloat value)) ] + let addInt (fields: Fields) (key: String) (value: Int) : Fields = + List.append fields [ (key, Json.Number (Int.toFloat value)) ] /// Add a required bool field let addBool (fields: Fields) (key: String) (value: Bool) : Fields = @@ -202,10 +202,10 @@ module Builder = let addOptionalInt (fields: Fields) (key: String) - (value: Option.Option) + (value: Option.Option) : Fields = match value with - | Some v -> List.append fields [ (key, Json.Number (Int64.toFloat v)) ] + | Some v -> List.append fields [ (key, Json.Number (Int.toFloat v)) ] | None -> fields /// Add an optional bool field (only adds if Some) diff --git a/packages/darklang/stdlib/int.dark b/packages/darklang/stdlib/int.dark index d10f5ba20e..58036bff06 100644 --- a/packages/darklang/stdlib/int.dark +++ b/packages/darklang/stdlib/int.dark @@ -83,6 +83,10 @@ let sqrt (a: Int) : Float = Builtin.intSqrt a let toFloat (a: Int) : Float = Builtin.intToFloat a +/// Converts a to an , truncating toward zero. +let fromFloat (a: Float) : Int = Builtin.intFromFloat a + + /// Returns the sum of all the ints in the list let sum (lst: List) : Int = Stdlib.List.fold lst 0I (fun acc x -> add acc x) diff --git a/packages/darklang/wip/ai/anthropic/batch.dark b/packages/darklang/wip/ai/anthropic/batch.dark index 9591010467..a8c6c5553c 100644 --- a/packages/darklang/wip/ai/anthropic/batch.dark +++ b/packages/darklang/wip/ai/anthropic/batch.dark @@ -78,11 +78,11 @@ module BatchResultType = // --------------------------------------------------------------------------- type BatchRequestCounts = - { processing: Int64 - succeeded: Int64 - errored: Int64 - canceled: Int64 - expired: Int64 } + { processing: Int + succeeded: Int + errored: Int + canceled: Int + expired: Int } // --------------------------------------------------------------------------- @@ -297,7 +297,7 @@ let handleBatchResponse | Ok r -> let bodyStr = Stdlib.String.fromBlobWithReplacement r.body - if r.statusCode == 200L || r.statusCode == 201L then + if r.statusCode == 200I || r.statusCode == 201I then match Stdlib.AltJson.parse bodyStr with | Ok json -> match parseMessageBatch json with @@ -317,7 +317,7 @@ let handleListResponse | Ok r -> let bodyStr = Stdlib.String.fromBlobWithReplacement r.body - if r.statusCode == 200L then + if r.statusCode == 200I then match Stdlib.AltJson.parse bodyStr with | Ok json -> match parseBatchListResponse json with @@ -364,7 +364,7 @@ let retrieveBatch /// Returns paginated results; use after_id for pagination let listBatches (apiKey: String) - (limit: Stdlib.Option.Option) + (limit: Stdlib.Option.Option) (afterId: Stdlib.Option.Option) : Stdlib.Result.Result = let headers = Models.getHeaders apiKey @@ -374,7 +374,7 @@ let listBatches [] |> (fun params -> match limit with - | Some l -> Stdlib.List.append params [ ("limit", Stdlib.Int64.toString l) ] + | Some l -> Stdlib.List.append params [ ("limit", Stdlib.Int.toString l) ] | None -> params) |> (fun params -> match afterId with @@ -422,7 +422,7 @@ let getBatchResults | Ok r -> let bodyStr = Stdlib.String.fromBlobWithReplacement r.body - if r.statusCode == 200L then + if r.statusCode == 200I then // Results are in JSONL format (newline-delimited JSON) let allLines = Stdlib.String.splitOnNewline bodyStr let lines = Stdlib.List.filter allLines (fun line -> Stdlib.Bool.not (Stdlib.String.isEmpty line)) @@ -455,7 +455,7 @@ let getBatchResultsFromUrl | Ok r -> let bodyStr = Stdlib.String.fromBlobWithReplacement r.body - if r.statusCode == 200L then + if r.statusCode == 200I then // Results are in JSONL format (newline-delimited JSON) let allLines = Stdlib.String.splitOnNewline bodyStr let lines = Stdlib.List.filter allLines (fun line -> Stdlib.Bool.not (Stdlib.String.isEmpty line)) @@ -493,13 +493,13 @@ let isCanceling (batch: MessageBatch) : Bool = batch.processing_status == BatchProcessingStatus.Canceling /// Get the total number of requests in a batch -let totalRequests (batch: MessageBatch) : Int64 = +let totalRequests (batch: MessageBatch) : Int = let counts = batch.request_counts counts.processing - |> Stdlib.Int64.add counts.succeeded - |> Stdlib.Int64.add counts.errored - |> Stdlib.Int64.add counts.canceled - |> Stdlib.Int64.add counts.expired + + counts.succeeded + + counts.errored + + counts.canceled + + counts.expired /// Get only the successful results from a batch results list let getSuccessfulResults diff --git a/packages/darklang/wip/ai/anthropic/chat.dark b/packages/darklang/wip/ai/anthropic/chat.dark index e627515037..123b796d1a 100644 --- a/packages/darklang/wip/ai/anthropic/chat.dark +++ b/packages/darklang/wip/ai/anthropic/chat.dark @@ -68,9 +68,9 @@ module ThinkingType = type ThinkingConfig = { ``type``: ThinkingType - budget_tokens: Stdlib.Option.Option } + budget_tokens: Stdlib.Option.Option } -let thinkingEnabled (budgetTokens: Int64) : ThinkingConfig = +let thinkingEnabled (budgetTokens: Int) : ThinkingConfig = ThinkingConfig { ``type`` = ThinkingType.Enabled budget_tokens = Stdlib.Option.Option.Some budgetTokens } @@ -156,14 +156,14 @@ let metadata (userId: String) : Metadata = type SimpleRequest = { model: String - max_tokens: Int64 + max_tokens: Int system: Stdlib.Option.Option messages: List tools: Stdlib.Option.Option> tool_choice: Stdlib.Option.Option temperature: Stdlib.Option.Option top_p: Stdlib.Option.Option - top_k: Stdlib.Option.Option + top_k: Stdlib.Option.Option stop_sequences: Stdlib.Option.Option> stream: Stdlib.Option.Option thinking: Stdlib.Option.Option @@ -174,14 +174,14 @@ type SimpleRequest = type BlockRequest = { model: String - max_tokens: Int64 + max_tokens: Int system: Stdlib.Option.Option> messages: List tools: Stdlib.Option.Option> tool_choice: Stdlib.Option.Option temperature: Stdlib.Option.Option top_p: Stdlib.Option.Option - top_k: Stdlib.Option.Option + top_k: Stdlib.Option.Option stop_sequences: Stdlib.Option.Option> stream: Stdlib.Option.Option thinking: Stdlib.Option.Option @@ -270,31 +270,36 @@ let parseResponse (json: Json) : Stdlib.Result.Result | Object fields -> let usageFields = JsonHelpers.getObject "usage" fields - let cacheCreation = JsonHelpers.getInt "cache_creation_input_tokens" usageFields - let cacheRead = JsonHelpers.getInt "cache_read_input_tokens" usageFields + let cacheCreation = + JsonHelpers.getInt "cache_creation_input_tokens" usageFields + let cacheRead = + JsonHelpers.getInt "cache_read_input_tokens" usageFields // Parse nested cache_creation object let cacheCreationObj = JsonHelpers.getObject "cache_creation" usageFields let cacheCreationUsage = - let e5m = JsonHelpers.getInt "ephemeral_5m_input_tokens" cacheCreationObj - let e1h = JsonHelpers.getInt "ephemeral_1h_input_tokens" cacheCreationObj - if e5m == 0L && e1h == 0L then + let e5m = + JsonHelpers.getInt "ephemeral_5m_input_tokens" cacheCreationObj + let e1h = + JsonHelpers.getInt "ephemeral_1h_input_tokens" cacheCreationObj + if e5m == 0I && e1h == 0I then Stdlib.Option.Option.None else Stdlib.Option.Option.Some( Response.CacheCreationUsage { ephemeral_5m_input_tokens = - if e5m == 0L then Stdlib.Option.Option.None + if e5m == 0I then Stdlib.Option.Option.None else Stdlib.Option.Option.Some e5m ephemeral_1h_input_tokens = - if e1h == 0L then Stdlib.Option.Option.None + if e1h == 0I then Stdlib.Option.Option.None else Stdlib.Option.Option.Some e1h }) // Parse nested server_tool_use object let serverToolObj = JsonHelpers.getObject "server_tool_use" usageFields let serverToolUsage = - let webSearchReqs = JsonHelpers.getInt "web_search_requests" serverToolObj - if webSearchReqs == 0L then + let webSearchReqs = + JsonHelpers.getInt "web_search_requests" serverToolObj + if webSearchReqs == 0I then Stdlib.Option.Option.None else Stdlib.Option.Option.Some( @@ -306,12 +311,12 @@ let parseResponse (json: Json) : Stdlib.Result.Result { input_tokens = JsonHelpers.getInt "input_tokens" usageFields output_tokens = JsonHelpers.getInt "output_tokens" usageFields cache_creation_input_tokens = - if cacheCreation == 0L then + if cacheCreation == 0I then Stdlib.Option.Option.None else Stdlib.Option.Option.Some cacheCreation cache_read_input_tokens = - if cacheRead == 0L then + if cacheRead == 0I then Stdlib.Option.Option.None else Stdlib.Option.Option.Some cacheRead @@ -365,7 +370,7 @@ let handleResponse | Ok r -> let bodyStr = Stdlib.String.fromBlobWithReplacement r.body - if r.statusCode == 200L then + if r.statusCode == 200I then match Stdlib.AltJson.parse bodyStr with | Ok json -> match parseResponse json with @@ -397,14 +402,14 @@ type SystemContent = /// Request configuration with sensible defaults type Request = { model: Models.Model - maxTokens: Int64 + maxTokens: Int messages: MessageContent system: Stdlib.Option.Option tools: Stdlib.Option.Option> toolChoice: Stdlib.Option.Option temperature: Stdlib.Option.Option topP: Stdlib.Option.Option - topK: Stdlib.Option.Option + topK: Stdlib.Option.Option stopSequences: Stdlib.Option.Option> thinking: Stdlib.Option.Option metadata: Stdlib.Option.Option @@ -417,7 +422,7 @@ module Request = let create () : Request = Request { model = Models.Model.latest - maxTokens = 4096L + maxTokens = 4096I messages = MessageContent.Simple [] system = Stdlib.Option.Option.None tools = Stdlib.Option.Option.None @@ -441,7 +446,7 @@ module Request = { req with model = Models.Model.Custom model } /// Set max tokens - let withMaxTokens (req: Request) (tokens: Int64) : Request = + let withMaxTokens (req: Request) (tokens: Int) : Request = { req with maxTokens = tokens } /// Set simple text messages @@ -490,7 +495,7 @@ module Request = { req with topP = Stdlib.Option.Option.Some p } /// Set top_k - let withTopK (req: Request) (k: Int64) : Request = + let withTopK (req: Request) (k: Int) : Request = { req with topK = Stdlib.Option.Option.Some k } /// Set stop sequences @@ -498,7 +503,7 @@ module Request = { req with stopSequences = Stdlib.Option.Option.Some seqs } /// Enable thinking with a budget - let withThinking (req: Request) (budgetTokens: Int64) : Request = + let withThinking (req: Request) (budgetTokens: Int) : Request = { req with thinking = Stdlib.Option.Option.Some(thinkingEnabled budgetTokens) } /// Enable adaptive thinking (for Opus 4.6) @@ -736,9 +741,9 @@ let promptWithSystem // --------------------------------------------------------------------------- type TokenCountResult = - { input_tokens: Int64 - cache_creation_input_tokens: Int64 - cache_read_input_tokens: Int64 } + { input_tokens: Int + cache_creation_input_tokens: Int + cache_read_input_tokens: Int } let parseTokenCountResponse (json: Json) @@ -748,8 +753,10 @@ let parseTokenCountResponse Stdlib.Result.Result.Ok( TokenCountResult { input_tokens = JsonHelpers.getInt "input_tokens" fields - cache_creation_input_tokens = JsonHelpers.getInt "cache_creation_input_tokens" fields - cache_read_input_tokens = JsonHelpers.getInt "cache_read_input_tokens" fields }) + cache_creation_input_tokens = + JsonHelpers.getInt "cache_creation_input_tokens" fields + cache_read_input_tokens = + JsonHelpers.getInt "cache_read_input_tokens" fields }) | _ -> Stdlib.Result.Result.Error "Invalid token count response format" /// Count tokens for a request without sending it @@ -768,7 +775,7 @@ let countTokens | Ok r -> let bodyStr = Stdlib.String.fromBlobWithReplacement r.body - if r.statusCode == 200L then + if r.statusCode == 200I then match Stdlib.AltJson.parse bodyStr with | Ok json -> match parseTokenCountResponse json with diff --git a/packages/darklang/wip/ai/anthropic/content.dark b/packages/darklang/wip/ai/anthropic/content.dark index 3f4674b40f..6bdcd64b70 100644 --- a/packages/darklang/wip/ai/anthropic/content.dark +++ b/packages/darklang/wip/ai/anthropic/content.dark @@ -241,22 +241,22 @@ type Citation = { ``type``: CitationType cited_text: String // For char_location - document_index: Stdlib.Option.Option + document_index: Stdlib.Option.Option document_title: Stdlib.Option.Option - start_char_index: Stdlib.Option.Option - end_char_index: Stdlib.Option.Option + start_char_index: Stdlib.Option.Option + end_char_index: Stdlib.Option.Option // For page_location - start_page_number: Stdlib.Option.Option - end_page_number: Stdlib.Option.Option + start_page_number: Stdlib.Option.Option + end_page_number: Stdlib.Option.Option // For content_block_location and search_result_location - start_block_index: Stdlib.Option.Option - end_block_index: Stdlib.Option.Option + start_block_index: Stdlib.Option.Option + end_block_index: Stdlib.Option.Option // For web_search_result_location encrypted_index: Stdlib.Option.Option url: Stdlib.Option.Option title: Stdlib.Option.Option // For search_result_location - search_result_index: Stdlib.Option.Option + search_result_index: Stdlib.Option.Option source: Stdlib.Option.Option // For output citations (response from API) file_id: Stdlib.Option.Option } @@ -305,21 +305,21 @@ type ContentBlock = stdout: Stdlib.Option.Option stderr: Stdlib.Option.Option encrypted_stdout: Stdlib.Option.Option // For PFC + web_search results - return_code: Stdlib.Option.Option + return_code: Stdlib.Option.Option // Code execution output / container upload file_id: Stdlib.Option.Option // Web fetch result fields retrieved_at: Stdlib.Option.Option // ISO 8601 timestamp // Text editor result fields file_type: Stdlib.Option.Option // "text" | "image" | "pdf" - start_line: Stdlib.Option.Option - num_lines: Stdlib.Option.Option - total_lines: Stdlib.Option.Option + start_line: Stdlib.Option.Option + num_lines: Stdlib.Option.Option + total_lines: Stdlib.Option.Option is_file_update: Stdlib.Option.Option - old_start: Stdlib.Option.Option - old_lines: Stdlib.Option.Option - new_start: Stdlib.Option.Option - new_lines: Stdlib.Option.Option + old_start: Stdlib.Option.Option + old_lines: Stdlib.Option.Option + new_start: Stdlib.Option.Option + new_lines: Stdlib.Option.Option lines: Stdlib.Option.Option> // Tool search result fields tool_references: Stdlib.Option.Option> @@ -331,10 +331,10 @@ type ContentBlock = let citationCharLocation (citedText: String) - (docIndex: Int64) + (docIndex: Int) (docTitle: String) - (startChar: Int64) - (endChar: Int64) + (startChar: Int) + (endChar: Int) : Citation = Citation { ``type`` = CitationType.CharLocation @@ -356,10 +356,10 @@ let citationCharLocation let citationPageLocation (citedText: String) - (docIndex: Int64) + (docIndex: Int) (docTitle: String) - (startPage: Int64) - (endPage: Int64) + (startPage: Int) + (endPage: Int) : Citation = Citation { ``type`` = CitationType.PageLocation @@ -405,8 +405,8 @@ let citationWebSearchResult let citationContentBlockLocation (citedText: String) - (startBlockIndex: Int64) - (endBlockIndex: Int64) + (startBlockIndex: Int) + (endBlockIndex: Int) : Citation = Citation { ``type`` = CitationType.ContentBlockLocation @@ -428,7 +428,7 @@ let citationContentBlockLocation let citationSearchResultLocation (citedText: String) - (searchResultIndex: Int64) + (searchResultIndex: Int) (resultSource: String) : Citation = Citation @@ -1981,7 +1981,7 @@ let contentBlockToJson (block: ContentBlock) : Json = let withReturnCode = match block.return_code with - | Some rc -> Stdlib.List.append withEncryptedStdout [ ("return_code", Json.Number (Stdlib.Int64.toFloat rc)) ] + | Some rc -> Stdlib.List.append withEncryptedStdout [ ("return_code", Json.Number (Stdlib.Int.toFloat rc)) ] | None -> withEncryptedStdout let withFileId = @@ -2001,17 +2001,17 @@ let contentBlockToJson (block: ContentBlock) : Json = let withStartLine = match block.start_line with - | Some sl -> Stdlib.List.append withFileType [ ("start_line", Json.Number (Stdlib.Int64.toFloat sl)) ] + | Some sl -> Stdlib.List.append withFileType [ ("start_line", Json.Number (Stdlib.Int.toFloat sl)) ] | None -> withFileType let withNumLines = match block.num_lines with - | Some nl -> Stdlib.List.append withStartLine [ ("num_lines", Json.Number (Stdlib.Int64.toFloat nl)) ] + | Some nl -> Stdlib.List.append withStartLine [ ("num_lines", Json.Number (Stdlib.Int.toFloat nl)) ] | None -> withStartLine let withTotalLines = match block.total_lines with - | Some tl -> Stdlib.List.append withNumLines [ ("total_lines", Json.Number (Stdlib.Int64.toFloat tl)) ] + | Some tl -> Stdlib.List.append withNumLines [ ("total_lines", Json.Number (Stdlib.Int.toFloat tl)) ] | None -> withNumLines let withIsFileUpdate = @@ -2021,22 +2021,22 @@ let contentBlockToJson (block: ContentBlock) : Json = let withOldStart = match block.old_start with - | Some os -> Stdlib.List.append withIsFileUpdate [ ("old_start", Json.Number (Stdlib.Int64.toFloat os)) ] + | Some os -> Stdlib.List.append withIsFileUpdate [ ("old_start", Json.Number (Stdlib.Int.toFloat os)) ] | None -> withIsFileUpdate let withOldLines = match block.old_lines with - | Some ol -> Stdlib.List.append withOldStart [ ("old_lines", Json.Number (Stdlib.Int64.toFloat ol)) ] + | Some ol -> Stdlib.List.append withOldStart [ ("old_lines", Json.Number (Stdlib.Int.toFloat ol)) ] | None -> withOldStart let withNewStart = match block.new_start with - | Some ns -> Stdlib.List.append withOldLines [ ("new_start", Json.Number (Stdlib.Int64.toFloat ns)) ] + | Some ns -> Stdlib.List.append withOldLines [ ("new_start", Json.Number (Stdlib.Int.toFloat ns)) ] | None -> withOldLines let withNewLines = match block.new_lines with - | Some nl -> Stdlib.List.append withNewStart [ ("new_lines", Json.Number (Stdlib.Int64.toFloat nl)) ] + | Some nl -> Stdlib.List.append withNewStart [ ("new_lines", Json.Number (Stdlib.Int.toFloat nl)) ] | None -> withNewStart let withLines = diff --git a/packages/darklang/wip/ai/anthropic/integration-tests.dark b/packages/darklang/wip/ai/anthropic/integration-tests.dark index 5af7e78a21..2a02bf0ad3 100644 --- a/packages/darklang/wip/ai/anthropic/integration-tests.dark +++ b/packages/darklang/wip/ai/anthropic/integration-tests.dark @@ -40,7 +40,7 @@ module DirectApiTests = let req = (Chat.Request.create ()) |> Chat.Request.withModel Models.Model.Haiku35 - |> Chat.Request.withMaxTokens 50L + |> Chat.Request.withMaxTokens 50I |> Chat.Request.withUserMessage "Say 'test passed'" match Chat.Request.send apiKey req with @@ -61,7 +61,7 @@ module DirectApiTests = let req = (Chat.Request.create ()) |> Chat.Request.withModel Models.Model.Haiku35 - |> Chat.Request.withMaxTokens 50L + |> Chat.Request.withMaxTokens 50I |> Chat.Request.withUserMessage "Reply with: hello" match Chat.Request.send apiKey req with @@ -70,7 +70,7 @@ module DirectApiTests = match Response.getStopReason response with | Some _ -> true | None -> false - let hasUsage = response.usage.input_tokens > 0L + let hasUsage = response.usage.input_tokens > 0I let isComplete = Response.isComplete response if hasStopReason && hasUsage && isComplete then @@ -102,7 +102,7 @@ module TokenCountingTests = match Chat.countTokens apiKey req with | Ok result -> - if result.input_tokens > 0L then + if result.input_tokens > 0I then TestResult.Pass else TestResult.Fail $"Expected positive token count, got {result.input_tokens}" @@ -116,7 +116,7 @@ module TokenCountingTests = | Some apiKey -> match Chat.countTokensForPrompt apiKey "What is 2+2?" with | Ok result -> - if result.input_tokens > 0L then + if result.input_tokens > 0I then TestResult.Pass else TestResult.Fail "Expected positive token count" @@ -173,7 +173,7 @@ module JsonSchemaTests = let req = (Chat.Request.create ()) |> Chat.Request.withModel Models.Model.Sonnet45 - |> Chat.Request.withMaxTokens 200L + |> Chat.Request.withMaxTokens 200I |> Chat.Request.withJsonSchema schema |> Chat.Request.withUserMessage "Generate a JSON object for a person named Alice who is 30 years old." @@ -206,7 +206,7 @@ module StopSequenceTests = let req = (Chat.Request.create ()) |> Chat.Request.withModel Models.Model.Haiku35 - |> Chat.Request.withMaxTokens 100L + |> Chat.Request.withMaxTokens 100I |> Chat.Request.withStopSequences [ "STOP" ] |> Chat.Request.withUserMessage "Count from 1 to 10, then write STOP, then continue to 20." @@ -250,7 +250,7 @@ module ServerToolTests = let req = (Chat.Request.create ()) |> Chat.Request.withModel Models.Model.Sonnet45 - |> Chat.Request.withMaxTokens 1000L + |> Chat.Request.withMaxTokens 1000I |> Chat.Request.withToolsJson [ toolJson ] |> Chat.Request.withUserMessage "Use code execution to calculate 15 * 23 and tell me the result." @@ -281,7 +281,7 @@ module ServerToolTests = let req = (Chat.Request.create ()) |> Chat.Request.withModel Models.Model.Sonnet45 - |> Chat.Request.withMaxTokens 1000L + |> Chat.Request.withMaxTokens 1000I |> Chat.Request.withToolsJson [ toolJson ] |> Chat.Request.withUserMessage "Use the bash tool to run 'echo hello' and tell me the output." @@ -312,7 +312,7 @@ module ServerToolTests = let req = (Chat.Request.create ()) |> Chat.Request.withModel Models.Model.Sonnet45 - |> Chat.Request.withMaxTokens 1000L + |> Chat.Request.withMaxTokens 1000I |> Chat.Request.withToolsJson [ toolJson ] |> Chat.Request.withUserMessage "Use the text editor to view the contents of /etc/hostname" @@ -355,7 +355,7 @@ module WebFetchTests = let req = (Chat.Request.create ()) |> Chat.Request.withModel Models.Model.Sonnet45 - |> Chat.Request.withMaxTokens 1000L + |> Chat.Request.withMaxTokens 1000I |> Chat.Request.withToolsJson [ toolJson ] |> Chat.Request.withUserMessage "Fetch the content from https://example.com and summarize it." @@ -382,7 +382,7 @@ module WebFetchTests = let req = (Chat.Request.create ()) |> Chat.Request.withModel Models.Model.Sonnet45 - |> Chat.Request.withMaxTokens 1000L + |> Chat.Request.withMaxTokens 1000I |> Chat.Request.withToolsJson [ toolJson ] |> Chat.Request.withUserMessage "Fetch https://example.com and tell me the title. Include a citation." @@ -442,7 +442,7 @@ module VisionTests = let req = (Chat.Request.create ()) |> Chat.Request.withModel Models.Model.Sonnet45 - |> Chat.Request.withMaxTokens 50L + |> Chat.Request.withMaxTokens 50I |> Chat.Request.withBlockMessages [ userMessage ] match Chat.Request.send apiKey req with @@ -477,7 +477,7 @@ module VisionTests = let req = (Chat.Request.create ()) |> Chat.Request.withModel Models.Model.Sonnet45 - |> Chat.Request.withMaxTokens 50L + |> Chat.Request.withMaxTokens 50I |> Chat.Request.withBlockMessages [ userMessage ] match Chat.Request.send apiKey req with @@ -512,7 +512,7 @@ module VisionTests = let req = (Chat.Request.create ()) |> Chat.Request.withModel Models.Model.Sonnet45 - |> Chat.Request.withMaxTokens 100L + |> Chat.Request.withMaxTokens 100I |> Chat.Request.withBlockMessages [ userMessage ] match Chat.Request.send apiKey req with @@ -547,7 +547,7 @@ module VisionTests = let req = (Chat.Request.create ()) |> Chat.Request.withModel Models.Model.Sonnet45 - |> Chat.Request.withMaxTokens 200L + |> Chat.Request.withMaxTokens 200I |> Chat.Request.withBlockMessages [ userMessage ] match Chat.Request.send apiKey req with @@ -586,7 +586,7 @@ module VisionTests = let req = (Chat.Request.create ()) |> Chat.Request.withModel Models.Model.Sonnet45 - |> Chat.Request.withMaxTokens 100L + |> Chat.Request.withMaxTokens 100I |> Chat.Request.withBlockMessages [ userMessage ] match Chat.Request.send apiKey req with @@ -631,7 +631,7 @@ module AdaptiveThinkingTests = let req = (Chat.Request.create ()) |> Chat.Request.withModel Models.Model.Opus46 - |> Chat.Request.withMaxTokens 2000L + |> Chat.Request.withMaxTokens 2000I |> Chat.Request.withAdaptiveThinking |> Chat.Request.withUserMessage "What is the square root of 144? Think through this carefully." @@ -673,7 +673,7 @@ module ServiceTierTests = let req = (Chat.Request.create ()) |> Chat.Request.withModel Models.Model.Haiku35 - |> Chat.Request.withMaxTokens 50L + |> Chat.Request.withMaxTokens 50I |> Chat.Request.withServiceTier Chat.ServiceTier.StandardOnly |> Chat.Request.withUserMessage "Say OK" @@ -694,7 +694,7 @@ module ServiceTierTests = let req = (Chat.Request.create ()) |> Chat.Request.withModel Models.Model.Haiku35 - |> Chat.Request.withMaxTokens 50L + |> Chat.Request.withMaxTokens 50I |> Chat.Request.withServiceTier Chat.ServiceTier.Auto |> Chat.Request.withUserMessage "Say OK" @@ -726,7 +726,7 @@ module SamplingParameterTests = let req = (Chat.Request.create ()) |> Chat.Request.withModel Models.Model.Haiku35 - |> Chat.Request.withMaxTokens 50L + |> Chat.Request.withMaxTokens 50I |> Chat.Request.withTopP 0.9 |> Chat.Request.withUserMessage "Say OK" @@ -747,8 +747,8 @@ module SamplingParameterTests = let req = (Chat.Request.create ()) |> Chat.Request.withModel Models.Model.Haiku35 - |> Chat.Request.withMaxTokens 50L - |> Chat.Request.withTopK 40L + |> Chat.Request.withMaxTokens 50I + |> Chat.Request.withTopK 40I |> Chat.Request.withUserMessage "Say OK" match Chat.Request.send apiKey req with @@ -768,9 +768,9 @@ module SamplingParameterTests = let req = (Chat.Request.create ()) |> Chat.Request.withModel Models.Model.Haiku35 - |> Chat.Request.withMaxTokens 50L + |> Chat.Request.withMaxTokens 50I |> Chat.Request.withTopP 0.95 - |> Chat.Request.withTopK 50L + |> Chat.Request.withTopK 50I |> Chat.Request.withUserMessage "Say OK" match Chat.Request.send apiKey req with @@ -802,7 +802,7 @@ module MetadataTests = let req = (Chat.Request.create ()) |> Chat.Request.withModel Models.Model.Haiku35 - |> Chat.Request.withMaxTokens 50L + |> Chat.Request.withMaxTokens 50I |> Chat.Request.withUserId "test-user-12345" |> Chat.Request.withUserMessage "Say OK" @@ -833,13 +833,13 @@ module BatchTests = let req1 = (Chat.Request.create ()) |> Chat.Request.withModel Models.Model.Haiku35 - |> Chat.Request.withMaxTokens 50L + |> Chat.Request.withMaxTokens 50I |> Chat.Request.withUserMessage "Say hello" let req2 = (Chat.Request.create ()) |> Chat.Request.withModel Models.Model.Haiku35 - |> Chat.Request.withMaxTokens 50L + |> Chat.Request.withMaxTokens 50I |> Chat.Request.withUserMessage "Say goodbye" let batchRequests = @@ -860,7 +860,7 @@ module BatchTests = match getApiKey () with | None -> TestResult.Skipped "ANTHROPIC_API_KEY not set" | Some apiKey -> - match Batch.listBatches apiKey (Stdlib.Option.Option.Some 5L) Stdlib.Option.Option.None with + match Batch.listBatches apiKey (Stdlib.Option.Option.Some 5I) Stdlib.Option.Option.None with | Ok response -> // Just verify we got a valid response (list could be empty) TestResult.Pass @@ -876,7 +876,7 @@ module BatchTests = let req = (Chat.Request.create ()) |> Chat.Request.withModel Models.Model.Haiku35 - |> Chat.Request.withMaxTokens 50L + |> Chat.Request.withMaxTokens 50I |> Chat.Request.withUserMessage "Say test" let batchRequests = [ Batch.batchRequest "retrieve-test" req ] @@ -903,7 +903,7 @@ module BatchTests = let req = (Chat.Request.create ()) |> Chat.Request.withModel Models.Model.Haiku35 - |> Chat.Request.withMaxTokens 50L + |> Chat.Request.withMaxTokens 50I |> Chat.Request.withUserMessage "Test" let batchRequests = [ Batch.batchRequest "helper-test" req ] @@ -915,7 +915,7 @@ module BatchTests = let isComplete = Batch.isComplete batch let total = Batch.totalRequests batch - if (isProcessing || isComplete) && total >= 1L then + if (isProcessing || isComplete) && total >= 1I then TestResult.Pass else TestResult.Fail $"Unexpected batch state: processing={isProcessing}, complete={isComplete}, total={total}" @@ -927,9 +927,9 @@ module BatchTests = let pollBatchUntilComplete (apiKey: String) (batchId: String) - (maxAttempts: Int64) + (maxAttempts: Int) : Stdlib.Result.Result = - let attempts = Stdlib.List.range 1I (Stdlib.Int.fromInt64 maxAttempts) + let attempts = Stdlib.List.range 1I maxAttempts Stdlib.List.fold attempts @@ -957,14 +957,14 @@ module BatchTests = let req = (Chat.Request.create ()) |> Chat.Request.withModel Models.Model.Haiku35 - |> Chat.Request.withMaxTokens 50L + |> Chat.Request.withMaxTokens 50I |> Chat.Request.withUserMessage "Reply with just: OK" let batchRequests = [ Batch.batchRequest "results-test" req ] match Batch.createBatch apiKey batchRequests with | Ok batch -> - match pollBatchUntilComplete apiKey batch.id 30L with + match pollBatchUntilComplete apiKey batch.id 30I with | Ok completedBatch -> match Batch.getBatchResults apiKey completedBatch.id with | Ok results -> @@ -1016,7 +1016,7 @@ module PromptCachingTests = let req1 = (Chat.Request.create ()) |> Chat.Request.withModel Models.Model.Sonnet45 - |> Chat.Request.withMaxTokens 50L + |> Chat.Request.withMaxTokens 50I |> Chat.Request.withSystemBlocks [ cachedBlock ] |> Chat.Request.withUserMessage "Say hello" @@ -1025,14 +1025,14 @@ module PromptCachingTests = // Check cache_creation_input_tokens let cacheCreated = match response1.usage.cache_creation_input_tokens with - | Some tokens -> tokens > 0L + | Some tokens -> tokens > 0I | None -> false // Second request - should read from cache let req2 = (Chat.Request.create ()) |> Chat.Request.withModel Models.Model.Sonnet45 - |> Chat.Request.withMaxTokens 50L + |> Chat.Request.withMaxTokens 50I |> Chat.Request.withSystemBlocks [ cachedBlock ] |> Chat.Request.withUserMessage "Say goodbye" @@ -1040,7 +1040,7 @@ module PromptCachingTests = | Ok response2 -> let cacheRead = match response2.usage.cache_read_input_tokens with - | Some tokens -> tokens > 0L + | Some tokens -> tokens > 0I | None -> false // Either cache was created on first call OR read on second call @@ -1067,10 +1067,10 @@ module PromptCachingTests = // ============================================================================= type TestSummary = - { totalTests: Int64 - passedTests: Int64 - failedTests: Int64 - skippedTests: Int64 + { totalTests: Int + passedTests: Int + failedTests: Int + skippedTests: Int failedTestNames: List } type TestList = List<(String * TestFunction)> @@ -1078,31 +1078,31 @@ type TestList = List<(String * TestFunction)> let runTestGroup (groupName: String) (tests: TestList) : TestSummary = let initialSummary = TestSummary - { totalTests = 0L - passedTests = 0L - failedTests = 0L - skippedTests = 0L + { totalTests = 0I + passedTests = 0I + failedTests = 0I + skippedTests = 0I failedTestNames = [] } tests |> Stdlib.List.fold initialSummary (fun summary nameFnPair -> let name = Stdlib.Tuple2.first nameFnPair let testFn = Stdlib.Tuple2.second nameFnPair - let newSummary = { summary with totalTests = summary.totalTests + 1L } + let newSummary = { summary with totalTests = summary.totalTests + 1I } let result = testFn () match result with | Pass -> Stdlib.printLine $" [PASS] {name}" - { newSummary with passedTests = newSummary.passedTests + 1L } + { newSummary with passedTests = newSummary.passedTests + 1I } | Skipped reason -> Stdlib.printLine $" [SKIP] {name}: {reason}" - { newSummary with skippedTests = newSummary.skippedTests + 1L } + { newSummary with skippedTests = newSummary.skippedTests + 1I } | Fail message -> Stdlib.printLine $" [FAIL] {name}: {message}" { newSummary with - failedTests = newSummary.failedTests + 1L + failedTests = newSummary.failedTests + 1I failedTestNames = Stdlib.List.push newSummary.failedTestNames $"{name}: {message}" }) let combineSummaries (a: TestSummary) (b: TestSummary) : TestSummary = @@ -1131,10 +1131,10 @@ let runAllTests () : String = let emptySummary = TestSummary - { totalTests = 0L - passedTests = 0L - failedTests = 0L - skippedTests = 0L + { totalTests = 0I + passedTests = 0I + failedTests = 0I + skippedTests = 0I failedTestNames = [] } let _ = Stdlib.printLine "Anthropic API Integration Tests" @@ -1150,13 +1150,13 @@ let runAllTests () : String = combineSummaries acc groupSummary) let resultLine = - if finalSummary.failedTests == 0L then - if finalSummary.skippedTests > 0L then - $"All run tests passed! ({Stdlib.Int64.toString finalSummary.skippedTests} skipped)" + if finalSummary.failedTests == 0I then + if finalSummary.skippedTests > 0I then + $"All run tests passed! ({Stdlib.Int.toString finalSummary.skippedTests} skipped)" else "All tests passed!" else let failedNames = Stdlib.String.join finalSummary.failedTestNames "\n - " $"Failed tests:\n - {failedNames}" - $"Anthropic API Integration Tests\nTotal: {Stdlib.Int64.toString finalSummary.totalTests}, Passed: {Stdlib.Int64.toString finalSummary.passedTests}, Failed: {Stdlib.Int64.toString finalSummary.failedTests}, Skipped: {Stdlib.Int64.toString finalSummary.skippedTests}\n{resultLine}" + $"Anthropic API Integration Tests\nTotal: {Stdlib.Int.toString finalSummary.totalTests}, Passed: {Stdlib.Int.toString finalSummary.passedTests}, Failed: {Stdlib.Int.toString finalSummary.failedTests}, Skipped: {Stdlib.Int.toString finalSummary.skippedTests}\n{resultLine}" diff --git a/packages/darklang/wip/ai/anthropic/response.dark b/packages/darklang/wip/ai/anthropic/response.dark index 5056bdcaf1..dbc4120625 100644 --- a/packages/darklang/wip/ai/anthropic/response.dark +++ b/packages/darklang/wip/ai/anthropic/response.dark @@ -50,18 +50,18 @@ let parseStopReason (s: String) : StopReason = StopReason.parse s /// Detailed cache creation breakdown type CacheCreationUsage = - { ephemeral_5m_input_tokens: Stdlib.Option.Option - ephemeral_1h_input_tokens: Stdlib.Option.Option } + { ephemeral_5m_input_tokens: Stdlib.Option.Option + ephemeral_1h_input_tokens: Stdlib.Option.Option } /// Server tool usage tracking type ServerToolUsage = - { web_search_requests: Stdlib.Option.Option } + { web_search_requests: Stdlib.Option.Option } type Usage = - { input_tokens: Int64 - output_tokens: Int64 - cache_creation_input_tokens: Stdlib.Option.Option - cache_read_input_tokens: Stdlib.Option.Option + { input_tokens: Int + output_tokens: Int + cache_creation_input_tokens: Stdlib.Option.Option + cache_read_input_tokens: Stdlib.Option.Option cache_creation: Stdlib.Option.Option server_tool_use: Stdlib.Option.Option service_tier: Stdlib.Option.Option @@ -105,7 +105,7 @@ type ApiError = | ServerError of String | Overloaded of String | InvalidResponse of String - | UnknownError of statusCode: Int64 * body: String + | UnknownError of statusCode: Int * body: String module ApiError = /// Convert an ApiError to a human-readable string @@ -126,7 +126,7 @@ module ApiError = | Overloaded msg -> "API overloaded: " ++ msg | InvalidResponse msg -> "Invalid response: " ++ msg | UnknownError(statusCode, body) -> - "HTTP " ++ Stdlib.Int64.toString statusCode ++ " error: " ++ body + "HTTP " ++ Stdlib.Int.toString statusCode ++ " error: " ++ body /// Check if the error is retryable let isRetryable (err: ApiError) : Bool = @@ -139,17 +139,17 @@ module ApiError = | _ -> false /// Parse an HTTP status code and body into an ApiError - let fromHttpResponse (statusCode: Int64) (body: String) : ApiError = + let fromHttpResponse (statusCode: Int) (body: String) : ApiError = match statusCode with - | 400L -> ApiError.InvalidRequest body - | 401L -> ApiError.AuthenticationError body - | 403L -> ApiError.PermissionDenied body - | 404L -> ApiError.NotFoundError body - | 413L -> ApiError.RequestTooLarge body - | 429L -> ApiError.RateLimited - | 500L -> ApiError.ServerError body - | 529L -> ApiError.Overloaded body - | _ when statusCode >= 500L -> ApiError.ServerError body + | 400I -> ApiError.InvalidRequest body + | 401I -> ApiError.AuthenticationError body + | 403I -> ApiError.PermissionDenied body + | 404I -> ApiError.NotFoundError body + | 413I -> ApiError.RequestTooLarge body + | 429I -> ApiError.RateLimited + | 500I -> ApiError.ServerError body + | 529I -> ApiError.Overloaded body + | _ when statusCode >= 500I -> ApiError.ServerError body | _ -> ApiError.UnknownError(statusCode, body) /// Convert an HttpClient.RequestError to an ApiError @@ -327,9 +327,9 @@ let getDocumentCitations (response: Response) : List = let toAssistantBlocks (response: Response) : List = response.content -let totalTokens (response: Response) : Int64 = - Stdlib.Int64.add response.usage.input_tokens response.usage.output_tokens +let totalTokens (response: Response) : Int = + response.usage.input_tokens + response.usage.output_tokens -let cacheHitTokens (response: Response) : Int64 = +let cacheHitTokens (response: Response) : Int = response.usage.cache_read_input_tokens - |> Stdlib.Option.withDefault 0L + |> Stdlib.Option.withDefault 0I diff --git a/packages/darklang/wip/ai/anthropic/tools.dark b/packages/darklang/wip/ai/anthropic/tools.dark index 09b570a38d..7e679406f6 100644 --- a/packages/darklang/wip/ai/anthropic/tools.dark +++ b/packages/darklang/wip/ai/anthropic/tools.dark @@ -265,7 +265,7 @@ type WebSearchUserLocation = type WebSearchTool = { ``type``: String name: String - max_uses: Stdlib.Option.Option + max_uses: Stdlib.Option.Option allowed_domains: Stdlib.Option.Option> blocked_domains: Stdlib.Option.Option> user_location: Stdlib.Option.Option } @@ -279,7 +279,7 @@ let webSearchTool () : WebSearchTool = blocked_domains = Stdlib.Option.Option.None user_location = Stdlib.Option.Option.None } -let webSearchToolWithLimit (maxUses: Int64) : WebSearchTool = +let webSearchToolWithLimit (maxUses: Int) : WebSearchTool = WebSearchTool { ``type`` = "web_search_20250305" name = "web_search" @@ -290,7 +290,7 @@ let webSearchToolWithLimit (maxUses: Int64) : WebSearchTool = let webSearchToolWithDomains (allowed: List) - (maxUses: Stdlib.Option.Option) + (maxUses: Stdlib.Option.Option) : WebSearchTool = WebSearchTool { ``type`` = "web_search_20250305" @@ -308,7 +308,7 @@ let webSearchToJson (tool: WebSearchTool) : Json = let withMaxUses = match tool.max_uses with | Some n -> - Stdlib.List.append baseFields [ ("max_uses", Json.Number (Stdlib.Int64.toFloat n)) ] + Stdlib.List.append baseFields [ ("max_uses", Json.Number (Stdlib.Int.toFloat n)) ] | None -> baseFields let withAllowed = @@ -368,7 +368,7 @@ let webSearchToJson (tool: WebSearchTool) : Json = type TextEditorTool = { ``type``: String name: String - max_characters: Stdlib.Option.Option } + max_characters: Stdlib.Option.Option } /// Latest text editor tool (20250728) - recommended let textEditorTool () : TextEditorTool = @@ -378,7 +378,7 @@ let textEditorTool () : TextEditorTool = max_characters = Stdlib.Option.Option.None } /// Latest text editor with character limit -let textEditorToolWithLimit (maxChars: Int64) : TextEditorTool = +let textEditorToolWithLimit (maxChars: Int) : TextEditorTool = TextEditorTool { ``type`` = "text_editor_20250728" name = "str_replace_based_edit_tool" @@ -406,7 +406,7 @@ let textEditorToJson (tool: TextEditorTool) : Json = let withMaxChars = match tool.max_characters with | Some n -> - Stdlib.List.append baseFields [ ("max_characters", Json.Number (Stdlib.Int64.toFloat n)) ] + Stdlib.List.append baseFields [ ("max_characters", Json.Number (Stdlib.Int.toFloat n)) ] | None -> baseFields Json.Object withMaxChars @@ -443,13 +443,13 @@ let bashToJson (tool: BashTool) : Json = type ComputerTool = { ``type``: String name: String - display_width_px: Int64 - display_height_px: Int64 - display_number: Stdlib.Option.Option + display_width_px: Int + display_height_px: Int + display_number: Stdlib.Option.Option enable_zoom: Stdlib.Option.Option } /// Computer tool for most models (20250124) -let computerTool (width: Int64) (height: Int64) : ComputerTool = +let computerTool (width: Int) (height: Int) : ComputerTool = ComputerTool { ``type`` = "computer_20250124" name = "computer" @@ -460,9 +460,9 @@ let computerTool (width: Int64) (height: Int64) : ComputerTool = /// Computer tool for most models with display number let computerToolWithDisplay - (width: Int64) - (height: Int64) - (displayNum: Int64) + (width: Int) + (height: Int) + (displayNum: Int) : ComputerTool = ComputerTool { ``type`` = "computer_20250124" @@ -473,7 +473,7 @@ let computerToolWithDisplay enable_zoom = Stdlib.Option.Option.None } /// Computer tool for Opus 4.6/4.5 (20251124) - includes zoom capability -let computerToolOpus (width: Int64) (height: Int64) : ComputerTool = +let computerToolOpus (width: Int) (height: Int) : ComputerTool = ComputerTool { ``type`` = "computer_20251124" name = "computer" @@ -483,7 +483,7 @@ let computerToolOpus (width: Int64) (height: Int64) : ComputerTool = enable_zoom = Stdlib.Option.Option.None } /// Computer tool for Opus 4.6/4.5 with zoom enabled -let computerToolOpusWithZoom (width: Int64) (height: Int64) : ComputerTool = +let computerToolOpusWithZoom (width: Int) (height: Int) : ComputerTool = ComputerTool { ``type`` = "computer_20251124" name = "computer" @@ -494,9 +494,9 @@ let computerToolOpusWithZoom (width: Int64) (height: Int64) : ComputerTool = /// Computer tool for Opus 4.6/4.5 with all options let computerToolOpusFull - (width: Int64) - (height: Int64) - (displayNum: Int64) + (width: Int) + (height: Int) + (displayNum: Int) (enableZoom: Bool) : ComputerTool = ComputerTool @@ -511,13 +511,13 @@ let computerToJson (tool: ComputerTool) : Json = let baseFields = [ ("type", Json.String tool.``type``) ("name", Json.String tool.name) - ("display_width_px", Json.Number(Stdlib.Int64.toFloat tool.display_width_px)) - ("display_height_px", Json.Number(Stdlib.Int64.toFloat tool.display_height_px)) ] + ("display_width_px", Json.Number(Stdlib.Int.toFloat tool.display_width_px)) + ("display_height_px", Json.Number(Stdlib.Int.toFloat tool.display_height_px)) ] let withDisplay = match tool.display_number with | Some n -> - Stdlib.List.append baseFields [ ("display_number", Json.Number(Stdlib.Int64.toFloat n)) ] + Stdlib.List.append baseFields [ ("display_number", Json.Number(Stdlib.Int.toFloat n)) ] | None -> baseFields let withZoom = @@ -669,11 +669,11 @@ type WebFetchCitations = type WebFetchTool = { ``type``: String name: String - max_uses: Stdlib.Option.Option + max_uses: Stdlib.Option.Option allowed_domains: Stdlib.Option.Option> blocked_domains: Stdlib.Option.Option> citations: Stdlib.Option.Option - max_content_tokens: Stdlib.Option.Option } + max_content_tokens: Stdlib.Option.Option } /// Basic web fetch tool with no options let webFetchTool () : WebFetchTool = @@ -687,7 +687,7 @@ let webFetchTool () : WebFetchTool = max_content_tokens = Stdlib.Option.Option.None } /// Web fetch tool with usage limit -let webFetchToolWithLimit (maxUses: Int64) : WebFetchTool = +let webFetchToolWithLimit (maxUses: Int) : WebFetchTool = WebFetchTool { ``type`` = "web_fetch_20250910" name = "web_fetch" @@ -731,7 +731,7 @@ let webFetchToolWithBlockedDomains (domains: List) : WebFetchTool = max_content_tokens = Stdlib.Option.Option.None } /// Web fetch tool with content token limit -let webFetchToolWithContentLimit (maxTokens: Int64) : WebFetchTool = +let webFetchToolWithContentLimit (maxTokens: Int) : WebFetchTool = WebFetchTool { ``type`` = "web_fetch_20250910" name = "web_fetch" @@ -743,11 +743,11 @@ let webFetchToolWithContentLimit (maxTokens: Int64) : WebFetchTool = /// Fully configurable web fetch tool let webFetchToolFull - (maxUses: Stdlib.Option.Option) + (maxUses: Stdlib.Option.Option) (allowedDomains: Stdlib.Option.Option>) (blockedDomains: Stdlib.Option.Option>) (enableCitations: Bool) - (maxContentTokens: Stdlib.Option.Option) + (maxContentTokens: Stdlib.Option.Option) : WebFetchTool = WebFetchTool { ``type`` = "web_fetch_20250910" @@ -770,7 +770,7 @@ let webFetchToJson (tool: WebFetchTool) : Json = let withMaxUses = match tool.max_uses with | Some n -> - Stdlib.List.append baseFields [ ("max_uses", Json.Number (Stdlib.Int64.toFloat n)) ] + Stdlib.List.append baseFields [ ("max_uses", Json.Number (Stdlib.Int.toFloat n)) ] | None -> baseFields let withAllowed = @@ -797,7 +797,7 @@ let webFetchToJson (tool: WebFetchTool) : Json = let withMaxContent = match tool.max_content_tokens with | Some n -> - Stdlib.List.append withCitations [ ("max_content_tokens", Json.Number (Stdlib.Int64.toFloat n)) ] + Stdlib.List.append withCitations [ ("max_content_tokens", Json.Number (Stdlib.Int.toFloat n)) ] | None -> withCitations Json.Object withMaxContent diff --git a/packages/darklang/wip/ai/openai/audio.dark b/packages/darklang/wip/ai/openai/audio.dark index 405519db63..523759ff52 100644 --- a/packages/darklang/wip/ai/openai/audio.dark +++ b/packages/darklang/wip/ai/openai/audio.dark @@ -71,9 +71,9 @@ module Transport = let mapStatusError (response: Stdlib.HttpClient.Response) : Stdlib.Option.Option = match response.statusCode with - | code when code >= 200L && code < 300L -> Stdlib.Option.Option.None - | 401L -> Stdlib.Option.Option.Some "Authentication failed: Invalid API key" - | 429L -> Stdlib.Option.Option.Some "Rate limit exceeded" + | code when code >= 200I && code < 300I -> Stdlib.Option.Option.None + | 401I -> Stdlib.Option.Option.Some "Authentication failed: Invalid API key" + | 429I -> Stdlib.Option.Option.Some "Rate limit exceeded" | _ -> let bodyStr = Stdlib.String.fromBlobWithReplacement response.body Stdlib.Option.Option.Some("API error: " ++ bodyStr) @@ -268,7 +268,7 @@ module Transcriptions = word: String } type TranscriptionSegment = - { id: Stdlib.Option.Option + { id: Stdlib.Option.Option start: Float end_: Float text: String @@ -276,17 +276,17 @@ module Transcriptions = compressionRatio: Stdlib.Option.Option noSpeechProb: Stdlib.Option.Option temperature: Stdlib.Option.Option - seek: Stdlib.Option.Option - tokens: List } + seek: Stdlib.Option.Option + tokens: List } type TranscriptionLogprob = { token: String logprob: Float - bytes: List } + bytes: List } type Usage = - { promptTokens: Int64 - totalTokens: Int64 } + { promptTokens: Int + totalTokens: Int } type TranscriptionJson = { text: String @@ -305,7 +305,7 @@ module Transcriptions = usage: Stdlib.Option.Option } type TranscriptionDiarizedSegment = - { id: Int64 + { id: Int start: Float end_: Float speaker: String @@ -396,7 +396,7 @@ module Transcriptions = (Stdlib.AltJson.Helpers.getArray "bytes" logprobFields) (fun b -> match b with - | Number n -> Stdlib.Option.Option.Some(Stdlib.Int64.fromFloat n) + | Number n -> Stdlib.Option.Option.Some(Stdlib.Int.fromFloat n) | _ -> Stdlib.Option.Option.None) match (Stdlib.AltJson.Helpers.getString "token" logprobFields, @@ -448,7 +448,7 @@ module Transcriptions = (Stdlib.AltJson.Helpers.getArray "tokens" fields) (fun t -> match t with - | Number n -> Stdlib.Option.Option.Some(Stdlib.Int64.fromFloat n) + | Number n -> Stdlib.Option.Option.Some(Stdlib.Int.fromFloat n) | _ -> Stdlib.Option.Option.None) match (Stdlib.AltJson.Helpers.getNumber "start" fields, @@ -484,7 +484,7 @@ module Transcriptions = | (Some id, Some start, Some end_, Some speaker, Some text, Some type_) -> Stdlib.Option.Option.Some( TranscriptionDiarizedSegment - { id = id + { id = Stdlib.Int.fromInt64 id start = start end_ = end_ speaker = speaker diff --git a/packages/darklang/wip/ai/openai/chat.dark b/packages/darklang/wip/ai/openai/chat.dark index 3616ec2ba9..04179b6e36 100644 --- a/packages/darklang/wip/ai/openai/chat.dark +++ b/packages/darklang/wip/ai/openai/chat.dark @@ -110,7 +110,7 @@ let audioParamToJson (param: AudioParam) : Json = type AudioResponse = { id: String // Unique identifier for the audio data: String // Base64-encoded audio data - expiresAt: Int64 // Unix timestamp when audio expires + expiresAt: Int64 // Unix timestamp when audio expires (KEPT Int64: timestamp) transcript: String } // Transcript of the audio /// Parse audio response from JSON @@ -133,13 +133,13 @@ let parseAudioResponse (fields: List<(String * Json)>) : Stdlib.Option.Option> } + bytes: Stdlib.Option.Option> } /// Token log probability type TokenLogprob = { token: String logprob: Float - bytes: Stdlib.Option.Option> + bytes: Stdlib.Option.Option> topLogprobs: List } /// Log probabilities for a choice @@ -428,8 +428,8 @@ type Request = modalities: Stdlib.Option.Option> audio: Stdlib.Option.Option // Token limits - maxTokens: Stdlib.Option.Option // Deprecated - maxCompletionTokens: Stdlib.Option.Option + maxTokens: Stdlib.Option.Option // Deprecated + maxCompletionTokens: Stdlib.Option.Option // Sampling parameters temperature: Stdlib.Option.Option topP: Stdlib.Option.Option @@ -443,13 +443,13 @@ type Request = metadata: Stdlib.Option.Option> serviceTier: Stdlib.Option.Option // Generation options - n: Stdlib.Option.Option - seed: Stdlib.Option.Option + n: Stdlib.Option.Option + seed: Stdlib.Option.Option // KEPT Int64: opaque reproducibility value, not a count user: Stdlib.Option.Option // Log probabilities logprobs: Stdlib.Option.Option - topLogprobs: Stdlib.Option.Option - logitBias: Stdlib.Option.Option> + topLogprobs: Stdlib.Option.Option + logitBias: Stdlib.Option.Option> // Advanced features webSearchOptions: Stdlib.Option.Option prediction: Stdlib.Option.Option } @@ -564,11 +564,11 @@ let withAudioParam (req: Request) (param: AudioParam) : Request = { req with audio = Stdlib.Option.Option.Some param } /// Set max tokens (deprecated, use withMaxCompletionTokens) -let withMaxTokens (req: Request) (tokens: Int64) : Request = +let withMaxTokens (req: Request) (tokens: Int) : Request = { req with maxTokens = Stdlib.Option.Option.Some tokens } /// Set max completion tokens -let withMaxCompletionTokens (req: Request) (tokens: Int64) : Request = +let withMaxCompletionTokens (req: Request) (tokens: Int) : Request = { req with maxCompletionTokens = Stdlib.Option.Option.Some tokens } /// Set temperature @@ -608,10 +608,10 @@ let withServiceTier (req: Request) (tier: ServiceTier.Tier) : Request = { req with serviceTier = Stdlib.Option.Option.Some tier } /// Set number of completions -let withN (req: Request) (count: Int64) : Request = +let withN (req: Request) (count: Int) : Request = { req with n = Stdlib.Option.Option.Some count } -/// Set seed +/// Set seed (KEPT Int64: opaque reproducibility value, not a count) let withSeed (req: Request) (seed: Int64) : Request = { req with seed = Stdlib.Option.Option.Some seed } @@ -624,11 +624,11 @@ let withLogprobs (req: Request) (enabled: Bool) : Request = { req with logprobs = Stdlib.Option.Option.Some enabled } /// Set top log probabilities count -let withTopLogprobs (req: Request) (count: Int64) : Request = +let withTopLogprobs (req: Request) (count: Int) : Request = { req with topLogprobs = Stdlib.Option.Option.Some count } /// Set logit bias -let withLogitBias (req: Request) (biases: List<(String * Int64)>) : Request = +let withLogitBias (req: Request) (biases: List<(String * Int)>) : Request = { req with logitBias = Stdlib.Option.Option.Some biases } /// Enable web search @@ -800,20 +800,20 @@ let buildRequestJson (req: Request) : Json = if caps.requiresMaxCompletionTokens then match req.maxCompletionTokens with | Some t -> - Stdlib.List.append withAudio_ [ ("max_completion_tokens", Json.Number(Stdlib.Int64.toFloat t)) ] + Stdlib.List.append withAudio_ [ ("max_completion_tokens", Json.Number(Stdlib.Int.toFloat t)) ] | None -> match req.maxTokens with | Some t -> - Stdlib.List.append withAudio_ [ ("max_completion_tokens", Json.Number(Stdlib.Int64.toFloat t)) ] + Stdlib.List.append withAudio_ [ ("max_completion_tokens", Json.Number(Stdlib.Int.toFloat t)) ] | None -> withAudio_ else match req.maxCompletionTokens with | Some t -> - Stdlib.List.append withAudio_ [ ("max_completion_tokens", Json.Number(Stdlib.Int64.toFloat t)) ] + Stdlib.List.append withAudio_ [ ("max_completion_tokens", Json.Number(Stdlib.Int.toFloat t)) ] | None -> match req.maxTokens with | Some t -> - Stdlib.List.append withAudio_ [ ("max_tokens", Json.Number(Stdlib.Int64.toFloat t)) ] + Stdlib.List.append withAudio_ [ ("max_tokens", Json.Number(Stdlib.Int.toFloat t)) ] | None -> withAudio_ // Reasoning effort @@ -903,7 +903,7 @@ let buildRequestJson (req: Request) : Json = let withN_ = match req.n with | Some count -> - Stdlib.List.append withServiceTier_ [ ("n", Json.Number(Stdlib.Int64.toFloat count)) ] + Stdlib.List.append withServiceTier_ [ ("n", Json.Number(Stdlib.Int.toFloat count)) ] | None -> withServiceTier_ // Seed @@ -931,14 +931,14 @@ let buildRequestJson (req: Request) : Json = let withTopLogprobs_ = match req.topLogprobs with | Some count -> - Stdlib.List.append withLogprobs_ [ ("top_logprobs", Json.Number(Stdlib.Int64.toFloat count)) ] + Stdlib.List.append withLogprobs_ [ ("top_logprobs", Json.Number(Stdlib.Int.toFloat count)) ] | None -> withLogprobs_ // Logit bias let withLogitBias_ = match req.logitBias with | Some biases -> - let biasJson = Stdlib.List.map biases (fun (k, v) -> (k, Json.Number(Stdlib.Int64.toFloat v))) + let biasJson = Stdlib.List.map biases (fun (k, v) -> (k, Json.Number(Stdlib.Int.toFloat v))) Stdlib.List.append withTopLogprobs_ [ ("logit_bias", Json.Object biasJson) ] | None -> withTopLogprobs_ @@ -973,26 +973,26 @@ type ResponseMessage = /// A choice in the chat completion (part of ChatCompletion.choices) type Choice = - { index: Int64 + { index: Int message: ResponseMessage finishReason: String logprobs: Stdlib.Option.Option } /// Token usage information type Usage = - { promptTokens: Int64 - completionTokens: Int64 - totalTokens: Int64 + { promptTokens: Int + completionTokens: Int + totalTokens: Int /// Reasoning tokens (o-series models) - reasoningTokens: Int64 + reasoningTokens: Int /// Cached prompt tokens - cachedTokens: Int64 } + cachedTokens: Int } /// Chat completion response (ChatCompletion) type Response = { id: String object_: String // "chat.completion" - created: Int64 + created: Int64 // KEPT Int64: Unix timestamp model: String choices: List usage: Usage @@ -1260,7 +1260,7 @@ type StoredMessage = /// GET /chat/completions let list (apiKey: String) - (limit: Stdlib.Option.Option) + (limit: Stdlib.Option.Option) (after: Stdlib.Option.Option) (order: Stdlib.Option.Option) : Stdlib.Result.Result, String> = @@ -1274,7 +1274,7 @@ let list let params = [] let withLimit = match limit with - | Some l -> Stdlib.List.append params [ ("limit", Stdlib.Int64.toString l) ] + | Some l -> Stdlib.List.append params [ ("limit", Stdlib.Int.toString l) ] | None -> params let withAfter = match after with diff --git a/packages/darklang/wip/ai/openai/embeddings.dark b/packages/darklang/wip/ai/openai/embeddings.dark index 4cd8684083..50a61293fb 100644 --- a/packages/darklang/wip/ai/openai/embeddings.dark +++ b/packages/darklang/wip/ai/openai/embeddings.dark @@ -21,7 +21,7 @@ type Options = input: String /// Number of dimensions (only for text-embedding-3 models) /// Allows shortening embeddings for storage efficiency - dimensions: Stdlib.Option.Option + dimensions: Stdlib.Option.Option /// Encoding format (float or base64) encodingFormat: Stdlib.Option.Option /// End-user ID for abuse detection @@ -41,7 +41,7 @@ let withModel (opts: Options) (model: String) : Options = { opts with model = model } /// Set dimensions (only for text-embedding-3 models) -let withDimensions (opts: Options) (dims: Int64) : Options = +let withDimensions (opts: Options) (dims: Int) : Options = { opts with dimensions = Stdlib.Option.Option.Some dims } /// Set encoding format @@ -54,13 +54,13 @@ let withUser (opts: Options) (userId: String) : Options = /// Token usage information type Usage = - { promptTokens: Int64 - totalTokens: Int64 } + { promptTokens: Int + totalTokens: Int } /// Represents an embedding vector returned by embedding endpoint type Embedding = { embedding: List - index: Int64 + index: Int object_: String } /// Response from creating embeddings @@ -84,7 +84,7 @@ let parseEmbedding (item: Json) : Stdlib.Option.Option = | Number n -> Stdlib.Option.Option.Some n | _ -> Stdlib.Option.Option.None) Stdlib.Option.Option.Some( - Embedding { embedding = floats; index = index; object_ = obj }) + Embedding { embedding = floats; index = Stdlib.Int.fromInt64 index; object_ = obj }) | _ -> Stdlib.Option.Option.None | _ -> Stdlib.Option.Option.None @@ -96,7 +96,9 @@ let parseUsage (fields: List<(String * Json)>) : Stdlib.Option.Option = Stdlib.AltJson.Helpers.getInt "total_tokens" usageFields) with | (Some promptTokens, Some totalTokens) -> Stdlib.Option.Option.Some( - Usage { promptTokens = promptTokens; totalTokens = totalTokens }) + Usage + { promptTokens = Stdlib.Int.fromInt64 promptTokens + totalTokens = Stdlib.Int.fromInt64 totalTokens }) | _ -> Stdlib.Option.Option.None | _ -> Stdlib.Option.Option.None @@ -115,7 +117,7 @@ let createWithOptions let withDims = match opts.dimensions with - | Some d -> Stdlib.List.append baseFields [ ("dimensions", Json.Number(Stdlib.Int64.toFloat d)) ] + | Some d -> Stdlib.List.append baseFields [ ("dimensions", Json.Number(Stdlib.Int.toFloat d)) ] | None -> baseFields let withEncoding = @@ -182,7 +184,7 @@ let createWithDimensions (apiKey: String) (model: String) (input: String) - (dimensions: Int64) + (dimensions: Int) : Stdlib.Result.Result = let opts = (defaultOptions input) @@ -195,7 +197,7 @@ type BatchOptions = { model: String inputs: List /// Number of dimensions (only for text-embedding-3 models) - dimensions: Stdlib.Option.Option + dimensions: Stdlib.Option.Option /// Encoding format (float or base64) encodingFormat: Stdlib.Option.Option /// End-user ID for abuse detection @@ -215,7 +217,7 @@ let withBatchModel (opts: BatchOptions) (model: String) : BatchOptions = { opts with model = model } /// Set dimensions for batch options -let withBatchDimensions (opts: BatchOptions) (dims: Int64) : BatchOptions = +let withBatchDimensions (opts: BatchOptions) (dims: Int) : BatchOptions = { opts with dimensions = Stdlib.Option.Option.Some dims } /// Generate embeddings for multiple texts with full options @@ -234,7 +236,7 @@ let createBatchWithOptions let withDims = match opts.dimensions with - | Some d -> Stdlib.List.append baseFields [ ("dimensions", Json.Number(Stdlib.Int64.toFloat d)) ] + | Some d -> Stdlib.List.append baseFields [ ("dimensions", Json.Number(Stdlib.Int.toFloat d)) ] | None -> baseFields let withEncoding = diff --git a/packages/darklang/wip/ai/openai/images.dark b/packages/darklang/wip/ai/openai/images.dark index f0c646e5e4..9b279069a8 100644 --- a/packages/darklang/wip/ai/openai/images.dark +++ b/packages/darklang/wip/ai/openai/images.dark @@ -85,13 +85,13 @@ type Options = quality: String /// Style: only for DALL-E 3 style: Stdlib.Option.Option - n: Int64 + n: Int /// Output format: only for GPT Image models (png, jpeg, webp) outputFormat: Stdlib.Option.Option /// Background: only for GPT Image models (transparent, opaque, auto) background: Stdlib.Option.Option /// Output compression: only for GPT Image models with jpeg/webp (0-100) - outputCompression: Stdlib.Option.Option + outputCompression: Stdlib.Option.Option /// User ID for abuse detection user: Stdlib.Option.Option } @@ -103,7 +103,7 @@ let defaultOptions (prompt: String) : Options = size = Size.square1024 quality = Quality.standard style = Stdlib.Option.Option.Some Style.vivid - n = 1L + n = 1I outputFormat = Stdlib.Option.Option.None background = Stdlib.Option.Option.None outputCompression = Stdlib.Option.Option.None @@ -117,7 +117,7 @@ let gptImageOptions (prompt: String) : Options = size = Size.auto quality = Quality.medium style = Stdlib.Option.Option.None - n = 1L + n = 1I outputFormat = Stdlib.Option.Option.Some OutputFormat.Png background = Stdlib.Option.Option.Some Background.Auto outputCompression = Stdlib.Option.Option.None @@ -140,7 +140,7 @@ let withStyle (opts: Options) (style: String) : Options = { opts with style = Stdlib.Option.Option.Some style } /// Set count -let withN (opts: Options) (count: Int64) : Options = +let withN (opts: Options) (count: Int) : Options = { opts with n = count } /// Set output format (GPT Image only) @@ -158,7 +158,7 @@ let withTransparentBackground (opts: Options) : Options = outputFormat = Stdlib.Option.Option.Some OutputFormat.Png } /// Set output compression 0-100 (GPT Image only, jpeg/webp) -let withOutputCompression (opts: Options) (compression: Int64) : Options = +let withOutputCompression (opts: Options) (compression: Int) : Options = { opts with outputCompression = Stdlib.Option.Option.Some compression } /// Set user ID @@ -224,7 +224,7 @@ let generateWithOptions ("prompt", Json.String options.prompt) ("size", Json.String options.size) ("quality", Json.String options.quality) - ("n", Json.Number(Stdlib.Int64.toFloat options.n)) ] + ("n", Json.Number(Stdlib.Int.toFloat options.n)) ] // Add style for DALL-E 3 let withStyle_ = @@ -261,7 +261,7 @@ let generateWithOptions match options.outputCompression with | Some c -> if isGpt then - Stdlib.List.append withBackground_ [ ("output_compression", Json.Number(Stdlib.Int64.toFloat c)) ] + Stdlib.List.append withBackground_ [ ("output_compression", Json.Number(Stdlib.Int.toFloat c)) ] else withBackground_ | None -> withBackground_ @@ -283,7 +283,7 @@ let generateWithOptions let bodyStr = Stdlib.String.fromBlobWithReplacement response.body match response.statusCode with - | code when code >= 200L && code < 300L -> + | code when code >= 200I && code < 300I -> match Stdlib.AltJson.parse bodyStr with | Ok (Object fields) -> let dataArray = Stdlib.AltJson.Helpers.getArray "data" fields @@ -308,8 +308,8 @@ let generateWithOptions | _ -> Stdlib.Option.Option.None) Stdlib.Result.Result.Ok images | _ -> Stdlib.Result.Result.Error "Invalid response format" - | 401L -> Stdlib.Result.Result.Error "Authentication failed: Invalid API key" - | 429L -> Stdlib.Result.Result.Error "Rate limit exceeded" + | 401I -> Stdlib.Result.Result.Error "Authentication failed: Invalid API key" + | 429I -> Stdlib.Result.Result.Error "Rate limit exceeded" | _ -> Stdlib.Result.Result.Error("API error: " ++ bodyStr) /// Generate an image with default DALL-E 3 settings (returns URL) @@ -392,7 +392,7 @@ type EditOptions = /// Optional mask (base64 encoded PNG, transparent areas indicate where to edit) mask: Stdlib.Option.Option size: String - n: Int64 + n: Int user: Stdlib.Option.Option } /// Create default edit options @@ -403,7 +403,7 @@ let defaultEditOptions (prompt: String) (imageBase64: String) : EditOptions = image = imageBase64 mask = Stdlib.Option.Option.None size = Size.square1024 - n = 1L + n = 1I user = Stdlib.Option.Option.None } /// Edit options with mask @@ -425,7 +425,7 @@ let edit ("prompt", Json.String options.prompt) ("image", Json.String options.image) ("size", Json.String options.size) - ("n", Json.Number(Stdlib.Int64.toFloat options.n)) ] + ("n", Json.Number(Stdlib.Int.toFloat options.n)) ] let withMask_ = match options.mask with @@ -448,7 +448,7 @@ let edit let bodyStr = Stdlib.String.fromBlobWithReplacement response.body match response.statusCode with - | code when code >= 200L && code < 300L -> + | code when code >= 200I && code < 300I -> match Stdlib.AltJson.parse bodyStr with | Ok (Object fields) -> let dataArray = Stdlib.AltJson.Helpers.getArray "data" fields @@ -470,8 +470,8 @@ let edit | _ -> Stdlib.Option.Option.None) Stdlib.Result.Result.Ok images | _ -> Stdlib.Result.Result.Error "Invalid response format" - | 401L -> Stdlib.Result.Result.Error "Authentication failed: Invalid API key" - | 429L -> Stdlib.Result.Result.Error "Rate limit exceeded" + | 401I -> Stdlib.Result.Result.Error "Authentication failed: Invalid API key" + | 429I -> Stdlib.Result.Result.Error "Rate limit exceeded" | _ -> Stdlib.Result.Result.Error("API error: " ++ bodyStr) // ============================================================================= @@ -485,7 +485,7 @@ type VariationOptions = /// Model (only dall-e-2 supported) model: String size: String - n: Int64 + n: Int user: Stdlib.Option.Option } /// Create default variation options @@ -494,7 +494,7 @@ let defaultVariationOptions (imageBase64: String) : VariationOptions = { image = imageBase64 model = Models.dalle2 size = Size.square1024 - n = 1L + n = 1I user = Stdlib.Option.Option.None } /// Create variations of an image (DALL-E 2 only) @@ -511,7 +511,7 @@ let createVariations [ ("image", Json.String options.image) ("model", Json.String options.model) ("size", Json.String options.size) - ("n", Json.Number(Stdlib.Int64.toFloat options.n)) ] + ("n", Json.Number(Stdlib.Int.toFloat options.n)) ] let withUser_ = match options.user with @@ -529,7 +529,7 @@ let createVariations let bodyStr = Stdlib.String.fromBlobWithReplacement response.body match response.statusCode with - | code when code >= 200L && code < 300L -> + | code when code >= 200I && code < 300I -> match Stdlib.AltJson.parse bodyStr with | Ok (Object fields) -> let dataArray = Stdlib.AltJson.Helpers.getArray "data" fields @@ -546,6 +546,6 @@ let createVariations | _ -> Stdlib.Option.Option.None) Stdlib.Result.Result.Ok images | _ -> Stdlib.Result.Result.Error "Invalid response format" - | 401L -> Stdlib.Result.Result.Error "Authentication failed: Invalid API key" - | 429L -> Stdlib.Result.Result.Error "Rate limit exceeded" + | 401I -> Stdlib.Result.Result.Error "Authentication failed: Invalid API key" + | 429I -> Stdlib.Result.Result.Error "Rate limit exceeded" | _ -> Stdlib.Result.Result.Error("API error: " ++ bodyStr) diff --git a/packages/darklang/wip/ai/openai/responses.dark b/packages/darklang/wip/ai/openai/responses.dark index 5256546b72..4bc965c9a0 100644 --- a/packages/darklang/wip/ai/openai/responses.dark +++ b/packages/darklang/wip/ai/openai/responses.dark @@ -237,7 +237,7 @@ module BuiltInTools = /// File search tool configuration type FileSearchTool = { vectorStoreIds: List - maxNumResults: Stdlib.Option.Option + maxNumResults: Stdlib.Option.Option rankingOptions: Stdlib.Option.Option } /// Code interpreter tool configuration @@ -247,8 +247,8 @@ module BuiltInTools = /// Computer use tool configuration type ComputerUseTool = - { displayWidth: Int64 - displayHeight: Int64 + { displayWidth: Int + displayHeight: Int environment: Stdlib.Option.Option } /// Built-in tool types @@ -272,7 +272,7 @@ module BuiltInTools = let withMaxResults = match opts.maxNumResults with - | Some n -> Stdlib.List.append fields [ ("max_num_results", Json.Number(Stdlib.Int64.toFloat n)) ] + | Some n -> Stdlib.List.append fields [ ("max_num_results", Json.Number(Stdlib.Int.toFloat n)) ] | None -> fields let withRanking = @@ -302,8 +302,8 @@ module BuiltInTools = | ComputerUse opts -> let fields = [ ("type", Json.String "computer_use_preview") - ("display_width", Json.Number(Stdlib.Int64.toFloat opts.displayWidth)) - ("display_height", Json.Number(Stdlib.Int64.toFloat opts.displayHeight)) ] + ("display_width", Json.Number(Stdlib.Int.toFloat opts.displayWidth)) + ("display_height", Json.Number(Stdlib.Int.toFloat opts.displayHeight)) ] let withEnv = match opts.environment with @@ -353,7 +353,7 @@ module BuiltInTools = fileIds = fileIds }) /// Create a computer use tool - let computerUse (width: Int64) (height: Int64) : BuiltInTool = + let computerUse (width: Int) (height: Int) : BuiltInTool = BuiltInTool.ComputerUse( ComputerUseTool { displayWidth = width @@ -477,7 +477,7 @@ type Request = toolChoice: Stdlib.Option.Option parallelToolCalls: Stdlib.Option.Option previousResponseId: Stdlib.Option.Option - maxOutputTokens: Stdlib.Option.Option + maxOutputTokens: Stdlib.Option.Option temperature: Stdlib.Option.Option topP: Stdlib.Option.Option text: Stdlib.Option.Option @@ -486,7 +486,7 @@ type Request = store: Stdlib.Option.Option serviceTier: Stdlib.Option.Option truncation: Stdlib.Option.Option - maxToolCalls: Stdlib.Option.Option } + maxToolCalls: Stdlib.Option.Option } /// Create a new request with defaults let createRequest () : Request = @@ -554,7 +554,7 @@ let withCodeInterpreterFiles (req: Request) (fileIds: List) : Request = withTool req (BuiltInTools.codeInterpreterWithFiles fileIds) /// Add computer use tool -let withComputerUse (req: Request) (width: Int64) (height: Int64) : Request = +let withComputerUse (req: Request) (width: Int) (height: Int) : Request = withTool req (BuiltInTools.computerUse width height) /// Add function tools from existing Tools.Tool list @@ -575,7 +575,7 @@ let withPreviousResponseId (req: Request) (id: String) : Request = { req with previousResponseId = Stdlib.Option.Option.Some id } /// Set max output tokens -let withMaxOutputTokens (req: Request) (tokens: Int64) : Request = +let withMaxOutputTokens (req: Request) (tokens: Int) : Request = { req with maxOutputTokens = Stdlib.Option.Option.Some tokens } /// Set temperature @@ -624,7 +624,7 @@ let withTruncation (req: Request) (strategy: String) : Request = { req with truncation = Stdlib.Option.Option.Some strategy } /// Set max tool calls -let withMaxToolCalls (req: Request) (max: Int64) : Request = +let withMaxToolCalls (req: Request) (max: Int) : Request = { req with maxToolCalls = Stdlib.Option.Option.Some max } @@ -667,7 +667,7 @@ let buildRequestJson (req: Request) : Json = let withMaxOutputTokens_ = match req.maxOutputTokens with - | Some t -> Stdlib.List.append withPreviousResponseId_ [ ("max_output_tokens", Json.Number(Stdlib.Int64.toFloat t)) ] + | Some t -> Stdlib.List.append withPreviousResponseId_ [ ("max_output_tokens", Json.Number(Stdlib.Int.toFloat t)) ] | None -> withPreviousResponseId_ let withTemp_ = @@ -715,7 +715,7 @@ let buildRequestJson (req: Request) : Json = let withMaxToolCalls_ = match req.maxToolCalls with - | Some m -> Stdlib.List.append withTruncation_ [ ("max_tool_calls", Json.Number(Stdlib.Int64.toFloat m)) ] + | Some m -> Stdlib.List.append withTruncation_ [ ("max_tool_calls", Json.Number(Stdlib.Int.toFloat m)) ] | None -> withTruncation_ Json.Object withMaxToolCalls_ @@ -727,9 +727,9 @@ let buildRequestJson (req: Request) : Json = /// Usage information type Usage = - { inputTokens: Int64 - outputTokens: Int64 - totalTokens: Int64 + { inputTokens: Int + outputTokens: Int + totalTokens: Int inputTokensDetails: Stdlib.Option.Option outputTokensDetails: Stdlib.Option.Option } diff --git a/packages/darklang/wip/ai/openai/web-search.dark b/packages/darklang/wip/ai/openai/web-search.dark index 8abdc47be4..7caeed83ba 100644 --- a/packages/darklang/wip/ai/openai/web-search.dark +++ b/packages/darklang/wip/ai/openai/web-search.dark @@ -290,9 +290,9 @@ type WebSearchCall = /// URL citation annotation from web search results type UrlCitation = { /// Start index in the text where citation appears - startIndex: Int64 + startIndex: Int /// End index in the text where citation ends - endIndex: Int64 + endIndex: Int /// The cited URL url: String /// Title of the cited source @@ -327,10 +327,14 @@ let parseUrlCitation (json: Json) : Stdlib.Option.Option = match json with | Object fields -> let startIndexJson = getJsonField fields "start_index" - let startIndex = Stdlib.Option.andThen startIndexJson (fun v -> jsonToInt64 v) + let startIndex = + (Stdlib.Option.andThen startIndexJson (fun v -> jsonToInt64 v)) + |> Stdlib.Option.map (fun n -> Stdlib.Int.fromInt64 n) let endIndexJson = getJsonField fields "end_index" - let endIndex = Stdlib.Option.andThen endIndexJson (fun v -> jsonToInt64 v) + let endIndex = + (Stdlib.Option.andThen endIndexJson (fun v -> jsonToInt64 v)) + |> Stdlib.Option.map (fun n -> Stdlib.Int.fromInt64 n) let urlJson = getJsonField fields "url" let url = Stdlib.Option.andThen urlJson (fun v -> jsonToString v) From 315f1c03e19f8ff41076c9f59323a933889ec63a Mon Sep 17 00:00:00 2001 From: OceanOak Date: Wed, 17 Jun 2026 14:07:35 +0000 Subject: [PATCH 17/61] Migrate LLM model/agent token limits from Int64 to Int --- packages/darklang/cli/ai/agent.dark | 4 +- packages/darklang/llm/agent.dark | 12 ++-- packages/darklang/llm/examples/basics.dark | 8 +-- .../darklang/llm/examples/code-agent.dark | 4 +- packages/darklang/llm/examples/explainer.dark | 4 +- .../darklang/llm/examples/git-commit.dark | 4 +- .../darklang/llm/examples/json-extractor.dark | 12 ++-- .../darklang/llm/examples/multi-model.dark | 2 +- .../darklang/llm/examples/news-digest.dark | 4 +- .../llm/examples/ollama-translator.dark | 2 +- packages/darklang/llm/examples/research.dark | 8 +-- .../darklang/llm/examples/url-reader.dark | 4 +- .../darklang/llm/internal/agent-loop.dark | 16 ++--- .../darklang/llm/internal/validation.dark | 12 ++-- packages/darklang/llm/models.dark | 64 +++++++++---------- packages/darklang/llm/providers/openai.dark | 14 ++-- 16 files changed, 87 insertions(+), 87 deletions(-) diff --git a/packages/darklang/cli/ai/agent.dark b/packages/darklang/cli/ai/agent.dark index acd289e577..6aca121dbb 100644 --- a/packages/darklang/cli/ai/agent.dark +++ b/packages/darklang/cli/ai/agent.dark @@ -239,8 +239,8 @@ let currentBranchName (state: Cli.AppState) : String = let createAgent (model: Darklang.LLM.Models.Model) (branchName: String) (writeMode: WriteMode) : Darklang.LLM.Agent.Agent = (Darklang.LLM.Agent.create ()) |> Darklang.LLM.Agent.withSystemPrompt systemPrompt - |> Darklang.LLM.Agent.withMaxTokens 4000L - |> Darklang.LLM.Agent.withMaxTurns 20L + |> Darklang.LLM.Agent.withMaxTokens 4000I + |> Darklang.LLM.Agent.withMaxTurns 20I |> Darklang.LLM.Agent.withTemperature 0.2 |> Darklang.LLM.Agent.withModel model |> Darklang.LLM.Agent.withTool (makeCliTool branchName writeMode) diff --git a/packages/darklang/llm/agent.dark b/packages/darklang/llm/agent.dark index 67ab5b57ac..ed94f28e3c 100644 --- a/packages/darklang/llm/agent.dark +++ b/packages/darklang/llm/agent.dark @@ -79,8 +79,8 @@ type Agent = { model: Model systemPrompt: Stdlib.Option.Option tools: List - maxTokens: Int64 - maxTurns: Int64 + maxTokens: Int + maxTurns: Int temperature: Stdlib.Option.Option // Shared provider features toolChoice: Stdlib.Option.Option @@ -107,8 +107,8 @@ let create () : Agent = { model = Darklang.LLM.Models.Anthropic.sonnet45 systemPrompt = Stdlib.Option.Option.None tools = [] - maxTokens = 4096L - maxTurns = 10L + maxTokens = 4096I + maxTurns = 10I temperature = Stdlib.Option.Option.None toolChoice = Stdlib.Option.Option.None disableParallelToolUse = false @@ -144,12 +144,12 @@ let withTools (agent: Agent) (tools: List) : Agent = { agent with tools = Stdlib.List.append agent.tools tools } /// Set max tokens per response -let withMaxTokens (agent: Agent) (tokens: Int64) : Agent = +let withMaxTokens (agent: Agent) (tokens: Int) : Agent = let validated = Darklang.LLM.Internal.Validation.validateMaxTokens tokens agent.model.outputTokens { agent with maxTokens = validated } /// Set max agentic turns -let withMaxTurns (agent: Agent) (turns: Int64) : Agent = +let withMaxTurns (agent: Agent) (turns: Int) : Agent = let validated = Darklang.LLM.Internal.Validation.validateMaxTurns turns { agent with maxTurns = validated } diff --git a/packages/darklang/llm/examples/basics.dark b/packages/darklang/llm/examples/basics.dark index ec805a4d90..6b159fb509 100644 --- a/packages/darklang/llm/examples/basics.dark +++ b/packages/darklang/llm/examples/basics.dark @@ -35,7 +35,7 @@ let askWith (modelName: String) (question: String) : String = /// Create an agent with a given model and token limit, then chat let chatWithModel (model: Models.Model) - (maxTokens: Int64) + (maxTokens: Int) (question: String) : String = let agent = @@ -87,7 +87,7 @@ let summarize (text: String) : String = (Agent.create ()) |> Agent.withModel Models.Anthropic.haiku45 |> Agent.withSystemPrompt "Summarize the following text in 2-3 sentences." - |> Agent.withMaxTokens 200L + |> Agent.withMaxTokens 200I |> Agent.withTemperature 0.3 match Agent.chat agent text with @@ -100,7 +100,7 @@ let creative (prompt: String) : String = let agent = (Agent.create ()) |> Agent.withSystemPrompt "You are a creative writer. Be imaginative and expressive." - |> Agent.withMaxTokens 1000L + |> Agent.withMaxTokens 1000I |> Agent.withTemperature 0.9 match Agent.chat agent prompt with @@ -113,7 +113,7 @@ let factual (question: String) : String = let agent = (Agent.create ()) |> Agent.withSystemPrompt "Provide accurate, factual information. Be concise and precise." - |> Agent.withMaxTokens 500L + |> Agent.withMaxTokens 500I |> Agent.withTemperature 0.1 match Agent.chat agent question with diff --git a/packages/darklang/llm/examples/code-agent.dark b/packages/darklang/llm/examples/code-agent.dark index 59eab20ca7..d99ad6e27c 100644 --- a/packages/darklang/llm/examples/code-agent.dark +++ b/packages/darklang/llm/examples/code-agent.dark @@ -15,8 +15,8 @@ let agent = (Darklang.LLM.Agent.create ()) |> Darklang.LLM.Agent.withSystemPrompt systemPrompt |> Darklang.LLM.Agent.withFileTools - |> Darklang.LLM.Agent.withMaxTokens 2000L - |> Darklang.LLM.Agent.withMaxTurns 10L + |> Darklang.LLM.Agent.withMaxTokens 2000I + |> Darklang.LLM.Agent.withMaxTurns 10I |> Darklang.LLM.Agent.withTemperature 0.2 diff --git a/packages/darklang/llm/examples/explainer.dark b/packages/darklang/llm/examples/explainer.dark index c043dce158..352afccdac 100644 --- a/packages/darklang/llm/examples/explainer.dark +++ b/packages/darklang/llm/examples/explainer.dark @@ -14,14 +14,14 @@ let thinkingAgent = (Darklang.LLM.Agent.create ()) |> Darklang.LLM.Agent.withSystemPrompt systemPrompt |> Darklang.LLM.Agent.withThinking 2000I - |> Darklang.LLM.Agent.withMaxTokens 4000L + |> Darklang.LLM.Agent.withMaxTokens 4000I /// Create a basic explainer without extended thinking (faster) let basicAgent = (Darklang.LLM.Agent.create ()) |> Darklang.LLM.Agent.withSystemPrompt systemPrompt - |> Darklang.LLM.Agent.withMaxTokens 1500L + |> Darklang.LLM.Agent.withMaxTokens 1500I |> Darklang.LLM.Agent.withTemperature 0.4 diff --git a/packages/darklang/llm/examples/git-commit.dark b/packages/darklang/llm/examples/git-commit.dark index d81004200c..df33477c79 100644 --- a/packages/darklang/llm/examples/git-commit.dark +++ b/packages/darklang/llm/examples/git-commit.dark @@ -20,8 +20,8 @@ let agent = |> Darklang.LLM.Agent.withShellTool "get_staged_files" "Get files staged for commit" "git diff --cached --name-only" |> Darklang.LLM.Agent.withShellTool "get_diff" "Get diff of staged changes" "git diff --cached" |> Darklang.LLM.Agent.withShellTool "get_recent_commits" "Get last 5 commits for style" "git log --oneline -n 5" - |> Darklang.LLM.Agent.withMaxTokens 500L - |> Darklang.LLM.Agent.withMaxTurns 5L + |> Darklang.LLM.Agent.withMaxTokens 500I + |> Darklang.LLM.Agent.withMaxTurns 5I |> Darklang.LLM.Agent.withTemperature 0.3 diff --git a/packages/darklang/llm/examples/json-extractor.dark b/packages/darklang/llm/examples/json-extractor.dark index b5a0a3bfe3..2ec2291d05 100644 --- a/packages/darklang/llm/examples/json-extractor.dark +++ b/packages/darklang/llm/examples/json-extractor.dark @@ -4,7 +4,7 @@ module Darklang.LLM.Examples.JsonExtractor /// Shared config: GPT-4o-mini with JSON mode at temperature 0.0 -let jsonExtractorAgent (systemPrompt: String) (maxTokens: Int64) : Agent.Agent = +let jsonExtractorAgent (systemPrompt: String) (maxTokens: Int) : Agent.Agent = (Agent.create ()) |> Agent.withSystemPrompt systemPrompt |> Agent.useGPT4oMini @@ -19,7 +19,7 @@ let contactPrompt = "Extract contact info as JSON: {name, email, phone, company, title, address}. Use null for missing fields." -let contactAgent = jsonExtractorAgent contactPrompt 500L +let contactAgent = jsonExtractorAgent contactPrompt 500I /// Run an extraction agent with a prompt prefix @@ -66,7 +66,7 @@ let eventPrompt = "Extract event info as JSON: {title, date (YYYY-MM-DD), time (HH:MM), location, description, attendees:[]}." -let eventAgent = jsonExtractorAgent eventPrompt 500L +let eventAgent = jsonExtractorAgent eventPrompt 500I /// Extract event information from text @@ -81,7 +81,7 @@ let entityPrompt = "Extract named entities as JSON: {people:[], organizations:[], locations:[], dates:[], amounts:[]}." -let entityAgent = jsonExtractorAgent entityPrompt 1000L +let entityAgent = jsonExtractorAgent entityPrompt 1000I /// Extract named entities from text @@ -96,7 +96,7 @@ let sentimentPrompt = "Analyze sentiment as JSON: {overall_sentiment, confidence (0-1), emotions:[], key_phrases:[], summary}." -let sentimentAgent = jsonExtractorAgent sentimentPrompt 500L +let sentimentAgent = jsonExtractorAgent sentimentPrompt 500I /// Analyze sentiment of text @@ -110,6 +110,6 @@ let analyzeSentiment (text: String) : String = /// Extract data using a custom schema description (uses GPT-4o for complex schemas) let extractWithSchema (schemaDescription: String) (text: String) : String = let agent = - (jsonExtractorAgent $"Extract data as JSON matching: {schemaDescription}" 2000L) + (jsonExtractorAgent $"Extract data as JSON matching: {schemaDescription}" 2000I) |> Agent.useGPT4o runExtraction agent "Extract from" text diff --git a/packages/darklang/llm/examples/multi-model.dark b/packages/darklang/llm/examples/multi-model.dark index cb3c7a8f41..ca3e473605 100644 --- a/packages/darklang/llm/examples/multi-model.dark +++ b/packages/darklang/llm/examples/multi-model.dark @@ -20,7 +20,7 @@ let askModel let agent = (Agent.create ()) |> Agent.withModel model - |> Agent.withMaxTokens 500L + |> Agent.withMaxTokens 500I match Agent.run agent prompt with | Ok result -> diff --git a/packages/darklang/llm/examples/news-digest.dark b/packages/darklang/llm/examples/news-digest.dark index d857eb65e3..2ff3792b34 100644 --- a/packages/darklang/llm/examples/news-digest.dark +++ b/packages/darklang/llm/examples/news-digest.dark @@ -14,8 +14,8 @@ let agent = (Darklang.LLM.Agent.create ()) |> Darklang.LLM.Agent.withSystemPrompt systemPrompt |> Darklang.LLM.Agent.withWebSearch - |> Darklang.LLM.Agent.withMaxTokens 1000L - |> Darklang.LLM.Agent.withMaxTurns 2L + |> Darklang.LLM.Agent.withMaxTokens 1000I + |> Darklang.LLM.Agent.withMaxTurns 2I |> Darklang.LLM.Agent.withTemperature 0.2 diff --git a/packages/darklang/llm/examples/ollama-translator.dark b/packages/darklang/llm/examples/ollama-translator.dark index cd0a170f2c..9d0292913f 100644 --- a/packages/darklang/llm/examples/ollama-translator.dark +++ b/packages/darklang/llm/examples/ollama-translator.dark @@ -10,7 +10,7 @@ let translate (word: String) (language: String) : String = (Darklang.LLM.Agent.create ()) |> Darklang.LLM.Agent.withModel Darklang.LLM.Models.Local.llama3 |> Darklang.LLM.Agent.withSystemPrompt "You are a translator. Reply with ONLY the translated word, nothing else." - |> Darklang.LLM.Agent.withMaxTokens 50L + |> Darklang.LLM.Agent.withMaxTokens 50I match Darklang.LLM.Agent.run agent $"Translate '{word}' to {language}" with | Ok result -> result.response diff --git a/packages/darklang/llm/examples/research.dark b/packages/darklang/llm/examples/research.dark index 1da9dc5ce5..45583a9603 100644 --- a/packages/darklang/llm/examples/research.dark +++ b/packages/darklang/llm/examples/research.dark @@ -17,8 +17,8 @@ let agent = |> Darklang.LLM.Agent.withWebSearch |> Darklang.LLM.Agent.withWebFetchCitations |> Darklang.LLM.Agent.withThinking 4000I - |> Darklang.LLM.Agent.withMaxTokens 8000L - |> Darklang.LLM.Agent.withMaxTurns 3L + |> Darklang.LLM.Agent.withMaxTokens 8000I + |> Darklang.LLM.Agent.withMaxTurns 3I /// Quick research agent (no thinking, faster) @@ -27,8 +27,8 @@ let quickAgent = |> Darklang.LLM.Agent.withSystemPrompt systemPrompt |> Darklang.LLM.Agent.useHaiku |> Darklang.LLM.Agent.withWebSearch - |> Darklang.LLM.Agent.withMaxTokens 2000L - |> Darklang.LLM.Agent.withMaxTurns 2L + |> Darklang.LLM.Agent.withMaxTokens 2000I + |> Darklang.LLM.Agent.withMaxTurns 2I /// Research a topic thoroughly diff --git a/packages/darklang/llm/examples/url-reader.dark b/packages/darklang/llm/examples/url-reader.dark index 22504edff3..d9a94dcb02 100644 --- a/packages/darklang/llm/examples/url-reader.dark +++ b/packages/darklang/llm/examples/url-reader.dark @@ -13,8 +13,8 @@ Format: ## Summary → **Title:** → **Type:** → ### Key Points → ### Detai let baseAgent = (Agent.create ()) |> Agent.withSystemPrompt systemPrompt - |> Agent.withMaxTokens 1500L - |> Agent.withMaxTurns 2L + |> Agent.withMaxTokens 1500I + |> Agent.withMaxTurns 2I |> Agent.withTemperature 0.2 /// URL reader agent diff --git a/packages/darklang/llm/internal/agent-loop.dark b/packages/darklang/llm/internal/agent-loop.dark index 840f22a1b5..b4dbfc9adf 100644 --- a/packages/darklang/llm/internal/agent-loop.dark +++ b/packages/darklang/llm/internal/agent-loop.dark @@ -45,8 +45,8 @@ type AgentConfig = { model: Model systemPrompt: Stdlib.Option.Option tools: List - maxTokens: Int64 - maxTurns: Int64 + maxTokens: Int + maxTurns: Int temperature: Stdlib.Option.Option } @@ -57,7 +57,7 @@ type AgentConfig = type AgentResult = { response: String toolCalls: List - turns: Int64 + turns: Int usage: Provider.Usage // Full message history including tool calls/results (for multi-turn conversations) messages: List @@ -119,7 +119,7 @@ let processToolCalls type LoopState = { messages: List toolCalls: List - turn: Int64 + turn: Int totalUsage: Provider.Usage isDone: Bool // Extended data accumulation @@ -140,7 +140,7 @@ let initialState { messages = Stdlib.List.append history [ Provider.userMessage userMessage ] toolCalls = [] - turn = 1L + turn = 1I totalUsage = Provider.emptyUsage isDone = false thinking = Stdlib.Option.Option.None @@ -161,7 +161,7 @@ let buildRequest (config: AgentConfig) (state: LoopState) : Provider.Request = (Provider.createRequest config.model.id) |> Provider.withMessages state.messages |> Provider.withTools toolSchemas - |> Provider.withMaxTokens (Stdlib.Int.fromInt64 config.maxTokens) + |> Provider.withMaxTokens config.maxTokens let request = match config.systemPrompt with @@ -237,7 +237,7 @@ let runExtendedLoop { state with messages = updatedMessages toolCalls = newToolCalls - turn = state.turn + 1L + turn = state.turn + 1I totalUsage = newUsage thinking = accumulatedThinking webSearchResults = accumulatedSearches @@ -246,7 +246,7 @@ let runExtendedLoop if newState.turn > config.maxTurns then Stdlib.Result.Result.Error - $"Max turns exceeded ({Stdlib.Int64.toString newState.turn}/{Stdlib.Int64.toString config.maxTurns})" + $"Max turns exceeded ({Stdlib.Int.toString newState.turn}/{Stdlib.Int.toString config.maxTurns})" else runExtendedLoop provider config extensions newState diff --git a/packages/darklang/llm/internal/validation.dark b/packages/darklang/llm/internal/validation.dark index fdbf9032a1..3d0979612f 100644 --- a/packages/darklang/llm/internal/validation.dark +++ b/packages/darklang/llm/internal/validation.dark @@ -3,19 +3,19 @@ module Darklang.LLM.Internal.Validation -/// Clamp an Int64 value between min and max (inclusive) -let clamp (value: Int64) (min: Int64) (max: Int64) : Int64 = +/// Clamp an Int value between min and max (inclusive) +let clamp (value: Int) (min: Int) (max: Int) : Int = if value < min then min else if value > max then max else value /// Validate max tokens is within reasonable bounds -let validateMaxTokens (tokens: Int64) (maxAllowed: Int64) : Int64 = - clamp tokens 1L maxAllowed +let validateMaxTokens (tokens: Int) (maxAllowed: Int) : Int = + clamp tokens 1I maxAllowed /// Validate max turns is reasonable -let validateMaxTurns (turns: Int64) : Int64 = - clamp turns 1L 100L +let validateMaxTurns (turns: Int) : Int = + clamp turns 1I 100I /// Validate temperature with a custom max (provider-specific) let validateTemperature (temp: Float) (maxTemp: Float) : Float = diff --git a/packages/darklang/llm/models.dark b/packages/darklang/llm/models.dark index 39f292feef..42ea5181f9 100644 --- a/packages/darklang/llm/models.dark +++ b/packages/darklang/llm/models.dark @@ -22,42 +22,42 @@ type Model = providerId: String /// Maximum context window in tokens - contextTokens: Int64 + contextTokens: Int /// Maximum output tokens - outputTokens: Int64 } + outputTokens: Int } // ANTHROPIC MODELS // Current Claude models from https://platform.claude.com/docs/en/about-claude/models -let anthropicModel (id: String) (name: String) (outputTokens: Int64) : Model = +let anthropicModel (id: String) (name: String) (outputTokens: Int) : Model = Model { id = id name = name providerId = "anthropic" - contextTokens = 200000L + contextTokens = 200000I outputTokens = outputTokens } module Anthropic = // Claude 4.6 (newest, most capable - February 2026) - let opus46 = anthropicModel "claude-opus-4-6" "Claude Opus 4.6" 128000L - let sonnet46 = anthropicModel "claude-sonnet-4-6" "Claude Sonnet 4.6" 64000L + let opus46 = anthropicModel "claude-opus-4-6" "Claude Opus 4.6" 128000I + let sonnet46 = anthropicModel "claude-sonnet-4-6" "Claude Sonnet 4.6" 64000I // Claude 4.5 family - let opus45 = anthropicModel "claude-opus-4-5-20251101" "Claude Opus 4.5" 64000L - let sonnet45 = anthropicModel "claude-sonnet-4-5-20250929" "Claude Sonnet 4.5" 64000L - let haiku45 = anthropicModel "claude-haiku-4-5-20251001" "Claude Haiku 4.5" 64000L + let opus45 = anthropicModel "claude-opus-4-5-20251101" "Claude Opus 4.5" 64000I + let sonnet45 = anthropicModel "claude-sonnet-4-5-20250929" "Claude Sonnet 4.5" 64000I + let haiku45 = anthropicModel "claude-haiku-4-5-20251001" "Claude Haiku 4.5" 64000I // Claude 4 family - let sonnet4 = anthropicModel "claude-sonnet-4-20250514" "Claude Sonnet 4" 64000L - let opus4 = anthropicModel "claude-opus-4-20250514" "Claude Opus 4" 32000L + let sonnet4 = anthropicModel "claude-sonnet-4-20250514" "Claude Sonnet 4" 64000I + let opus4 = anthropicModel "claude-opus-4-20250514" "Claude Opus 4" 32000I // Claude 3.7 - let sonnet37 = anthropicModel "claude-3-7-sonnet-20250219" "Claude Sonnet 3.7" 64000L + let sonnet37 = anthropicModel "claude-3-7-sonnet-20250219" "Claude Sonnet 3.7" 64000I // Claude 3 (legacy) - let haiku3 = anthropicModel "claude-3-haiku-20240307" "Claude Haiku 3" 4096L + let haiku3 = anthropicModel "claude-3-haiku-20240307" "Claude Haiku 3" 4096I /// Balanced: good balance of speed/quality (Sonnet 4.6 - latest) let balanced = sonnet46 @@ -72,7 +72,7 @@ module Anthropic = // OPENAI MODELS // Current OpenAI models from https://platform.openai.com/docs/models -let openaiModel (id: String) (name: String) (contextTokens: Int64) (outputTokens: Int64) : Model = +let openaiModel (id: String) (name: String) (contextTokens: Int) (outputTokens: Int) : Model = Model { id = id name = name @@ -82,16 +82,16 @@ let openaiModel (id: String) (name: String) (contextTokens: Int64) (outputTokens module OpenAI = // GPT-4o family - let gpt4o = openaiModel "gpt-4o" "GPT-4o" 128000L 16384L - let gpt4oMini = openaiModel "gpt-4o-mini" "GPT-4o Mini" 128000L 16384L + let gpt4o = openaiModel "gpt-4o" "GPT-4o" 128000I 16384I + let gpt4oMini = openaiModel "gpt-4o-mini" "GPT-4o Mini" 128000I 16384I // O-series (reasoning models) - let o1 = openaiModel "o1" "O1" 200000L 100000L - let o1Mini = openaiModel "o1-mini" "O1 Mini" 128000L 65536L - let o3Mini = openaiModel "o3-mini" "O3 Mini" 200000L 100000L + let o1 = openaiModel "o1" "O1" 200000I 100000I + let o1Mini = openaiModel "o1-mini" "O1 Mini" 128000I 65536I + let o3Mini = openaiModel "o3-mini" "O3 Mini" 200000I 100000I // GPT-4 Turbo - let gpt4Turbo = openaiModel "gpt-4-turbo" "GPT-4 Turbo" 128000L 4096L + let gpt4Turbo = openaiModel "gpt-4-turbo" "GPT-4 Turbo" 128000I 4096I /// Balanced: good balance of speed/quality let balanced = gpt4o @@ -106,7 +106,7 @@ module OpenAI = // LOCAL MODELS (Ollama) // Common models available through Ollama -let ollamaModel (id: String) (name: String) (contextTokens: Int64) (outputTokens: Int64) : Model = +let ollamaModel (id: String) (name: String) (contextTokens: Int) (outputTokens: Int) : Model = Model { id = id name = name @@ -115,15 +115,15 @@ let ollamaModel (id: String) (name: String) (contextTokens: Int64) (outputTokens outputTokens = outputTokens } module Local = - let llama3 = ollamaModel "llama3" "Llama 3 8B" 8192L 4096L - let llama3_70b = ollamaModel "llama3:70b" "Llama 3 70B" 8192L 4096L - let llama31 = ollamaModel "llama3.1" "Llama 3.1 8B" 128000L 4096L - let llama32 = ollamaModel "llama3.2" "Llama 3.2 3B" 128000L 4096L - let codellama = ollamaModel "codellama" "Code Llama" 16384L 4096L - let mistral = ollamaModel "mistral" "Mistral 7B" 32768L 4096L - let mixtral = ollamaModel "mixtral" "Mixtral 8x7B" 32768L 4096L - let qwen25 = ollamaModel "qwen2.5" "Qwen 2.5" 128000L 8192L - let deepseekCoder = ollamaModel "deepseek-coder" "DeepSeek Coder" 16384L 4096L + let llama3 = ollamaModel "llama3" "Llama 3 8B" 8192I 4096I + let llama3_70b = ollamaModel "llama3:70b" "Llama 3 70B" 8192I 4096I + let llama31 = ollamaModel "llama3.1" "Llama 3.1 8B" 128000I 4096I + let llama32 = ollamaModel "llama3.2" "Llama 3.2 3B" 128000I 4096I + let codellama = ollamaModel "codellama" "Code Llama" 16384I 4096I + let mistral = ollamaModel "mistral" "Mistral 7B" 32768I 4096I + let mixtral = ollamaModel "mixtral" "Mixtral 8x7B" 32768I 4096I + let qwen25 = ollamaModel "qwen2.5" "Qwen 2.5" 128000I 8192I + let deepseekCoder = ollamaModel "deepseek-coder" "DeepSeek Coder" 16384I 4096I /// Balanced local model let balanced = llama3 @@ -135,14 +135,14 @@ module Local = let custom (providerId: String) (modelId: String) - (contextTokens: Int64) + (contextTokens: Int) : Model = Model { id = modelId name = "Custom: " ++ modelId providerId = providerId contextTokens = contextTokens - outputTokens = contextTokens / 4L } + outputTokens = contextTokens / 4I } // ENVIRONMENT-BASED MODEL SELECTION diff --git a/packages/darklang/llm/providers/openai.dark b/packages/darklang/llm/providers/openai.dark index 441dc7f67c..64bb39e72e 100644 --- a/packages/darklang/llm/providers/openai.dark +++ b/packages/darklang/llm/providers/openai.dark @@ -25,7 +25,7 @@ type Config = /// Human-readable name providerName: String /// Max context tokens - maxContextTokens: Int64 } + maxContextTokens: Int } /// OpenAI API configuration @@ -39,7 +39,7 @@ let openaiConfig () : Stdlib.Result.Result = baseUrl = "https://api.openai.com/v1/chat/completions" providerId = "openai" providerName = "OpenAI" - maxContextTokens = 128000L }) + maxContextTokens = 128000I }) | Error e -> Stdlib.Result.Result.Error e @@ -58,12 +58,12 @@ let azureConfig baseUrl = endpoint ++ "/openai/deployments/" ++ deploymentName ++ "/chat/completions?api-version=" ++ apiVersion providerId = "azure" providerName = "Azure OpenAI" - maxContextTokens = 128000L }) + maxContextTokens = 128000I }) | Error e -> Stdlib.Result.Result.Error e /// Custom OpenAI-compatible endpoint (no API key required) -let customConfig (baseUrl: String) (name: String) (maxTokens: Int64) : Config = +let customConfig (baseUrl: String) (name: String) (maxTokens: Int) : Config = Config { apiKey = Stdlib.Option.Option.None baseUrl = baseUrl @@ -578,7 +578,7 @@ let createWithKey (apiKey: String) : Stdlib.Result.Result = match Internal.ApiKeys.validate apiKey with | Ok _ -> let config = - { (customConfig "https://api.openai.com/v1/chat/completions" "OpenAI" 128000L) with + { (customConfig "https://api.openai.com/v1/chat/completions" "OpenAI" 128000I) with apiKey = Stdlib.Option.Option.Some apiKey providerId = "openai" } Stdlib.Result.Result.Ok(buildProvider config true) @@ -593,7 +593,7 @@ let createWithConfig (config: Config) : Provider = /// Create a custom OpenAI-compatible provider (no API key required) -let createCustom (baseUrl: String) (name: String) (maxTokens: Int64) : Provider = +let createCustom (baseUrl: String) (name: String) (maxTokens: Int) : Provider = let config = customConfig baseUrl name maxTokens buildProvider config false @@ -604,7 +604,7 @@ let createCustomWithKey (baseUrl: String) (name: String) (apiKey: String) - (maxTokens: Int64) + (maxTokens: Int) : Stdlib.Result.Result = match Internal.ApiKeys.validate apiKey with | Ok _ -> From 74df830e54cd6e6f770d21214f887484831fd77b Mon Sep 17 00:00:00 2001 From: OceanOak Date: Wed, 17 Jun 2026 14:11:56 +0000 Subject: [PATCH 18/61] Migrate diff edit-distance table from Int64 to Int --- packages/darklang/stdlib/diff.dark | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/darklang/stdlib/diff.dark b/packages/darklang/stdlib/diff.dark index 773e7cfb54..b15b0e3bbd 100644 --- a/packages/darklang/stdlib/diff.dark +++ b/packages/darklang/stdlib/diff.dark @@ -6,27 +6,27 @@ type DiffLine = | Removed of String /// Helper to safely index into a 2D list -let tableGet (table: List>) (row: Int) (col: Int) : Int64 = +let tableGet (table: List>) (row: Int) (col: Int) : Int = let r = Stdlib.Option.withDefault (Stdlib.List.getAt table row) [] - Stdlib.Option.withDefault (Stdlib.List.getAt r col) 0L + Stdlib.Option.withDefault (Stdlib.List.getAt r col) 0I /// Build the LCS length table -let buildTable (oldLines: List) (newLines: List) : List> = +let buildTable (oldLines: List) (newLines: List) : List> = let zeroRow = Stdlib.List.map (Stdlib.List.range 0I (Stdlib.List.length oldLines)) - (fun _i -> 0L) + (fun _i -> 0I) Stdlib.List.fold newLines [zeroRow] (fun table newLine -> let prevRow = Stdlib.Option.withDefault (Stdlib.List.last table) [] let pairs = Stdlib.List.indexedMap oldLines (fun i oldLine -> (i, oldLine)) let nextRow = - Stdlib.List.fold pairs [0L] (fun row pair -> + Stdlib.List.fold pairs [0I] (fun row pair -> let (i, oldLine) = pair - let above = Stdlib.Option.withDefault (Stdlib.List.getAt prevRow (i + 1I)) 0L - let diag = Stdlib.Option.withDefault (Stdlib.List.getAt prevRow i) 0L - let left = Stdlib.Option.withDefault (Stdlib.List.last row) 0L + let above = Stdlib.Option.withDefault (Stdlib.List.getAt prevRow (i + 1I)) 0I + let diag = Stdlib.Option.withDefault (Stdlib.List.getAt prevRow i) 0I + let left = Stdlib.Option.withDefault (Stdlib.List.last row) 0I let cell = - if oldLine == newLine then diag + 1L + if oldLine == newLine then diag + 1I else if above >= left then above else left Stdlib.List.append row [cell]) @@ -36,7 +36,7 @@ let buildTable (oldLines: List) (newLines: List) : List) (newLines: List) - (table: List>) + (table: List>) (i: Int) (j: Int) : List = From 3ea0ecd82d454496a2f433ae2571c563e9100ec9 Mon Sep 17 00:00:00 2001 From: OceanOak Date: Wed, 17 Jun 2026 18:57:38 +0000 Subject: [PATCH 19/61] Migrate LLM file-search counts to Int and fix provider maxContextTokens --- .../darklang/llm/providers/anthropic.dark | 2 +- packages/darklang/llm/providers/ollama.dark | 2 +- packages/darklang/llm/tools/file-system.dark | 22 +++++++++---------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/darklang/llm/providers/anthropic.dark b/packages/darklang/llm/providers/anthropic.dark index d865085b7b..9d30fa1cb3 100644 --- a/packages/darklang/llm/providers/anthropic.dark +++ b/packages/darklang/llm/providers/anthropic.dark @@ -677,7 +677,7 @@ let buildProvider (config: Config) : Provider = supportsStreaming = false supportsSystemPrompt = true supportsImages = true - maxContextTokens = 200000L } } + maxContextTokens = 200000I } } /// Create an Anthropic provider with default configuration diff --git a/packages/darklang/llm/providers/ollama.dark b/packages/darklang/llm/providers/ollama.dark index 0bad4a9ceb..88064c0143 100644 --- a/packages/darklang/llm/providers/ollama.dark +++ b/packages/darklang/llm/providers/ollama.dark @@ -18,7 +18,7 @@ let configWithUrl (baseUrl: String) : Providers.OpenAI.Config = baseUrl = baseUrl ++ "/v1/chat/completions" providerId = "ollama" providerName = "Ollama (Local)" - maxContextTokens = 128000L } + maxContextTokens = 128000I } /// Ollama configuration (reads OLLAMA_BASE_URL, defaults to localhost:11434) let config () : Providers.OpenAI.Config = diff --git a/packages/darklang/llm/tools/file-system.dark b/packages/darklang/llm/tools/file-system.dark index b83a8bef08..c393dbc20e 100644 --- a/packages/darklang/llm/tools/file-system.dark +++ b/packages/darklang/llm/tools/file-system.dark @@ -72,13 +72,13 @@ let formatDirectoryEntries (entries: List) : String = // FILE SEARCH type SearchState = - { filesScanned: Int64 + { filesScanned: Int matches: List hitResultLimit: Bool hitFileLimit: Bool } -let maxSearchResults : Int64 = 50L -let maxSearchFiles : Int64 = 200L +let maxSearchResults : Int = 50I +let maxSearchFiles : Int = 200I let filePathToDisplayPath (fullPath: String) : String = let cwd = Builtin.directoryCurrent () @@ -98,7 +98,7 @@ let searchFileForPattern if state.hitResultLimit || state.hitFileLimit then state else - let nextState = { state with filesScanned = state.filesScanned + 1L } + let nextState = { state with filesScanned = state.filesScanned + 1I } if nextState.filesScanned > maxSearchFiles then { nextState with hitFileLimit = true } else @@ -111,20 +111,20 @@ let searchFileForPattern let (_, finalState) = lines - |> Stdlib.List.fold (1L, nextState) (fun (lineNumber, currentState) line -> + |> Stdlib.List.fold (1I, nextState) (fun (lineNumber, currentState) line -> if currentState.hitResultLimit then - (lineNumber + 1L, currentState) + (lineNumber + 1I, currentState) else if Stdlib.String.contains line pattern then - let matchText = $"{displayPath}:{Stdlib.Int64.toString lineNumber}: {line}" + let matchText = $"{displayPath}:{Stdlib.Int.toString lineNumber}: {line}" let updatedMatches = Stdlib.List.append currentState.matches [ matchText ] - let reachedLimit = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length updatedMatches))) >= maxSearchResults + let reachedLimit = (Stdlib.List.length updatedMatches) >= maxSearchResults let updatedState = { currentState with matches = updatedMatches hitResultLimit = reachedLimit } - (lineNumber + 1L, updatedState) + (lineNumber + 1I, updatedState) else - (lineNumber + 1L, currentState)) + (lineNumber + 1I, currentState)) finalState @@ -233,7 +233,7 @@ let handleSearch (input: Json) : Stdlib.Result.Result = | Ok fullPath -> let initialState = SearchState - { filesScanned = 0L + { filesScanned = 0I matches = [] hitResultLimit = false hitFileLimit = false } From cc67ce61c6c2abf9771545dd4eb55e114b7d8b7b Mon Sep 17 00:00:00 2001 From: OceanOak Date: Wed, 17 Jun 2026 19:26:19 +0000 Subject: [PATCH 20/61] Migrate SCM package-ops counts from Int64 to Int --- .../Builtins.Matter/Libs/PM/PackageOps.fs | 62 ++++++++++--------- backend/src/LibDB/Queries.fs | 4 +- backend/src/LibExecution/ProgramTypes.fs | 2 +- .../LibExecution/ProgramTypesToDarkTypes.fs | 2 +- packages/darklang/cli/scm/branch.dark | 6 +- packages/darklang/cli/scm/discard.dark | 16 ++--- packages/darklang/cli/scm/log.dark | 8 +-- packages/darklang/cli/scm/review/app.dark | 16 +++-- packages/darklang/cli/scm/showCommit.dark | 2 +- packages/darklang/cli/scm/status.dark | 18 +++--- .../internal/dark-packages/dark-packages.dark | 4 +- .../lsp-server/fileSystemProvider.dark | 2 +- .../lsp-server/handleIncomingMessage.dark | 4 +- .../languageTools/lsp-server/pendingOps.dark | 2 +- .../languageTools/lsp-server/scm.dark | 16 ++--- packages/darklang/scm/packageOps.dark | 32 +++++----- 16 files changed, 99 insertions(+), 97 deletions(-) diff --git a/backend/src/Builtins/Builtins.Matter/Libs/PM/PackageOps.fs b/backend/src/Builtins/Builtins.Matter/Libs/PM/PackageOps.fs index de04b008c1..5ebe2a66d0 100644 --- a/backend/src/Builtins/Builtins.Matter/Libs/PM/PackageOps.fs +++ b/backend/src/Builtins/Builtins.Matter/Libs/PM/PackageOps.fs @@ -52,14 +52,14 @@ let fns (pm : PT.PackageManager) : List = parameters = [ Param.make "branchId" TUuid "Branch to add ops to" Param.make "ops" (TList(TCustomType(NR.ok (packageOpTypeName ()), []))) "" ] - returnType = TypeReference.result TInt64 TString + returnType = TypeReference.result TInt TString description = "Add package ops to the database as WIP (uncommitted) on the given branch. Returns the number of inserted ops on success (duplicates are skipped), or an error message on failure. Use scmCommitWipOpsByIds to commit WIP ops." fn = - let resultOk = Dval.resultOk KTInt64 KTString - let resultError = Dval.resultError KTInt64 KTString + let resultOk = Dval.resultOk KTInt KTString + let resultError = Dval.resultError KTInt KTString (function | exeState, _, _, [ DUuid branchId; DList(_vtTODO, ops) ] -> uply { @@ -84,7 +84,7 @@ let fns (pm : PT.PackageManager) : List = { values = exeState.values.builtIn; fns = exeState.fns.builtIn } let! _ = LibDB.Seed.evaluateAllValues builtins LibDB.PackageManager.rt - return resultOk (Dval.int64 insertedCount) + return resultOk (Dval.int (bigint insertedCount)) with ex -> return resultError (Dval.string ex.Message) } @@ -97,14 +97,14 @@ let fns (pm : PT.PackageManager) : List = { name = fn "scmGetRecentOps" 0 typeParams = [] - parameters = [ Param.make "limit" TInt64 "" ] + parameters = [ Param.make "limit" TInt "" ] returnType = TList(TCustomType(NR.ok (packageOpTypeName ()), [])) description = "Get recent package ops from the database." fn = function - | _, _, _, [ DInt64 limit ] -> + | _, _, _, [ DInt limit ] -> uply { - let! ops = LibDB.Queries.getRecentOps limit + let! ops = LibDB.Queries.getRecentOps (int64 (DarkInt.toBigInt limit)) return Dval.list (packageOpKT ()) (ops |> List.map PT2DT.PackageOp.toDT) } | _ -> incorrectArgs () @@ -117,7 +117,7 @@ let fns (pm : PT.PackageManager) : List = { name = fn "scmGetWipSummary" 0 typeParams = [] parameters = [ Param.make "branchId" TUuid "Branch ID" ] - returnType = TDict TInt64 + returnType = TDict TInt description = "Get summary of WIP ops on a branch (counts by type)." fn = function @@ -126,13 +126,13 @@ let fns (pm : PT.PackageManager) : List = let! summary = LibDB.Queries.getWipSummary branchId return Dval.dict - KTInt64 - [ "types", Dval.int64 summary.types - "values", Dval.int64 summary.values - "fns", Dval.int64 summary.fns - "renames", Dval.int64 summary.renames - "deprecations", Dval.int64 summary.deprecations - "total", Dval.int64 summary.total ] + KTInt + [ "types", Dval.int (bigint summary.types) + "values", Dval.int (bigint summary.values) + "fns", Dval.int (bigint summary.fns) + "renames", Dval.int (bigint summary.renames) + "deprecations", Dval.int (bigint summary.deprecations) + "total", Dval.int (bigint summary.total) ] } | _ -> incorrectArgs () sqlSpec = NotQueryable @@ -174,14 +174,14 @@ let fns (pm : PT.PackageManager) : List = { name = fn "scmGetWipOpCount" 0 typeParams = [] parameters = [ Param.make "branchId" TUuid "Branch ID" ] - returnType = TInt64 + returnType = TInt description = "Get count of WIP ops on a branch (fast, no deserialization)." fn = function | _, _, _, [ DUuid branchId ] -> uply { let! count = LibDB.Queries.getWipOpCount branchId - return Dval.int64 count + return Dval.int (bigint count) } | _ -> incorrectArgs () sqlSpec = NotQueryable @@ -193,14 +193,14 @@ let fns (pm : PT.PackageManager) : List = { name = fn "scmGetCommitCount" 0 typeParams = [] parameters = [ Param.make "branchId" TUuid "Branch ID" ] - returnType = TInt64 + returnType = TInt description = "Get count of commits on a branch (fast, no deserialization)." fn = function | _, _, _, [ DUuid branchId ] -> uply { let! count = LibDB.Queries.getCommitCount branchId - return Dval.int64 count + return Dval.int (bigint count) } | _ -> incorrectArgs () sqlSpec = NotQueryable @@ -301,19 +301,19 @@ let fns (pm : PT.PackageManager) : List = { name = fn "scmDiscard" 0 typeParams = [] parameters = [ Param.make "branchId" TUuid "Branch ID" ] - returnType = TypeReference.result TInt64 TString + returnType = TypeReference.result TInt TString description = "Discard all WIP ops on a branch. Returns the count of discarded ops on success, or an error message on failure." fn = - let resultOk = Dval.resultOk KTInt64 KTString - let resultError = Dval.resultError KTInt64 KTString + let resultOk = Dval.resultOk KTInt KTString + let resultError = Dval.resultError KTInt KTString (function | _, _, _, [ DUuid branchId ] -> uply { let! result = LibDB.Inserts.discardWipOps branchId match result with - | Ok count -> return resultOk (Dval.int64 count) + | Ok count -> return resultOk (Dval.int (bigint count)) | Error msg -> return resultError (Dval.string msg) } | _ -> incorrectArgs ()) @@ -327,14 +327,15 @@ let fns (pm : PT.PackageManager) : List = typeParams = [] parameters = [ Param.make "branchId" TUuid "Branch ID" - Param.make "limit" TInt64 "Maximum commits to return" ] + Param.make "limit" TInt "Maximum commits to return" ] returnType = TList(TCustomType(NR.ok (PT2DT.Commit.typeName ()), [])) description = "Get commit log for a branch ordered by date descending." fn = function - | _, _, _, [ DUuid branchId; DInt64 limit ] -> + | _, _, _, [ DUuid branchId; DInt limit ] -> uply { - let! commits = LibDB.Queries.getCommits branchId limit + let! commits = + LibDB.Queries.getCommits branchId (int64 (DarkInt.toBigInt limit)) return Dval.list (PT2DT.Commit.knownType ()) @@ -351,15 +352,18 @@ let fns (pm : PT.PackageManager) : List = typeParams = [] parameters = [ Param.make "branchId" TUuid "Branch ID" - Param.make "limit" TInt64 "Maximum commits to return" ] + Param.make "limit" TInt "Maximum commits to return" ] returnType = TList(TCustomType(NR.ok (PT2DT.Commit.typeName ()), [])) description = "Get commit log across the entire branch chain (current + ancestors), ordered by date descending." fn = function - | _, _, _, [ DUuid branchId; DInt64 limit ] -> + | _, _, _, [ DUuid branchId; DInt limit ] -> uply { - let! commits = LibDB.Queries.getCommitsForBranchChain branchId limit + let! commits = + LibDB.Queries.getCommitsForBranchChain + branchId + (int64 (DarkInt.toBigInt limit)) return Dval.list (PT2DT.Commit.knownType ()) diff --git a/backend/src/LibDB/Queries.fs b/backend/src/LibDB/Queries.fs index 5cf7606805..a9c0e9bfe1 100644 --- a/backend/src/LibDB/Queries.fs +++ b/backend/src/LibDB/Queries.fs @@ -531,7 +531,7 @@ let getCommits (branchId : PT.BranchId) (limit : int64) : Task> { hash = Hash(read.string "hash") message = read.string "message" createdAt = read.instant "created_at" - opCount = read.int64 "op_count" + opCount = read.int64 "op_count" |> bigint branchId = read.uuid "branch_id" branchName = read.string "branch_name" committerId = read.uuid "account_id" @@ -576,7 +576,7 @@ let getCommitsForBranchChain { hash = Hash(read.string "hash") message = read.string "message" createdAt = read.instant "created_at" - opCount = read.int64 "op_count" + opCount = read.int64 "op_count" |> bigint branchId = read.uuid "branch_id" branchName = read.string "branch_name" committerId = read.uuid "account_id" diff --git a/backend/src/LibExecution/ProgramTypes.fs b/backend/src/LibExecution/ProgramTypes.fs index 380c8c26e5..1a6f244b3c 100644 --- a/backend/src/LibExecution/ProgramTypes.fs +++ b/backend/src/LibExecution/ProgramTypes.fs @@ -69,7 +69,7 @@ type Commit = { hash : Hash message : string createdAt : NodaTime.Instant - opCount : int64 + opCount : bigint committerId : AccountID committerName : string branchId : BranchId diff --git a/backend/src/LibExecution/ProgramTypesToDarkTypes.fs b/backend/src/LibExecution/ProgramTypesToDarkTypes.fs index 62bc64094f..04a6be549f 100644 --- a/backend/src/LibExecution/ProgramTypesToDarkTypes.fs +++ b/backend/src/LibExecution/ProgramTypesToDarkTypes.fs @@ -1807,7 +1807,7 @@ module Commit = [ "hash", Hash.toDT c.hash "message", DString c.message "createdAt", DDateTime(DarkDateTime.fromInstant c.createdAt) - "opCount", DInt64 c.opCount + "opCount", Dval.int c.opCount "branchId", DUuid c.branchId "branchName", DString c.branchName "committerId", DUuid c.committerId diff --git a/packages/darklang/cli/scm/branch.dark b/packages/darklang/cli/scm/branch.dark index 363a1de52e..ec9d9fb90f 100644 --- a/packages/darklang/cli/scm/branch.dark +++ b/packages/darklang/cli/scm/branch.dark @@ -13,8 +13,8 @@ let branchAnnotation let wip = SCM.PackageOps.getWipSummary branch.id let pendingPart = - if wip.total > 0L then - let total = Stdlib.Int64.toString wip.total + if wip.total > 0I then + let total = Stdlib.Int.toString wip.total [ Colors.warning $"{total} pending" ] else [] @@ -23,7 +23,7 @@ let branchAnnotation if isMain then [] else - let commits = SCM.PackageOps.getCommits branch.id 1000L + let commits = SCM.PackageOps.getCommits branch.id 1000I let commitCount = Stdlib.List.length commits if commitCount > 0I then diff --git a/packages/darklang/cli/scm/discard.dark b/packages/darklang/cli/scm/discard.dark index 5e76d256c8..db3135c9e8 100644 --- a/packages/darklang/cli/scm/discard.dark +++ b/packages/darklang/cli/scm/discard.dark @@ -9,21 +9,21 @@ let execute (state: AppState) (args: List) : AppState = let summary = SCM.PackageOps.getWipSummary branchId - if summary.total == 0L then + if summary.total == 0I then Stdlib.printLine "Nothing to discard." state else let header = if autoConfirm then "Discarded:" else "Will discard:" Stdlib.printLine header - if summary.types > 0L then - Stdlib.printLine $" {Stdlib.Int64.toString summary.types} type(s)" + if summary.types > 0I then + Stdlib.printLine $" {Stdlib.Int.toString summary.types} type(s)" - if summary.values > 0L then - Stdlib.printLine $" {Stdlib.Int64.toString summary.values} value(s)" + if summary.values > 0I then + Stdlib.printLine $" {Stdlib.Int.toString summary.values} value(s)" - if summary.fns > 0L then - Stdlib.printLine $" {Stdlib.Int64.toString summary.fns} function(s)" + if summary.fns > 0I then + Stdlib.printLine $" {Stdlib.Int.toString summary.fns} function(s)" Stdlib.printLine "" @@ -38,7 +38,7 @@ let execute (state: AppState) (args: List) : AppState = if proceed then match SCM.PackageOps.discard branchId with | Ok count -> - Stdlib.printLine (Colors.success $"Discarded {Stdlib.Int64.toString count} ops.") + Stdlib.printLine (Colors.success $"Discarded {Stdlib.Int.toString count} ops.") state | Error e -> Stdlib.printLine (Colors.error $"Discard failed: {e}") diff --git a/packages/darklang/cli/scm/log.dark b/packages/darklang/cli/scm/log.dark index 6dda80be5e..6ae10f8ec0 100644 --- a/packages/darklang/cli/scm/log.dark +++ b/packages/darklang/cli/scm/log.dark @@ -7,10 +7,10 @@ let execute (state: AppState) (args: List) : AppState = let limit = match args with | [ limitStr ] -> - match Stdlib.Int64.parse limitStr with + match Stdlib.Int.parse limitStr with | Ok n -> n - | Error _ -> 20L - | _ -> 20L + | Error _ -> 20I + | _ -> 20I let commits = SCM.PackageOps.getCommitsWithAncestors branchId limit @@ -23,7 +23,7 @@ let execute (state: AppState) (args: List) : AppState = |> Stdlib.List.iter (fun c -> let id = LanguageTools.ProgramTypes.hashToShort c.hash let createdAt = Stdlib.DateTime.toString_v0 c.createdAt - let opCount = Stdlib.Int64.toString c.opCount + let opCount = Stdlib.Int.toString c.opCount let commitBranchId = Stdlib.Uuid.toString c.branchId let isAncestor = commitBranchId != currentBranchIdStr && commitBranchId != "" diff --git a/packages/darklang/cli/scm/review/app.dark b/packages/darklang/cli/scm/review/app.dark index 804078c019..3d3a97f4e4 100644 --- a/packages/darklang/cli/scm/review/app.dark +++ b/packages/darklang/cli/scm/review/app.dark @@ -59,8 +59,8 @@ let loadBranchList () : List = branches |> Stdlib.List.filterMap (fun b -> // bridge: packageOps counts are Int64 (out of scope); convert to Int at the boundary - let wipOpCount = Stdlib.Int.fromInt64 (SCM.PackageOps.getWipOpCount b.id) - let committedCount = Stdlib.Int.fromInt64 (SCM.PackageOps.getCommitCount b.id) + let wipOpCount = SCM.PackageOps.getWipOpCount b.id + let committedCount = SCM.PackageOps.getCommitCount b.id if wipOpCount == 0I && committedCount == 0I then Stdlib.Option.Option.None else @@ -234,7 +234,7 @@ let buildModuleDiffState (detail: DetailState) (modPath: String) : DiffState = returnTo = DiffReturnTo.ReturnToDetail detail } let buildCommitList (detail: DetailState) : CommitListState = - let commits = SCM.PackageOps.getCommits detail.branchId 20L + let commits = SCM.PackageOps.getCommits detail.branchId 20I let entries = Stdlib.List.map commits (fun c -> let shortHash = LanguageTools.ProgramTypes.hashToShort c.hash @@ -245,8 +245,7 @@ let buildCommitList (detail: DetailState) : CommitListState = fullHash = fullHash message = c.message date = date - // Commit.opCount is Int64 (SCM model); bridge into the review's Int model. - opCount = Stdlib.Int.fromInt64 c.opCount }) + opCount = c.opCount }) CommitListState { branchName = detail.branchName branchId = detail.branchId @@ -566,8 +565,7 @@ let buildDetailForBranch (branchId: Uuid) : Screen = match SCM.Branch.get branchId with | Some b -> b.name | None -> "unknown" - // bridge: getWipOpCount is Int64 (out of scope); convert to Int at the boundary - let wipCount = Stdlib.Int.fromInt64 (SCM.PackageOps.getWipOpCount branchId) + let wipCount = SCM.PackageOps.getWipOpCount branchId let item = BranchReviewItem { branchId = branchId @@ -611,7 +609,7 @@ let printWipItems (branchId: Uuid) : Unit = Stdlib.List.iter diffLines (fun line -> printDiffLine line)) let printRecentCommits (branchId: Uuid) : Unit = - let commits = SCM.PackageOps.getCommits branchId 10L + let commits = SCM.PackageOps.getCommits branchId 10I if commits != [] then Stdlib.printLine "" Stdlib.printLine (Darklang.Cli.Colors.boldText "Recent commits:") @@ -619,7 +617,7 @@ let printRecentCommits (branchId: Uuid) : Unit = let shortHash = LanguageTools.ProgramTypes.hashToShort c.hash let date = Stdlib.DateTime.toString c.createdAt let hashText = Darklang.Cli.Colors.colorize Darklang.Cli.Colors.yellow shortHash - let opsText = Darklang.Cli.Colors.dimText $"({Stdlib.Int64.toString c.opCount} ops)" + let opsText = Darklang.Cli.Colors.dimText $"({Stdlib.Int.toString c.opCount} ops)" let dateText = Darklang.Cli.Colors.dimText date Stdlib.printLine $" {hashText} {c.message} {opsText} {dateText}") diff --git a/packages/darklang/cli/scm/showCommit.dark b/packages/darklang/cli/scm/showCommit.dark index 5d1773d5d2..0aaecbbd78 100644 --- a/packages/darklang/cli/scm/showCommit.dark +++ b/packages/darklang/cli/scm/showCommit.dark @@ -14,7 +14,7 @@ let execute (state: AppState) (args: List) : AppState = let fullIdStr = if Stdlib.String.length commitHashStr < 64I then // Try to find a matching commit (search current branch and ancestors) - let commits = SCM.PackageOps.getCommitsWithAncestors branchId 100L + let commits = SCM.PackageOps.getCommitsWithAncestors branchId 100I let matching = commits diff --git a/packages/darklang/cli/scm/status.dark b/packages/darklang/cli/scm/status.dark index 1e420feb3c..45a7f1a424 100644 --- a/packages/darklang/cli/scm/status.dark +++ b/packages/darklang/cli/scm/status.dark @@ -14,23 +14,23 @@ let execute (state: AppState) (args: List) : AppState = let summary = SCM.PackageOps.getWipSummary branchId - if summary.total == 0L then + if summary.total == 0I then Stdlib.printLine "No uncommitted changes." else Stdlib.printLine "Uncommitted changes:" - if summary.types > 0L then - Stdlib.printLine $" {Stdlib.Int64.toString summary.types} type(s)" + if summary.types > 0I then + Stdlib.printLine $" {Stdlib.Int.toString summary.types} type(s)" - if summary.values > 0L then - Stdlib.printLine $" {Stdlib.Int64.toString summary.values} value(s)" + if summary.values > 0I then + Stdlib.printLine $" {Stdlib.Int.toString summary.values} value(s)" - if summary.fns > 0L then - Stdlib.printLine $" {Stdlib.Int64.toString summary.fns} function(s)" + if summary.fns > 0I then + Stdlib.printLine $" {Stdlib.Int.toString summary.fns} function(s)" - if summary.deprecations > 0L then + if summary.deprecations > 0I then Stdlib.printLine - $" {Stdlib.Int64.toString summary.deprecations} deprecation(s)" + $" {Stdlib.Int.toString summary.deprecations} deprecation(s)" [ "" "Use 'commit \"message\"' to commit these changes." diff --git a/packages/darklang/internal/dark-packages/dark-packages.dark b/packages/darklang/internal/dark-packages/dark-packages.dark index 9fe9d36120..e40f57f77a 100644 --- a/packages/darklang/internal/dark-packages/dark-packages.dark +++ b/packages/darklang/internal/dark-packages/dark-packages.dark @@ -113,7 +113,7 @@ let opsPostHandlerFn (req: HttpRequest) : HttpResponse = | Ok ops -> match SCM.PackageOps.add serverBranchId ops with | Ok insertedCount -> - let countStr = Stdlib.Int64.toString insertedCount + let countStr = Stdlib.Int.toString insertedCount Stdlib.Http.responseWithText $"Successfully received and applied {countStr} ops" 200I | Error errorMsg -> Stdlib.Http.serverError errorMsg | Error _err -> @@ -127,7 +127,7 @@ let opsGetHandlerFn (req: HttpRequest) : HttpResponse = match HttpRequest.queryParam req "limit" with | None -> Stdlib.Http.badRequest "Missing required query parameter: 'limit'" | Some limitStr -> - match Stdlib.Int64.parse limitStr with + match Stdlib.Int.parse limitStr with | Error _ -> Stdlib.Http.badRequest "Invalid 'limit' parameter. Expected integer." | Ok limit -> let ops = SCM.PackageOps.getRecent limit diff --git a/packages/darklang/languageTools/lsp-server/fileSystemProvider.dark b/packages/darklang/languageTools/lsp-server/fileSystemProvider.dark index 7947096530..e1901a7c22 100644 --- a/packages/darklang/languageTools/lsp-server/fileSystemProvider.dark +++ b/packages/darklang/languageTools/lsp-server/fileSystemProvider.dark @@ -464,7 +464,7 @@ module WriteFile = if (Stdlib.List.isEmpty allOps) |> Stdlib.Bool.not then SCM.PackageOps.add branchId allOps else - Stdlib.Result.Result.Ok 0L + Stdlib.Result.Result.Ok 0I match addResult with | Error err -> diff --git a/packages/darklang/languageTools/lsp-server/handleIncomingMessage.dark b/packages/darklang/languageTools/lsp-server/handleIncomingMessage.dark index cb08f6ec5d..17be56b70b 100644 --- a/packages/darklang/languageTools/lsp-server/handleIncomingMessage.dark +++ b/packages/darklang/languageTools/lsp-server/handleIncomingMessage.dark @@ -307,10 +307,10 @@ let handleIncomingMessage Scm.handleGetWipSummaryRequest state requestId | ("dark/scm/getCommits", Some requestId, Some(Object [ ("limit", Number n) ])) -> - Scm.handleGetCommitsRequest state requestId (Stdlib.Int64.fromFloat n) + Scm.handleGetCommitsRequest state requestId (Stdlib.Int.fromFloat n) | ("dark/scm/getCommits", Some requestId, _) -> - Scm.handleGetCommitsRequest state requestId 10L + Scm.handleGetCommitsRequest state requestId 10I | ("dark/scm/getWipOps", Some requestId, _) -> Scm.handleGetWipOpsRequest state requestId diff --git a/packages/darklang/languageTools/lsp-server/pendingOps.dark b/packages/darklang/languageTools/lsp-server/pendingOps.dark index ee593407f7..4440facab0 100644 --- a/packages/darklang/languageTools/lsp-server/pendingOps.dark +++ b/packages/darklang/languageTools/lsp-server/pendingOps.dark @@ -7,7 +7,7 @@ let handleGetPendingOpsRequest (params: Stdlib.Option.Option) : LspState = // Get last 20 recent ops - let ops = SCM.PackageOps.getRecent 20L + let ops = SCM.PackageOps.getRecent 20I let body = ops diff --git a/packages/darklang/languageTools/lsp-server/scm.dark b/packages/darklang/languageTools/lsp-server/scm.dark index 72dc5c1a74..a148b0e072 100644 --- a/packages/darklang/languageTools/lsp-server/scm.dark +++ b/packages/darklang/languageTools/lsp-server/scm.dark @@ -10,11 +10,11 @@ let handleGetWipSummaryRequest let responseJson = Stdlib.AltJson.Json.Object - [ ("types", Stdlib.AltJson.Json.Number(Stdlib.Int64.toFloat summary.types)) - ("values", Stdlib.AltJson.Json.Number(Stdlib.Int64.toFloat summary.values)) - ("fns", Stdlib.AltJson.Json.Number(Stdlib.Int64.toFloat summary.fns)) - ("renames", Stdlib.AltJson.Json.Number(Stdlib.Int64.toFloat summary.renames)) - ("total", Stdlib.AltJson.Json.Number(Stdlib.Int64.toFloat summary.total)) ] + [ ("types", Stdlib.AltJson.Json.Number(Stdlib.Int.toFloat summary.types)) + ("values", Stdlib.AltJson.Json.Number(Stdlib.Int.toFloat summary.values)) + ("fns", Stdlib.AltJson.Json.Number(Stdlib.Int.toFloat summary.fns)) + ("renames", Stdlib.AltJson.Json.Number(Stdlib.Int.toFloat summary.renames)) + ("total", Stdlib.AltJson.Json.Number(Stdlib.Int.toFloat summary.total)) ] let response = (JsonRPC.Response.Ok.make (Stdlib.Option.Option.Some requestId) responseJson) @@ -28,7 +28,7 @@ let handleGetWipSummaryRequest let handleGetCommitsRequest (state: LspState) (requestId: JsonRPC.RequestID) - (limit: Int64) + (limit: Int) : LspState = let commits = SCM.PackageOps.getCommitsWithAncestors state.currentBranchId limit @@ -39,7 +39,7 @@ let handleGetCommitsRequest [ ("hash", Stdlib.AltJson.Json.String c.hash) ("message", Stdlib.AltJson.Json.String c.message) ("createdAt", Stdlib.AltJson.Json.String (Stdlib.DateTime.toString_v0 c.createdAt)) - ("opCount", Stdlib.AltJson.Json.String (Stdlib.Int64.toString c.opCount)) + ("opCount", Stdlib.AltJson.Json.String (Stdlib.Int.toString c.opCount)) ("branchId", Stdlib.AltJson.Json.String (Stdlib.Uuid.toString c.branchId)) ("branchName", Stdlib.AltJson.Json.String c.branchName) ]) @@ -141,7 +141,7 @@ let handleDiscardRequest let responseJson = Stdlib.AltJson.Json.Object [ ("success", Stdlib.AltJson.Json.Bool true) - ("discardedCount", Stdlib.AltJson.Json.Number (Stdlib.Int64.toFloat count)) ] + ("discardedCount", Stdlib.AltJson.Json.Number (Stdlib.Int.toFloat count)) ] let response = (JsonRPC.Response.Ok.make (Stdlib.Option.Option.Some requestId) responseJson) diff --git a/packages/darklang/scm/packageOps.dark b/packages/darklang/scm/packageOps.dark index e955112477..5262755fcb 100644 --- a/packages/darklang/scm/packageOps.dark +++ b/packages/darklang/scm/packageOps.dark @@ -6,7 +6,7 @@ type Commit = { hash: LanguageTools.ProgramTypes.Hash message: String createdAt: DateTime - opCount: Int64 + opCount: Int branchId: Uuid branchName: String committerId: Uuid @@ -22,12 +22,12 @@ type Commit = let add (branchId: Uuid) (ops: List) - : Stdlib.Result.Result = + : Stdlib.Result.Result = Builtin.scmAddOps branchId ops /// Get recent package ops from the database -let getRecent (limit: Int64) : List = +let getRecent (limit: Int) : List = Builtin.scmGetRecentOps limit @@ -65,18 +65,18 @@ let locationToFqn (loc: LanguageTools.ProgramTypes.PackageLocation) : String = /// Summary of WIP (uncommitted) changes on a branch type WipSummary = - { types: Int64 - values: Int64 - fns: Int64 - renames: Int64 - deprecations: Int64 - total: Int64 } + { types: Int + values: Int + fns: Int + renames: Int + deprecations: Int + total: Int } /// Get a count from a Dict, defaulting to 0 -let getCount (d: Dict) (key: String) : Int64 = +let getCount (d: Dict) (key: String) : Int = match Stdlib.Dict.get d key with | Some v -> v - | None -> 0L + | None -> 0I /// Get summary of WIP ops on a branch (counts by type) let getWipSummary (branchId: Uuid) : WipSummary = @@ -91,11 +91,11 @@ let getWipSummary (branchId: Uuid) : WipSummary = total = getCount d "total" } /// Fast count of WIP ops on a branch (no deserialization) -let getWipOpCount (branchId: Uuid) : Int64 = +let getWipOpCount (branchId: Uuid) : Int = Builtin.scmGetWipOpCount branchId /// Fast count of commits on a branch (no deserialization) -let getCommitCount (branchId: Uuid) : Int64 = +let getCommitCount (branchId: Uuid) : Int = Builtin.scmGetCommitCount branchId /// Get WIP items on a branch (excludes auto-propagated ops) @@ -132,18 +132,18 @@ let commitOpIds /// Discard all WIP ops on a branch /// Returns the count of discarded ops on success, or an error message on failure -let discard (branchId: Uuid) : Stdlib.Result.Result = +let discard (branchId: Uuid) : Stdlib.Result.Result = Builtin.scmDiscard branchId /// Get commit log for a branch ordered by date descending -let getCommits (branchId: Uuid) (limit: Int64) : List = +let getCommits (branchId: Uuid) (limit: Int) : List = Builtin.scmGetCommits branchId limit /// Get commit log across the entire branch chain (current + ancestors), /// ordered by date descending. -let getCommitsWithAncestors (branchId: Uuid) (limit: Int64) : List = +let getCommitsWithAncestors (branchId: Uuid) (limit: Int) : List = Builtin.scmGetCommitsForBranchChain branchId limit From c46dc31f1a09a7a2601dc4971b2c95a19bc56155 Mon Sep 17 00:00:00 2001 From: OceanOak Date: Wed, 17 Jun 2026 19:55:50 +0000 Subject: [PATCH 21/61] Migrate misc CLI/stdlib counts from Int64 to Int --- packages/darklang/cli/packages/db.dark | 13 +++++------ packages/darklang/cli/packages/delete.dark | 8 +++---- packages/darklang/cli/packages/tree.dark | 22 +++++++++---------- packages/darklang/stdlib/cli/ui/progress.dark | 18 +++++++-------- packages/darklang/stdlib/retry.dark | 20 ++++++++--------- 5 files changed, 39 insertions(+), 42 deletions(-) diff --git a/packages/darklang/cli/packages/db.dark b/packages/darklang/cli/packages/db.dark index 19466b319d..08773ebc01 100644 --- a/packages/darklang/cli/packages/db.dark +++ b/packages/darklang/cli/packages/db.dark @@ -151,25 +151,24 @@ let viewDB (state: Cli.AppState) (dbName: String) : Cli.AppState = let result = resultOpt |> Stdlib.Option.withDefault "" Stdlib.printLine "" - let colWidth = 15L + let colWidth = 15I // Print header let keyHeader = - (Stdlib.String.padEnd "Key" " " (Stdlib.Int.fromInt64 colWidth)) |> Builtin.unwrap + (Stdlib.String.padEnd "Key" " " colWidth) |> Builtin.unwrap let fieldHeaders = fieldNames |> Stdlib.List.map (fun name -> - (Stdlib.String.padEnd name " " (Stdlib.Int.fromInt64 colWidth)) |> Builtin.unwrap) + (Stdlib.String.padEnd name " " colWidth) |> Builtin.unwrap) |> Stdlib.String.join "" Stdlib.printLine $"{keyHeader}{fieldHeaders}" let totalWidth = - colWidth - + (Stdlib.Int64.multiply (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length fieldNames))) colWidth) + colWidth + ((Stdlib.List.length fieldNames) * colWidth) - Stdlib.printLine (Stdlib.String.repeat "─" (Stdlib.Int.fromInt64 totalWidth)) + Stdlib.printLine (Stdlib.String.repeat "─" totalWidth) if Stdlib.String.isEmpty result then Stdlib.printLine " (empty)" @@ -185,7 +184,7 @@ let viewDB (state: Cli.AppState) (dbName: String) : Cli.AppState = let formatted = parts |> Stdlib.List.map (fun part -> - (Stdlib.String.padEnd part " " (Stdlib.Int.fromInt64 colWidth)) |> Builtin.unwrap) + (Stdlib.String.padEnd part " " colWidth) |> Builtin.unwrap) |> Stdlib.String.join "" Stdlib.printLine formatted) diff --git a/packages/darklang/cli/packages/delete.dark b/packages/darklang/cli/packages/delete.dark index e27e54faf3..219d17b19d 100644 --- a/packages/darklang/cli/packages/delete.dark +++ b/packages/darklang/cli/packages/delete.dark @@ -49,7 +49,7 @@ let countLiveDependents (branchId: Uuid) (targetLoc: LanguageTools.ProgramTypes.PackageLocation) (targetKind: LanguageTools.ProgramTypes.ItemKind) - : Int64 = + : Int = let deps = Builtin.depsGetDependents branchId [ (targetLoc, targetKind) ] let depSets = Query.loadDeprecationSets branchId deps @@ -57,8 +57,6 @@ let countLiveDependents let (depHash, _depLoc, _depKind) = entry Stdlib.Bool.not (Query.isDeprecated depSets depHash)) |> Stdlib.List.length - |> Stdlib.Int.toInt64 - |> Builtin.unwrap /// Translate delete's ParsedArgs into the equivalent `deprecate --kind obsolete` @@ -113,10 +111,10 @@ let execute (state: Cli.AppState) (args: List) : Cli.AppState = // Only gate `delete` adds over `deprecate --kind obsolete`: refuse // when LIVE dependents exist. Deprecated-only callers don't block. let depCount = countLiveDependents branchId targetLoc itemKind - if depCount > 0L && Stdlib.Bool.not parsed.ignoreDependents then + if depCount > 0I && Stdlib.Bool.not parsed.ignoreDependents then Stdlib.printLine (Colors.error - $"{Stdlib.Int64.toString depCount} live dependent(s) still reference this item.") + $"{Stdlib.Int.toString depCount} live dependent(s) still reference this item.") Stdlib.printLine "Use `deprecate` to give them time to migrate, or pass `--ignore-dependents` / `--force`." state diff --git a/packages/darklang/cli/packages/tree.dark b/packages/darklang/cli/packages/tree.dark index 5de71d5ec9..44fc4512ef 100644 --- a/packages/darklang/cli/packages/tree.dark +++ b/packages/darklang/cli/packages/tree.dark @@ -129,11 +129,11 @@ let execute (state: AppState) (args: List): AppState = match Stdlib.List.findFirst args (fun arg -> Stdlib.String.startsWith arg "--depth=") with | Some depthArg -> let depthStr = Stdlib.String.dropFirst depthArg 8I // Remove "--depth=" - match Stdlib.Int64.parse depthStr with + match Stdlib.Int.parse depthStr with | Ok depth -> - if depth > 0L && depth <= 10L then depth else 2L // Limit to reasonable range - | Error _ -> 2L - | None -> 2L // Default depth of 2 for concise but useful view + if depth > 0I && depth <= 10I then depth else 2I // Limit to reasonable range + | Error _ -> 2I + | None -> 2I // Default depth of 2 for concise but useful view // Determine starting location let branchId = state.currentBranchId @@ -157,7 +157,7 @@ let execute (state: AppState) (args: List): AppState = let locationStr = Packages.formatLocation startLocation Stdlib.printLine $"Package tree from {locationStr}:" Stdlib.printLine "" - displayTree branchId startLocation maxDepth 0L "" depSets includeDeprecated + displayTree branchId startLocation maxDepth 0I "" depSets includeDeprecated state @@ -169,13 +169,13 @@ let execute (state: AppState) (args: List): AppState = let displayTree (branchId: Uuid) (location: PackageLocation) - (remainingDepth: Int64) - (currentDepth: Int64) + (remainingDepth: Int) + (currentDepth: Int) (prefix: String) (depSets: Query.DeprecationSets) (includeDeprecated: Bool) : Unit = - if remainingDepth <= 0L then + if remainingDepth <= 0I then () else let modulePath = @@ -243,15 +243,15 @@ let displayTree Stdlib.printLine $"{fullPrefix}{icon}{name}{mark}" // Recursively display submodules - if entityType == EntityType.Module && remainingDepth > 1L then + if entityType == EntityType.Module && remainingDepth > 1I then let newPrefix = prefix ++ (if isLast then " " else "│ ") let newModulePath = Stdlib.List.append modulePath [name] let newLocation = PackageLocation.Module newModulePath displayTree branchId newLocation - (remainingDepth - 1L) - (currentDepth + 1L) + (remainingDepth - 1I) + (currentDepth + 1I) newPrefix depSets includeDeprecated diff --git a/packages/darklang/stdlib/cli/ui/progress.dark b/packages/darklang/stdlib/cli/ui/progress.dark index 1653d1b71c..787f742413 100644 --- a/packages/darklang/stdlib/cli/ui/progress.dark +++ b/packages/darklang/stdlib/cli/ui/progress.dark @@ -5,24 +5,24 @@ module Darklang.Stdlib.Cli.UI.Progress /// current: current progress value /// total: total value /// label: text to show after the bar -let bar (current: Int64) (total: Int64) (label: String) : Unit = - let width = 30L +let bar (current: Int) (total: Int) (label: String) : Unit = + let width = 30I let filled = - if total == 0L then 0L - else Stdlib.Int64.divide (current * width) total + if total == 0I then 0I + else Stdlib.Int.divide (current * width) total let empty = width - filled - let filledStr = Stdlib.String.repeat "#" (Stdlib.Int.fromInt64 filled) - let emptyStr = Stdlib.String.repeat "-" (Stdlib.Int.fromInt64 empty) + let filledStr = Stdlib.String.repeat "#" filled + let emptyStr = Stdlib.String.repeat "-" empty let pct = - if total == 0L then 0L - else Stdlib.Int64.divide (current * 100L) total + if total == 0I then 0I + else Stdlib.Int.divide (current * 100I) total Builtin.print - $"\r[{filledStr}{emptyStr}] {Stdlib.Int64.toString pct}% {label}" + $"\r[{filledStr}{emptyStr}] {Stdlib.Int.toString pct}% {label}" if current >= total then Builtin.printLine "" else () diff --git a/packages/darklang/stdlib/retry.dark b/packages/darklang/stdlib/retry.dark index a28c690d48..4f4c6883d3 100644 --- a/packages/darklang/stdlib/retry.dark +++ b/packages/darklang/stdlib/retry.dark @@ -2,8 +2,8 @@ module Darklang.Stdlib.Retry let withBackoffLoop - (maxAttempts: Int64) - (attempt: Int64) + (maxAttempts: Int) + (attempt: Int) (delayMs: Float) (fn: Unit -> Result.Result<'a, String>) : Result.Result<'a, String> = @@ -14,22 +14,22 @@ let withBackoffLoop Stdlib.Result.Result.Error e else let _ = Cli.Posix.sleep delayMs - withBackoffLoop maxAttempts (attempt + 1L) (Stdlib.Float.multiply delayMs 2.0) fn + withBackoffLoop maxAttempts (attempt + 1I) (Stdlib.Float.multiply delayMs 2.0) fn /// Retry a function up to maxAttempts times with exponential backoff. /// Starts with a 100ms delay, doubling each retry. /// Returns the first successful result, or the last error. let withBackoff - (maxAttempts: Int64) + (maxAttempts: Int) (fn: Unit -> Result.Result<'a, String>) : Result.Result<'a, String> = - withBackoffLoop maxAttempts 1L 100.0 fn + withBackoffLoop maxAttempts 1I 100.0 fn let withFixedDelayLoop - (maxAttempts: Int64) - (attempt: Int64) + (maxAttempts: Int) + (attempt: Int) (delayMs: Float) (fn: Unit -> Result.Result<'a, String>) : Result.Result<'a, String> = @@ -40,13 +40,13 @@ let withFixedDelayLoop Stdlib.Result.Result.Error e else let _ = Cli.Posix.sleep delayMs - withFixedDelayLoop maxAttempts (attempt + 1L) delayMs fn + withFixedDelayLoop maxAttempts (attempt + 1I) delayMs fn /// Retry with a fixed delay between attempts. let withFixedDelay - (maxAttempts: Int64) + (maxAttempts: Int) (delayMs: Float) (fn: Unit -> Result.Result<'a, String>) : Result.Result<'a, String> = - withFixedDelayLoop maxAttempts 1L delayMs fn + withFixedDelayLoop maxAttempts 1I delayMs fn From 959ce511326419ee4ca9b2d16a11eedd8649f95c Mon Sep 17 00:00:00 2001 From: OceanOak Date: Wed, 17 Jun 2026 20:20:14 +0000 Subject: [PATCH 22/61] Migrate outliner from Int64 to Int --- packages/darklang/cli/outliner/core.dark | 74 +++--- packages/darklang/cli/outliner/export.dark | 2 +- packages/darklang/cli/outliner/main.dark | 70 +++--- packages/darklang/cli/outliner/markdown.dark | 16 +- .../darklang/cli/outliner/outline-editor.dark | 20 +- packages/darklang/cli/outliner/tests.dark | 230 +++++++++--------- 6 files changed, 205 insertions(+), 207 deletions(-) diff --git a/packages/darklang/cli/outliner/core.dark b/packages/darklang/cli/outliner/core.dark index 5d3e96f5bd..e4a67c0096 100644 --- a/packages/darklang/cli/outliner/core.dark +++ b/packages/darklang/cli/outliner/core.dark @@ -7,57 +7,57 @@ type NodeContent = { text: String } type TreeStructure = - { children: List + { children: List collapsed: Bool } type Outline = { nodes: Dict structure: Dict - rootChildren: List - nextId: Int64 } + rootChildren: List + nextId: Int } type VisibleNode = - { id: Int64 + { id: Int text: String - depth: Int64 + depth: Int hasChildren: Bool - childCount: Int64 + childCount: Int isCollapsed: Bool } type Document = - { id: Int64 + { id: Int title: String outline: Outline } type PersistedData = { documents: List - activeDocId: Int64 - nextDocId: Int64 } + activeDocId: Int + nextDocId: Int } // --- Outline helpers --- -let k (id: Int64) : String = - Stdlib.Int64.toString id +let k (id: Int) : String = + Stdlib.Int.toString id let emptyOutline () : Outline = Outline { nodes = Stdlib.Dict.empty structure = Stdlib.Dict.empty rootChildren = [] - nextId = 1L } + nextId = 1I } -let getNodeText (outline: Outline) (id: Int64) : String = +let getNodeText (outline: Outline) (id: Int) : String = match Stdlib.Dict.get outline.nodes (k id) with | Some nc -> nc.text | None -> "" -let getStructure (outline: Outline) (id: Int64) : TreeStructure = +let getStructure (outline: Outline) (id: Int) : TreeStructure = match Stdlib.Dict.get outline.structure (k id) with | Some s -> s | None -> TreeStructure { children = []; collapsed = false } -let addNode (outline: Outline) (id: Int64) (text: String) : Outline = +let addNode (outline: Outline) (id: Int) (text: String) : Outline = let key = k id let nc = NodeContent { text = text } let ts = TreeStructure { children = []; collapsed = false } @@ -65,18 +65,18 @@ let addNode (outline: Outline) (id: Int64) (text: String) : Outline = nodes = Stdlib.Dict.setOverridingDuplicates outline.nodes key nc structure = Stdlib.Dict.setOverridingDuplicates outline.structure key ts } -let setNodeText (outline: Outline) (id: Int64) (text: String) : Outline = +let setNodeText (outline: Outline) (id: Int) (text: String) : Outline = let key = k id let nc = NodeContent { text = text } { outline with nodes = Stdlib.Dict.setOverridingDuplicates outline.nodes key nc } -let removeNodeData (outline: Outline) (id: Int64) : Outline = +let removeNodeData (outline: Outline) (id: Int) : Outline = let key = k id { outline with nodes = Stdlib.Dict.remove outline.nodes key structure = Stdlib.Dict.remove outline.structure key } -let setCollapsed (outline: Outline) (id: Int64) (collapsed: Bool) : Outline = +let setCollapsed (outline: Outline) (id: Int) (collapsed: Bool) : Outline = let key = k id match Stdlib.Dict.get outline.structure key with | Some s -> @@ -84,14 +84,14 @@ let setCollapsed (outline: Outline) (id: Int64) (collapsed: Bool) : Outline = { outline with structure = Stdlib.Dict.setOverridingDuplicates outline.structure key updated } | None -> outline -let getChildren (outline: Outline) (parentId: Stdlib.Option.Option) : List = +let getChildren (outline: Outline) (parentId: Stdlib.Option.Option) : List = match parentId with | None -> outline.rootChildren | Some pid -> let s = getStructure outline pid s.children -let setChildren (outline: Outline) (parentId: Stdlib.Option.Option) (newChildren: List) : Outline = +let setChildren (outline: Outline) (parentId: Stdlib.Option.Option) (newChildren: List) : Outline = match parentId with | None -> { outline with rootChildren = newChildren } | Some pid -> @@ -100,7 +100,7 @@ let setChildren (outline: Outline) (parentId: Stdlib.Option.Option) (newC let updated = { s with children = newChildren } { outline with structure = Stdlib.Dict.setOverridingDuplicates outline.structure key updated } -let findParentId (outline: Outline) (targetId: Int64) : Stdlib.Option.Option = +let findParentId (outline: Outline) (targetId: Int) : Stdlib.Option.Option = if Stdlib.List.any outline.rootChildren (fun id -> id == targetId) then Stdlib.Option.Option.None else @@ -110,14 +110,14 @@ let findParentId (outline: Outline) (targetId: Int64) : Stdlib.Option.Option id == targetId)) |> Stdlib.Option.map (fun pair -> let (key, _s) = pair - match Stdlib.Int64.parse key with + match Stdlib.Int.parse key with | Ok id -> id - | Error _ -> 0L) + | Error _ -> 0I) // --- List helpers --- -let insertIdAfter (ids: List) (afterId: Int64) (newId: Int64) : List = +let insertIdAfter (ids: List) (afterId: Int) (newId: Int) : List = ids |> Stdlib.List.fold [] (fun acc id -> if id == afterId then @@ -125,21 +125,21 @@ let insertIdAfter (ids: List) (afterId: Int64) (newId: Int64) : List) (i: Int64) (j: Int64) : List = +let swapAt (ids: List) (i: Int) (j: Int) : List = let iVal = - (Stdlib.List.getAt ids (Stdlib.Int.fromInt64 i)) |> Stdlib.Option.withDefault 0L + (Stdlib.List.getAt ids i) |> Stdlib.Option.withDefault 0I let jVal = - (Stdlib.List.getAt ids (Stdlib.Int.fromInt64 j)) |> Stdlib.Option.withDefault 0L + (Stdlib.List.getAt ids j) |> Stdlib.Option.withDefault 0I ids |> Stdlib.List.indexedMap (fun idx id -> - if idx == Stdlib.Int.fromInt64 i then jVal - else if idx == Stdlib.Int.fromInt64 j then iVal + if idx == i then jVal + else if idx == j then iVal else id) // --- Flatten --- -let flattenVisibleHelper (outline: Outline) (ids: List) (depth: Int64) : List = +let flattenVisibleHelper (outline: Outline) (ids: List) (depth: Int) : List = ids |> Stdlib.List.fold [] (fun acc id -> let text = getNodeText outline id @@ -151,26 +151,26 @@ let flattenVisibleHelper (outline: Outline) (ids: List) (depth: Int64) : text = text depth = depth hasChildren = hasChildren - childCount = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length s.children))) + childCount = (Stdlib.List.length s.children) isCollapsed = s.collapsed } let childNodes = if s.collapsed then [] else - flattenVisibleHelper outline s.children (depth + 1L) + flattenVisibleHelper outline s.children (depth + 1I) Stdlib.List.append acc (Stdlib.List.append [vn] childNodes)) let flattenVisible (outline: Outline) : List = - flattenVisibleHelper outline outline.rootChildren 0L + flattenVisibleHelper outline outline.rootChildren 0I // --- Outline builder --- let buildOutline - (nodeList: List<(Int64 * String)>) - (childMap: List<(Int64 * List)>) - (roots: List) - (nextId: Int64) + (nodeList: List<(Int * String)>) + (childMap: List<(Int * List)>) + (roots: List) + (nextId: Int) : Outline = let nodeEntries = nodeList diff --git a/packages/darklang/cli/outliner/export.dark b/packages/darklang/cli/outliner/export.dark index a649e5cbdb..2cea748cd3 100644 --- a/packages/darklang/cli/outliner/export.dark +++ b/packages/darklang/cli/outliner/export.dark @@ -1,7 +1,7 @@ module Darklang.Cli.Outliner.Export /// Convert an outline's nodes to generic Opml.Node tree for OPML export. -let toOpmlNodes (outline: Outline) (ids: List) : List = +let toOpmlNodes (outline: Outline) (ids: List) : List = ids |> Stdlib.List.map (fun id -> let text = getNodeText outline id diff --git a/packages/darklang/cli/outliner/main.dark b/packages/darklang/cli/outliner/main.dark index 398e835be7..e479cf6eb3 100644 --- a/packages/darklang/cli/outliner/main.dark +++ b/packages/darklang/cli/outliner/main.dark @@ -2,15 +2,15 @@ module Darklang.Cli.Outliner.Main type Screen = | DocPicker of ListPicker.State - | DocRenaming of docId: Int64 * ListPicker.State * TextEditor.State + | DocRenaming of docId: Int * ListPicker.State * TextEditor.State | Editor of OutlineEditor.State | ExportPicker of ListPicker.State<(String * String)> | ExportPath of ext: String * TextEditor.State type State = { documents: List - activeDocId: Int64 - nextDocId: Int64 + activeDocId: Int + nextDocId: Int screen: Screen } type KeyResult = @@ -24,12 +24,12 @@ type KeyResult = let activeDoc (state: State) : Document = let fallback = Document - { id = 0L; title = "Untitled"; outline = emptyOutline () } + { id = 0I; title = "Untitled"; outline = emptyOutline () } state.documents |> Stdlib.List.findFirst (fun d -> d.id == state.activeDocId) |> Stdlib.Option.withDefault fallback -let updateDoc (state: State) (docId: Int64) (updater: Document -> Document) : State = +let updateDoc (state: State) (docId: Int) (updater: Document -> Document) : State = { state with documents = Stdlib.List.map state.documents (fun d -> @@ -46,11 +46,11 @@ let createDocument (state: State) (title: String) : State = { state with documents = Stdlib.List.append state.documents [newDoc] activeDocId = state.nextDocId - nextDocId = state.nextDocId + 1L } + nextDocId = state.nextDocId + 1I } let editor = OutlineEditor.fromOutline newDoc.outline { newState with screen = Screen.Editor editor } -let deleteDocument (state: State) (docId: Int64) : State = +let deleteDocument (state: State) (docId: Int) : State = let docCount = Stdlib.List.length state.documents if docCount <= 1I then state @@ -69,7 +69,7 @@ let deleteDocument (state: State) (docId: Int64) : State = activeDocId = newActiveId } { newState with screen = Screen.DocPicker (makeDocPicker newState) } -let renameDocument (state: State) (docId: Int64) (newTitle: String) : State = +let renameDocument (state: State) (docId: Int) (newTitle: String) : State = updateDoc state docId (fun d -> { d with title = newTitle }) @@ -360,39 +360,39 @@ module Persistence = let defaultState () : State = let notesOutline = buildOutline - [ (1L, "Welcome to Outliner") - (2L, "Use arrow keys to navigate") - (3L, "Press Enter to edit an item") - (4L, "Press Tab to indent") - (5L, "Features") - (6L, "Collapse/expand with Space") - (7L, "Add new items with 'o'") - (8L, "Move items with Ctrl+Up/Down") - (9L, "Press / for document picker") ] - [ (1L, [2L; 3L; 4L]) - (5L, [6L; 7L; 8L]) ] - [1L; 5L; 9L] - 10L + [ (1I, "Welcome to Outliner") + (2I, "Use arrow keys to navigate") + (3I, "Press Enter to edit an item") + (4I, "Press Tab to indent") + (5I, "Features") + (6I, "Collapse/expand with Space") + (7I, "Add new items with 'o'") + (8I, "Move items with Ctrl+Up/Down") + (9I, "Press / for document picker") ] + [ (1I, [2I; 3I; 4I]) + (5I, [6I; 7I; 8I]) ] + [1I; 5I; 9I] + 10I let tasksOutline = buildOutline - [ (1L, "Today") - (2L, "Try out the outliner") - (3L, "Add your own items") - (4L, "Later") - (5L, "Organize your thoughts") - (6L, "Set up a project outline") ] - [ (1L, [2L; 3L]) - (4L, [5L; 6L]) ] - [1L; 4L] - 7L + [ (1I, "Today") + (2I, "Try out the outliner") + (3I, "Add your own items") + (4I, "Later") + (5I, "Organize your thoughts") + (6I, "Set up a project outline") ] + [ (1I, [2I; 3I]) + (4I, [5I; 6I]) ] + [1I; 4I] + 7I let doc1 = Document - { id = 1L + { id = 1I title = "My Notes" outline = notesOutline } let doc2 = Document - { id = 2L + { id = 2I title = "Tasks" outline = tasksOutline } let docs = [doc1; doc2] @@ -402,6 +402,6 @@ let defaultState () : State = $"{doc.title} ({Stdlib.Int.toString nodeCount} items)") State { documents = docs - activeDocId = 1L - nextDocId = 3L + activeDocId = 1I + nextDocId = 3I screen = Screen.DocPicker picker } diff --git a/packages/darklang/cli/outliner/markdown.dark b/packages/darklang/cli/outliner/markdown.dark index 0bc944a534..ebfa6c1bbf 100644 --- a/packages/darklang/cli/outliner/markdown.dark +++ b/packages/darklang/cli/outliner/markdown.dark @@ -1,19 +1,19 @@ module Darklang.Cli.Outliner.Markdown -let exportHelper (outline: Outline) (ids: List) (depth: Int64) : List = +let exportHelper (outline: Outline) (ids: List) (depth: Int) : List = ids |> Stdlib.List.fold [] (fun acc id -> let text = getNodeText outline id let s = getStructure outline id - let indent = Stdlib.String.repeat " " (Stdlib.Int.fromInt64 depth) + let indent = Stdlib.String.repeat " " depth let line = $"{indent}- {text}" let childLines = - exportHelper outline s.children (depth + 1L) + exportHelper outline s.children (depth + 1I) Stdlib.List.append acc (Stdlib.List.append [line] childLines)) let export (doc: Document) : String = let header = $"# {doc.title}" - let lines = exportHelper doc.outline doc.outline.rootChildren 0L + let lines = exportHelper doc.outline doc.outline.rootChildren 0I Stdlib.String.join (Stdlib.List.append [header; ""] lines) "\n" let import (markdown: String) : Document = @@ -40,7 +40,7 @@ let import (markdown: String) : Document = Stdlib.Bool.not (Stdlib.String.isEmpty (Stdlib.String.trim line))) let result = nonEmptyLines - |> Stdlib.List.fold (emptyOutline (), [], 0L) (fun acc line -> + |> Stdlib.List.fold (emptyOutline (), [], 0I) (fun acc line -> let (outline, stack, _count) = acc let trimmed = Stdlib.String.trim line let text = @@ -70,11 +70,11 @@ let import (markdown: String) : Document = | Some pid -> let children = getChildren o1 (Stdlib.Option.Option.Some pid) setChildren o1 (Stdlib.Option.Option.Some pid) (Stdlib.List.append children [id]) - let o3 = { o2 with nextId = id + 1L } + let o3 = { o2 with nextId = id + 1I } let updatedStack = Stdlib.List.append newStack [(depth, id)] - (o3, updatedStack, 0L)) + (o3, updatedStack, 0I)) let (finalOutline, _stack, _count) = result Document - { id = 0L + { id = 0I title = title outline = finalOutline } diff --git a/packages/darklang/cli/outliner/outline-editor.dark b/packages/darklang/cli/outliner/outline-editor.dark index 8b9f44cf8a..9aa5680759 100644 --- a/packages/darklang/cli/outliner/outline-editor.dark +++ b/packages/darklang/cli/outliner/outline-editor.dark @@ -20,7 +20,7 @@ let getVisibleNodeAtCursor (state: State) : Stdlib.Option.Option = let flat = flattenVisible state.outline Stdlib.List.getAt flat state.cursor -let findCursorIndex (outline: Outline) (nodeId: Int64) (fallback: Int) : Int = +let findCursorIndex (outline: Outline) (nodeId: Int) (fallback: Int) : Int = let flat = flattenVisible outline flat |> Stdlib.List.findFirstIndex (fun vn -> vn.id == nodeId) @@ -45,7 +45,7 @@ let insertAfter (state: State) : State = match getVisibleNodeAtCursor state with | None -> let o1 = addNode outline id "" - let o2 = { o1 with rootChildren = [id]; nextId = id + 1L } + let o2 = { o1 with rootChildren = [id]; nextId = id + 1I } { state with outline = o2 cursor = 0I @@ -56,7 +56,7 @@ let insertAfter (state: State) : State = let siblings = getChildren o1 parentId let newSiblings = insertIdAfter siblings vn.id id let o2 = setChildren o1 parentId newSiblings - let o3 = { o2 with nextId = id + 1L } + let o3 = { o2 with nextId = id + 1I } let newCursor = findCursorIndex o3 id state.cursor { state with outline = o3 @@ -112,7 +112,7 @@ let outdentNode (state: State) : State = match getVisibleNodeAtCursor state with | None -> state | Some vn -> - if vn.depth == 0L then + if vn.depth == 0I then state else let outline = state.outline @@ -143,8 +143,7 @@ let moveNodeUp (state: State) : State = if i == 0I then state else - let i64 = Builtin.unwrap (Stdlib.Int.toInt64 i) - let swapped = swapAt siblings (i64 - 1L) i64 + let swapped = swapAt siblings (i - 1I) i let o1 = setChildren outline parentId swapped { state with outline = o1; cursor = findCursorIndex o1 vn.id state.cursor } @@ -162,8 +161,7 @@ let moveNodeDown (state: State) : State = if i >= ((Stdlib.List.length siblings) - 1I) then state else - let i64 = Builtin.unwrap (Stdlib.Int.toInt64 i) - let swapped = swapAt siblings i64 (i64 + 1L) + let swapped = swapAt siblings i (i + 1I) let o1 = setChildren outline parentId swapped { state with outline = o1; cursor = findCursorIndex o1 vn.id state.cursor } @@ -282,7 +280,7 @@ let renderBody (state: State) (region: Darklang.Cli.UI.Layout.Region) : Unit = let (relIdx, vn) = pair let absoluteIdx = scrollOffset + relIdx let isSelected = absoluteIdx == state.cursor - let indent = Stdlib.String.repeat " " (Stdlib.Int.fromInt64 vn.depth) + let indent = Stdlib.String.repeat " " vn.depth let bullet = if vn.isCollapsed && vn.hasChildren then Darklang.Cli.Colors.colorize Darklang.Cli.Colors.yellow ">" @@ -297,8 +295,8 @@ let renderBody (state: State) (region: Darklang.Cli.UI.Layout.Region) : Unit = else vn.text | None -> vn.text let collapseHint = - if vn.isCollapsed && vn.childCount > 0L then - let countStr = Stdlib.Int64.toString vn.childCount + if vn.isCollapsed && vn.childCount > 0I then + let countStr = Stdlib.Int.toString vn.childCount Darklang.Cli.Colors.colorize Darklang.Cli.Colors.dim $" ({countStr} hidden)" else "" diff --git a/packages/darklang/cli/outliner/tests.dark b/packages/darklang/cli/outliner/tests.dark index 5d5acf1055..c5da26464b 100644 --- a/packages/darklang/cli/outliner/tests.dark +++ b/packages/darklang/cli/outliner/tests.dark @@ -7,9 +7,9 @@ type TestResult = type TestFunction = Unit -> TestResult type TestSummary = - { totalTests: Int64 - passedTests: Int64 - failedTests: Int64 + { totalTests: Int + passedTests: Int + failedTests: Int failedTestNames: List } @@ -21,15 +21,15 @@ let makeEditor (outline: Outline) : OutlineEditor.State = let makeMainState (outline: Outline) : Main.State = let doc = Document - { id = 1L + { id = 1I title = "Test Doc" outline = outline } let docs = [doc] let picker = ListPicker.make docs (fun d -> d.title) Main.State { documents = docs - activeDocId = 1L - nextDocId = 2L + activeDocId = 1I + nextDocId = 2I screen = Main.Screen.Editor (makeEditor outline) } let assertEq (label: String) (actual: String) (expected: String) : TestResult = @@ -38,11 +38,11 @@ let assertEq (label: String) (actual: String) (expected: String) : TestResult = else TestResult.Fail $"{label}: expected '{expected}', got '{actual}'" -let assertInt (label: String) (actual: Int64) (expected: Int64) : TestResult = +let assertInt (label: String) (actual: Int) (expected: Int) : TestResult = if actual == expected then TestResult.Pass else - TestResult.Fail $"{label}: expected {Stdlib.Int64.toString expected}, got {Stdlib.Int64.toString actual}" + TestResult.Fail $"{label}: expected {Stdlib.Int.toString expected}, got {Stdlib.Int.toString actual}" // --- Outline tests --- @@ -50,36 +50,36 @@ let assertInt (label: String) (actual: Int64) (expected: Int64) : TestResult = let testFlattenVisibleCountsAllNodes () : TestResult = let outline = buildOutline - [(1L, "A"); (2L, "B"); (3L, "C"); (4L, "D")] - [(1L, [2L; 3L])] - [1L; 4L] - 5L + [(1I, "A"); (2I, "B"); (3I, "C"); (4I, "D")] + [(1I, [2I; 3I])] + [1I; 4I] + 5I let flat = flattenVisible outline - assertInt "visible count" (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length flat))) 4L + assertInt "visible count" (Stdlib.List.length flat) 4I let testFlattenVisibleRespectsCollapse () : TestResult = let outline = buildOutline - [(1L, "A"); (2L, "B"); (3L, "C"); (4L, "D")] - [(1L, [2L; 3L])] - [1L; 4L] - 5L - let collapsed = setCollapsed outline 1L true + [(1I, "A"); (2I, "B"); (3I, "C"); (4I, "D")] + [(1I, [2I; 3I])] + [1I; 4I] + 5I + let collapsed = setCollapsed outline 1I true let flat = flattenVisible collapsed - assertInt "visible count" (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length flat))) 2L + assertInt "visible count" (Stdlib.List.length flat) 2I let testBuildOutline () : TestResult = let outline = buildOutline - [(1L, "A"); (2L, "B"); (3L, "C")] - [(1L, [2L; 3L])] - [1L] - 4L + [(1I, "A"); (2I, "B"); (3I, "C")] + [(1I, [2I; 3I])] + [1I] + 4I let flat = flattenVisible outline if Stdlib.List.length flat == 3I then match Stdlib.List.head flat with | Some vn -> - if vn.text == "A" && vn.hasChildren && vn.depth == 0L then + if vn.text == "A" && vn.hasChildren && vn.depth == 0I then TestResult.Pass else TestResult.Fail "First node should be A with children at depth 0" @@ -90,20 +90,20 @@ let testBuildOutline () : TestResult = let testFindParentId () : TestResult = let outline = buildOutline - [(1L, "Parent"); (2L, "Child"); (3L, "Root2")] - [(1L, [2L])] - [1L; 3L] - 4L - let childParent = findParentId outline 2L - let rootParent = findParentId outline 1L + [(1I, "Parent"); (2I, "Child"); (3I, "Root2")] + [(1I, [2I])] + [1I; 3I] + 4I + let childParent = findParentId outline 2I + let rootParent = findParentId outline 1I match childParent with | Some pid -> - if pid == 1L then + if pid == 1I then match rootParent with | None -> TestResult.Pass | Some _ -> TestResult.Fail "Root node should have no parent" else - TestResult.Fail $"Expected parent 1, got {Stdlib.Int64.toString pid}" + TestResult.Fail $"Expected parent 1, got {Stdlib.Int.toString pid}" | None -> TestResult.Fail "Child should have a parent" @@ -112,103 +112,103 @@ let testFindParentId () : TestResult = let testInsertAfterAddsNode () : TestResult = let outline = buildOutline - [(1L, "First")] + [(1I, "First")] [] - [1L] - 2L + [1I] + 2I let editor = makeEditor outline let newEditor = OutlineEditor.insertAfter editor let flat = flattenVisible newEditor.outline - assertInt "visible count" (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length flat))) 2L + assertInt "visible count" (Stdlib.List.length flat) 2I let testInsertAfterEmptyTree () : TestResult = let outline = emptyOutline () let editor = makeEditor outline let newEditor = OutlineEditor.insertAfter editor - assertInt "root count" (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length newEditor.outline.rootChildren))) 1L + assertInt "root count" (Stdlib.List.length newEditor.outline.rootChildren) 1I let testDeleteEmptyNode () : TestResult = let outline = buildOutline - [(1L, ""); (2L, "Keep")] + [(1I, ""); (2I, "Keep")] [] - [1L; 2L] - 3L + [1I; 2I] + 3I let editor = makeEditor outline let newEditor = OutlineEditor.deleteNode editor - assertInt "root count" (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length newEditor.outline.rootChildren))) 1L + assertInt "root count" (Stdlib.List.length newEditor.outline.rootChildren) 1I let testDeleteNonEmptyNodeDoesNothing () : TestResult = let outline = buildOutline - [(1L, "Has text")] + [(1I, "Has text")] [] - [1L] - 2L + [1I] + 2I let editor = makeEditor outline let newEditor = OutlineEditor.deleteNode editor - assertInt "root count" (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length newEditor.outline.rootChildren))) 1L + assertInt "root count" (Stdlib.List.length newEditor.outline.rootChildren) 1I let testToggleCollapse () : TestResult = let outline = buildOutline - [(1L, "Parent"); (2L, "Child")] - [(1L, [2L])] - [1L] - 3L + [(1I, "Parent"); (2I, "Child")] + [(1I, [2I])] + [1I] + 3I let editor = makeEditor outline let newEditor = OutlineEditor.toggleCollapse editor - let s = getStructure newEditor.outline 1L + let s = getStructure newEditor.outline 1I if s.collapsed then TestResult.Pass else TestResult.Fail "Expected node to be collapsed" let testToggleCollapseLeafDoesNothing () : TestResult = let outline = buildOutline - [(1L, "Leaf")] + [(1I, "Leaf")] [] - [1L] - 2L + [1I] + 2I let editor = makeEditor outline let newEditor = OutlineEditor.toggleCollapse editor - let s = getStructure newEditor.outline 1L + let s = getStructure newEditor.outline 1I if s.collapsed then TestResult.Fail "Leaf should not be collapsible" else TestResult.Pass let testIndentNode () : TestResult = let outline = buildOutline - [(1L, "First"); (2L, "Second")] + [(1I, "First"); (2I, "Second")] [] - [1L; 2L] - 3L + [1I; 2I] + 3I let editor = { (makeEditor outline) with cursor = 1I } let newEditor = OutlineEditor.indentNode editor let rootCount = Stdlib.List.length newEditor.outline.rootChildren if rootCount == 1I then - let s = getStructure newEditor.outline 1L - assertInt "child count" (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length s.children))) 1L + let s = getStructure newEditor.outline 1I + assertInt "child count" (Stdlib.List.length s.children) 1I else TestResult.Fail $"Expected 1 root after indent, got {Stdlib.Int.toString rootCount}" let testOutdentNode () : TestResult = let outline = buildOutline - [(1L, "Parent"); (2L, "Child")] - [(1L, [2L])] - [1L] - 3L + [(1I, "Parent"); (2I, "Child")] + [(1I, [2I])] + [1I] + 3I let editor = { (makeEditor outline) with cursor = 1I } let newEditor = OutlineEditor.outdentNode editor - assertInt "root count" (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length newEditor.outline.rootChildren))) 2L + assertInt "root count" (Stdlib.List.length newEditor.outline.rootChildren) 2I let testMoveNodeUp () : TestResult = let outline = buildOutline - [(1L, "First"); (2L, "Second")] + [(1I, "First"); (2I, "Second")] [] - [1L; 2L] - 3L + [1I; 2I] + 3I let editor = { (makeEditor outline) with cursor = 1I } let newEditor = OutlineEditor.moveNodeUp editor match Stdlib.List.head newEditor.outline.rootChildren with @@ -220,10 +220,10 @@ let testMoveNodeUp () : TestResult = let testMoveNodeDown () : TestResult = let outline = buildOutline - [(1L, "First"); (2L, "Second")] + [(1I, "First"); (2I, "Second")] [] - [1L; 2L] - 3L + [1I; 2I] + 3I let editor = makeEditor outline let newEditor = OutlineEditor.moveNodeDown editor match Stdlib.List.head newEditor.outline.rootChildren with @@ -235,10 +235,10 @@ let testMoveNodeDown () : TestResult = let testMoveCursorUpDown () : TestResult = let outline = buildOutline - [(1L, "A"); (2L, "B"); (3L, "C")] + [(1I, "A"); (2I, "B"); (3I, "C")] [] - [1L; 2L; 3L] - 4L + [1I; 2I; 3I] + 4I let editor = makeEditor outline let down1 = OutlineEditor.moveCursorDown editor let down2 = OutlineEditor.moveCursorDown down1 @@ -251,10 +251,10 @@ let testMoveCursorUpDown () : TestResult = let testMoveCursorBounds () : TestResult = let outline = buildOutline - [(1L, "Only")] + [(1I, "Only")] [] - [1L] - 2L + [1I] + 2I let editor = makeEditor outline let upFromZero = OutlineEditor.moveCursorUp editor let downFromMax = OutlineEditor.moveCursorDown editor @@ -268,25 +268,25 @@ let testMoveCursorBounds () : TestResult = let testTextEditorInsert () : TestResult = let te = TextEditor.fromText "Hello" - match TextEditor.handleKey te (Stdlib.Cli.Stdin.Key.Key.Other) (Stdlib.Cli.Stdin.Modifiers.Modifiers { shift = false; ctrl = false; alt = false; meta = false }) (Stdlib.Option.Option.Some "!") with + match TextEditor.handleKey te (Stdlib.Cli.Stdin.Key.Key.None) (Stdlib.Cli.Stdin.Modifiers.Modifiers { shift = false; ctrl = false; alt = false }) (Stdlib.Option.Option.Some "!") with | Editing newTe -> assertEq "after insert" newTe.text "Hello!" | _ -> TestResult.Fail "Expected Editing result" let testTextEditorBackspace () : TestResult = let te = TextEditor.fromText "AB" - match TextEditor.handleKey te (Stdlib.Cli.Stdin.Key.Key.Backspace) (Stdlib.Cli.Stdin.Modifiers.Modifiers { shift = false; ctrl = false; alt = false; meta = false }) (Stdlib.Option.Option.None) with + match TextEditor.handleKey te (Stdlib.Cli.Stdin.Key.Key.Backspace) (Stdlib.Cli.Stdin.Modifiers.Modifiers { shift = false; ctrl = false; alt = false }) (Stdlib.Option.Option.None) with | Editing newTe -> assertEq "after backspace" newTe.text "A" | _ -> TestResult.Fail "Expected Editing result" let testTextEditorFinish () : TestResult = let te = TextEditor.fromText "Done" - match TextEditor.handleKey te (Stdlib.Cli.Stdin.Key.Key.Enter) (Stdlib.Cli.Stdin.Modifiers.Modifiers { shift = false; ctrl = false; alt = false; meta = false }) (Stdlib.Option.Option.None) with + match TextEditor.handleKey te (Stdlib.Cli.Stdin.Key.Key.Enter) (Stdlib.Cli.Stdin.Modifiers.Modifiers { shift = false; ctrl = false; alt = false }) (Stdlib.Option.Option.None) with | Finished text -> assertEq "finished text" text "Done" | _ -> TestResult.Fail "Expected Finished result" let testTextEditorCancel () : TestResult = let te = TextEditor.fromText "Nope" - match TextEditor.handleKey te (Stdlib.Cli.Stdin.Key.Key.Escape) (Stdlib.Cli.Stdin.Modifiers.Modifiers { shift = false; ctrl = false; alt = false; meta = false }) (Stdlib.Option.Option.None) with + match TextEditor.handleKey te (Stdlib.Cli.Stdin.Key.Key.Escape) (Stdlib.Cli.Stdin.Modifiers.Modifiers { shift = false; ctrl = false; alt = false }) (Stdlib.Option.Option.None) with | Cancelled -> TestResult.Pass | _ -> TestResult.Fail "Expected Cancelled result" @@ -296,29 +296,29 @@ let testTextEditorCancel () : TestResult = let testEditMode () : TestResult = let outline = buildOutline - [(1L, "Hello")] + [(1I, "Hello")] [] - [1L] - 2L + [1I] + 2I let editor = makeEditor outline let editing = OutlineEditor.enterEditMode editor match editing.editing with | Some te -> - if te.text == "Hello" && te.cursor == 5L then TestResult.Pass + if te.text == "Hello" && te.cursor == 5I then TestResult.Pass else TestResult.Fail $"Expected 'Hello' at cursor 5" | None -> TestResult.Fail "Expected editing state" let testFinishEditing () : TestResult = let outline = buildOutline - [(1L, "Old")] + [(1I, "Old")] [] - [1L] - 2L + [1I] + 2I let editor = makeEditor outline let editing = OutlineEditor.enterEditMode editor let committed = OutlineEditor.commitEdit editing "New" - let text = getNodeText committed.outline 1L + let text = getNodeText committed.outline 1I assertEq "node text" text "New" @@ -326,7 +326,7 @@ let testFinishEditing () : TestResult = let testDefaultStateHasTwoDocs () : TestResult = let state = Main.defaultState () - assertInt "doc count" (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length state.documents))) 2L + assertInt "doc count" (Stdlib.List.length state.documents) 2I let testActiveDocReturnsCorrectDoc () : TestResult = let state = Main.defaultState () @@ -348,12 +348,12 @@ let testDeleteDocument () : TestResult = let newState = Main.createDocument state "Third" let thirdDocId = newState.activeDocId let afterDelete = Main.deleteDocument newState thirdDocId - assertInt "doc count" (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length afterDelete.documents))) 2L + assertInt "doc count" (Stdlib.List.length afterDelete.documents) 2I let testDeleteOnlyDocDoesNothing () : TestResult = - let state = makeMainState (buildOutline [(1L, "X")] [] [1L] 2L) - let afterDelete = Main.deleteDocument state 1L - assertInt "doc count" (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length afterDelete.documents))) 1L + let state = makeMainState (buildOutline [(1I, "X")] [] [1I] 2I) + let afterDelete = Main.deleteDocument state 1I + assertInt "doc count" (Stdlib.List.length afterDelete.documents) 1I let testRenameDocument () : TestResult = let state = Main.defaultState () @@ -365,12 +365,12 @@ let testRenameDocument () : TestResult = let testExportMarkdown () : TestResult = let outline = buildOutline - [(1L, "Root"); (2L, "Child")] - [(1L, [2L])] - [1L] - 3L + [(1I, "Root"); (2I, "Child")] + [(1I, [2I])] + [1I] + 3I let doc = - Document { id = 1L; title = "Test"; outline = outline } + Document { id = 1I; title = "Test"; outline = outline } let md = Export.toMarkdown doc if Stdlib.String.contains md "# Test" && Stdlib.String.contains md "- Root" && Stdlib.String.contains md " - Child" then TestResult.Pass @@ -380,12 +380,12 @@ let testExportMarkdown () : TestResult = let testExportOpml () : TestResult = let outline = buildOutline - [(1L, "Root"); (2L, "Child")] - [(1L, [2L])] - [1L] - 3L + [(1I, "Root"); (2I, "Child")] + [(1I, [2I])] + [1I] + 3I let doc = - Document { id = 1L; title = "Test"; outline = outline } + Document { id = 1I; title = "Test"; outline = outline } let opml = Export.toOpml doc if Stdlib.String.contains opml "Test" && Stdlib.String.contains opml "text=\"Root\"" && Stdlib.String.contains opml "text=\"Child\"" then TestResult.Pass @@ -397,7 +397,7 @@ let testImportMarkdown () : TestResult = let doc = Markdown.import md if doc.title == "My Doc" then let flat = flattenVisible doc.outline - assertInt "visible count" (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length flat))) 3L + assertInt "visible count" (Stdlib.List.length flat) 3I else TestResult.Fail $"Expected title 'My Doc', got '{doc.title}'" @@ -438,7 +438,7 @@ let allTests () : List<(String * TestFunction)> = ("Import markdown", fun () -> testImportMarkdown ()) ] -let runAllTests () : Int64 = +let runAllTests () : Int = let tests = allTests () Stdlib.printLine "" @@ -447,9 +447,9 @@ let runAllTests () : Int64 = let initialSummary = TestSummary - { totalTests = 0L - passedTests = 0L - failedTests = 0L + { totalTests = 0I + passedTests = 0I + failedTests = 0I failedTestNames = [] } let finalSummary = @@ -457,26 +457,26 @@ let runAllTests () : Int64 = |> Stdlib.List.fold initialSummary (fun summary pair -> let (name, testFn) = pair let newSummary = - { summary with totalTests = summary.totalTests + 1L } + { summary with totalTests = summary.totalTests + 1I } match testFn () with | Pass -> Stdlib.printLine $" PASS {name}" - { newSummary with passedTests = newSummary.passedTests + 1L } + { newSummary with passedTests = newSummary.passedTests + 1I } | Fail message -> Stdlib.printLine $" FAIL {name}: {message}" { newSummary with - failedTests = newSummary.failedTests + 1L + failedTests = newSummary.failedTests + 1I failedTestNames = Stdlib.List.append newSummary.failedTestNames [name] }) Stdlib.printLine "" - Stdlib.printLine $"Results: {Stdlib.Int64.toString finalSummary.passedTests}/{Stdlib.Int64.toString finalSummary.totalTests} passed" + Stdlib.printLine $"Results: {Stdlib.Int.toString finalSummary.passedTests}/{Stdlib.Int.toString finalSummary.totalTests} passed" - if finalSummary.failedTests == 0L then + if finalSummary.failedTests == 0I then Stdlib.printLine "All tests passed!" - 0L + 0I else Stdlib.printLine "Failed:" finalSummary.failedTestNames |> Stdlib.List.iter (fun name -> Stdlib.printLine $" - {name}") - 1L + 1I From 42b2f3530ec405c1b5da3742afae23b94e94d04b Mon Sep 17 00:00:00 2001 From: OceanOak Date: Wed, 17 Jun 2026 20:33:06 +0000 Subject: [PATCH 23/61] Fix LLM example maxTokens passing Int64 literals to migrated Int param --- packages/darklang/llm/examples/basics.dark | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/darklang/llm/examples/basics.dark b/packages/darklang/llm/examples/basics.dark index 6b159fb509..8bd2e141a5 100644 --- a/packages/darklang/llm/examples/basics.dark +++ b/packages/darklang/llm/examples/basics.dark @@ -52,30 +52,30 @@ let chatWithModel /// Use Anthropic Claude let withAnthropic (question: String) : String = - chatWithModel Models.Anthropic.sonnet45 4096L question + chatWithModel Models.Anthropic.sonnet45 4096I question /// Use OpenAI GPT let withOpenAI (question: String) : String = - chatWithModel Models.OpenAI.gpt4o 4096L question + chatWithModel Models.OpenAI.gpt4o 4096I question /// Use local Ollama let withOllama (question: String) : String = - chatWithModel Models.Local.llama3 4096L question + chatWithModel Models.Local.llama3 4096I question // MODEL TIERS (Fast vs Balanced vs Smart) /// Use fast model (Haiku) - good for simple tasks let fast (question: String) : String = - chatWithModel Models.Anthropic.haiku45 500L question + chatWithModel Models.Anthropic.haiku45 500I question /// Use balanced model (Sonnet) - good for most tasks let balanced (question: String) : String = - chatWithModel Models.Anthropic.sonnet45 2000L question + chatWithModel Models.Anthropic.sonnet45 2000I question /// Use smart model (Opus) - good for complex reasoning let smart (question: String) : String = - chatWithModel Models.Anthropic.opus46 4000L question + chatWithModel Models.Anthropic.opus46 4000I question From e9ae787606657de053b826d8b4d75cd4f8f089c0 Mon Sep 17 00:00:00 2001 From: OceanOak Date: Wed, 17 Jun 2026 20:39:37 +0000 Subject: [PATCH 24/61] Migrate caps editors from Int64 to Int --- packages/darklang/cli/caps/accessEditor.dark | 26 ++++---- .../darklang/cli/caps/httpRuleEditor.dark | 26 ++++---- packages/darklang/cli/caps/lineInput.dark | 36 +++++------ packages/darklang/cli/caps/main.dark | 62 +++++++++---------- 4 files changed, 75 insertions(+), 75 deletions(-) diff --git a/packages/darklang/cli/caps/accessEditor.dark b/packages/darklang/cli/caps/accessEditor.dark index b4d3d9ad10..aab7feba26 100644 --- a/packages/darklang/cli/caps/accessEditor.dark +++ b/packages/darklang/cli/caps/accessEditor.dark @@ -10,7 +10,7 @@ type Field = type State = { domain: String - accessIdx: Int64 + accessIdx: Int scope: LineInput.State field: Field } @@ -24,13 +24,13 @@ let accesses : List = [ "read"; "write"; "read+write" ] let forDomain (domain: String) : State = State { domain = domain - accessIdx = 0L + accessIdx = 0I scope = LineInput.empty field = Field.AccessField } -let indexOfAccess (a: String) : Int64 = - let indexed = Stdlib.List.indexedMap accesses (fun i x -> (Builtin.unwrap (Stdlib.Int.toInt64 i), x)) - Stdlib.List.fold indexed 0L (fun acc pair -> +let indexOfAccess (a: String) : Int = + let indexed = Stdlib.List.indexedMap accesses (fun i x -> (i, x)) + Stdlib.List.fold indexed 0I (fun acc pair -> let (i, x) = pair if x == a then i else acc) @@ -51,7 +51,7 @@ let fromSpec (spec: String) : State = | _ -> forDomain "file" let currentAccess (state: State) : String = - accesses |> Stdlib.List.getAt (Stdlib.Int.fromInt64 state.accessIdx) |> Stdlib.Option.withDefault "read" + accesses |> Stdlib.List.getAt state.accessIdx |> Stdlib.Option.withDefault "read" let toSpec (state: State) : String = let access = currentAccess state @@ -60,12 +60,12 @@ let toSpec (state: State) : String = if scope == "" then $"{state.domain} {access}" else $"{state.domain} {access} {scope}" -let cycleAccess (state: State) (delta: Int64) : State = - let count = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length accesses))) +let cycleAccess (state: State) (delta: Int) : State = + let count = (Stdlib.List.length accesses) let raw = state.accessIdx + delta let next = - if raw < 0L then count - 1L - else if raw >= count then 0L + if raw < 0I then count - 1I + else if raw >= count then 0I else raw { state with accessIdx = next } @@ -102,13 +102,13 @@ let handleKey | UpArrow -> EditResult.Editing ({ state with field = Field.AccessField }) | DownArrow -> EditResult.Editing ({ state with field = Field.ScopeField }) | LeftArrow -> - if onAccess then EditResult.Editing (cycleAccess state (0L - 1L)) + if onAccess then EditResult.Editing (cycleAccess state (0I - 1I)) else EditResult.Editing (applyScopeKey state key keyChar) | RightArrow -> - if onAccess then EditResult.Editing (cycleAccess state 1L) + if onAccess then EditResult.Editing (cycleAccess state 1I) else EditResult.Editing (applyScopeKey state key keyChar) | Spacebar -> - if onAccess then EditResult.Editing (cycleAccess state 1L) + if onAccess then EditResult.Editing (cycleAccess state 1I) else EditResult.Editing (applyScopeKey state key keyChar) | _ -> EditResult.Editing (applyScopeKey state key keyChar) diff --git a/packages/darklang/cli/caps/httpRuleEditor.dark b/packages/darklang/cli/caps/httpRuleEditor.dark index 2f7af3a25b..4d3b5c7ea3 100644 --- a/packages/darklang/cli/caps/httpRuleEditor.dark +++ b/packages/darklang/cli/caps/httpRuleEditor.dark @@ -9,7 +9,7 @@ type Field = | UrlField type State = - { methodIdx: Int64 + { methodIdx: Int url: LineInput.State field: Field } @@ -23,14 +23,14 @@ let methods : List = let empty : State = State - { methodIdx = 1L + { methodIdx = 1I url = LineInput.empty field = Field.MethodField } // find a method's index (default 0 = `*`) -let indexOfMethod (m: String) : Int64 = - let indexed = Stdlib.List.indexedMap methods (fun i x -> (Builtin.unwrap (Stdlib.Int.toInt64 i), x)) - Stdlib.List.fold indexed 0L (fun acc pair -> +let indexOfMethod (m: String) : Int = + let indexed = Stdlib.List.indexedMap methods (fun i x -> (i, x)) + Stdlib.List.fold indexed 0I (fun acc pair -> let (i, x) = pair if x == m then i else acc) @@ -52,7 +52,7 @@ let fromSpec (spec: String) : State = | _ -> empty let currentMethod (state: State) : String = - methods |> Stdlib.List.getAt (Stdlib.Int.fromInt64 state.methodIdx) |> Stdlib.Option.withDefault "*" + methods |> Stdlib.List.getAt state.methodIdx |> Stdlib.Option.withDefault "*" let toSpec (state: State) : String = let m = currentMethod state @@ -60,12 +60,12 @@ let toSpec (state: State) : String = let u = Stdlib.String.trim urlState.text if u == "" then $"http-client {m}" else $"http-client {m} {u}" -let cycleMethod (state: State) (delta: Int64) : State = - let count = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length methods))) +let cycleMethod (state: State) (delta: Int) : State = + let count = (Stdlib.List.length methods) let raw = state.methodIdx + delta let next = - if raw < 0L then count - 1L - else if raw >= count then 0L + if raw < 0I then count - 1I + else if raw >= count then 0I else raw { state with methodIdx = next } @@ -103,13 +103,13 @@ let handleKey | UpArrow -> EditResult.Editing ({ state with field = Field.MethodField }) | DownArrow -> EditResult.Editing ({ state with field = Field.UrlField }) | LeftArrow -> - if onMethod then EditResult.Editing (cycleMethod state (0L - 1L)) + if onMethod then EditResult.Editing (cycleMethod state (0I - 1I)) else EditResult.Editing (applyUrlKey state key keyChar) | RightArrow -> - if onMethod then EditResult.Editing (cycleMethod state 1L) + if onMethod then EditResult.Editing (cycleMethod state 1I) else EditResult.Editing (applyUrlKey state key keyChar) | Spacebar -> - if onMethod then EditResult.Editing (cycleMethod state 1L) + if onMethod then EditResult.Editing (cycleMethod state 1I) else EditResult.Editing (applyUrlKey state key keyChar) | _ -> EditResult.Editing (applyUrlKey state key keyChar) diff --git a/packages/darklang/cli/caps/lineInput.dark b/packages/darklang/cli/caps/lineInput.dark index b44c938f74..d93f240347 100644 --- a/packages/darklang/cli/caps/lineInput.dark +++ b/packages/darklang/cli/caps/lineInput.dark @@ -3,32 +3,32 @@ module Darklang.Cli.Caps.LineInput // A tiny composable single-line text field. Standalone (no app state) so any caps editor — or any other // app — can embed it: hold a `State`, feed it keys via `handleKey`, and `render` it focused or not. -type State = { text: String; cursor: Int64 } +type State = { text: String; cursor: Int } let make (text: String) : State = - State { text = text; cursor = Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length text)) } + State { text = text; cursor = Stdlib.String.length text } -let empty : State = State { text = ""; cursor = 0L } +let empty : State = State { text = ""; cursor = 0I } let insert (state: State) (ch: String) : State = - let before = Stdlib.String.slice state.text 0I (Stdlib.Int.fromInt64 state.cursor) - let after = Stdlib.String.dropFirst state.text (Stdlib.Int.fromInt64 state.cursor) - State { text = before ++ ch ++ after; cursor = state.cursor + (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length ch))) } + let before = Stdlib.String.slice state.text 0I state.cursor + let after = Stdlib.String.dropFirst state.text state.cursor + State { text = before ++ ch ++ after; cursor = state.cursor + (Stdlib.String.length ch) } let backspace (state: State) : State = - if state.cursor == 0L then + if state.cursor == 0I then state else - let before = Stdlib.String.slice state.text 0I (Stdlib.Int.fromInt64 (state.cursor - 1L)) - let after = Stdlib.String.dropFirst state.text (Stdlib.Int.fromInt64 state.cursor) - State { text = before ++ after; cursor = state.cursor - 1L } + let before = Stdlib.String.slice state.text 0I ((state.cursor - 1I)) + let after = Stdlib.String.dropFirst state.text state.cursor + State { text = before ++ after; cursor = state.cursor - 1I } let left (state: State) : State = - if state.cursor > 0L then { state with cursor = state.cursor - 1L } else state + if state.cursor > 0I then { state with cursor = state.cursor - 1I } else state let right (state: State) : State = - if state.cursor < (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length state.text))) then - { state with cursor = state.cursor + 1L } + if state.cursor < (Stdlib.String.length state.text) then + { state with cursor = state.cursor + 1I } else state @@ -51,16 +51,16 @@ let handleKey /// Render the field. When focused, shows a reverse-video cursor; unfocused + empty shows `placeholder`. let render (state: State) (focused: Bool) (placeholder: String) : String = if focused then - let before = Stdlib.String.slice state.text 0I (Stdlib.Int.fromInt64 state.cursor) + let before = Stdlib.String.slice state.text 0I state.cursor let cursorChar = - if state.cursor < (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length state.text))) then - Stdlib.String.slice state.text (Stdlib.Int.fromInt64 state.cursor) (Stdlib.Int.fromInt64 (state.cursor + 1L)) + if state.cursor < (Stdlib.String.length state.text) then + Stdlib.String.slice state.text state.cursor (state.cursor + 1I) else " " let cursorDisplay = Darklang.Cli.Colors.colorize Darklang.Cli.Colors.reverse cursorChar let after = - if state.cursor < (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.String.length state.text))) then - Stdlib.String.dropFirst state.text (Stdlib.Int.fromInt64 (state.cursor + 1L)) + if state.cursor < (Stdlib.String.length state.text) then + Stdlib.String.dropFirst state.text (state.cursor + 1I) else "" before ++ cursorDisplay ++ after diff --git a/packages/darklang/cli/caps/main.dark b/packages/darklang/cli/caps/main.dark index 56d3e6fe9f..2887a0eaef 100644 --- a/packages/darklang/cli/caps/main.dark +++ b/packages/darklang/cli/caps/main.dark @@ -23,16 +23,16 @@ type Row = // removes the original before adding the new one (otherwise editing a rule would duplicate it). type Screen = | Browsing - | AddPickDomain of Int64 + | AddPickDomain of Int | EditHttp of String * HttpRuleEditor.State | EditExec of String * ExecRuleEditor.State | EditAccess of String * AccessEditor.State - | PickProfile of Int64 + | PickProfile of Int type State = { specs: List saved: List - cursor: Int64 + cursor: Int dirty: Bool screen: Screen } @@ -46,7 +46,7 @@ let load () : State = State { specs = specs saved = specs - cursor = 0L + cursor = 0I dirty = false screen = Screen.Browsing } @@ -66,7 +66,7 @@ let rows (state: State) : List = |> Stdlib.List.map (fun s -> Row.RuleRow s) Stdlib.List.append flagRows (Stdlib.List.append ruleRows [ Row.AddRuleRow ]) -let rowCount (state: State) : Int64 = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length (rows state)))) +let rowCount (state: State) : Int = (Stdlib.List.length (rows state)) let toggleFlag (state: State) (domain: String) : State = if Stdlib.List.member_v0 state.specs domain then @@ -121,9 +121,9 @@ let editNew (state: State) (domain: String) : State = let private clampCursor (state: State) : State = let count = rowCount state let c = - if count == 0L then 0L - else if state.cursor >= count then count - 1L - else if state.cursor < 0L then 0L + if count == 0I then 0I + else if state.cursor >= count then count - 1I + else if state.cursor < 0I then 0I else state.cursor { state with cursor = c } @@ -137,29 +137,29 @@ let handleBrowsing // discard unsaved edits: restore the last-saved set so onSave writes it unchanged KeyResult.Exit ({ state with specs = state.saved }) | UpArrow -> - let c = if state.cursor > 0L then state.cursor - 1L else 0L + let c = if state.cursor > 0I then state.cursor - 1I else 0I KeyResult.Continue ({ state with cursor = c }) | DownArrow -> - let maxIdx = rowCount state - 1L - let c = if state.cursor < maxIdx then state.cursor + 1L else maxIdx + let maxIdx = rowCount state - 1I + let c = if state.cursor < maxIdx then state.cursor + 1I else maxIdx KeyResult.Continue ({ state with cursor = c }) | Spacebar -> - match Stdlib.List.getAt (rows state) (Stdlib.Int.fromInt64 state.cursor) with + match Stdlib.List.getAt (rows state) state.cursor with | Some(FlagRow(d, _)) -> KeyResult.Continue (toggleFlag state d) | _ -> KeyResult.Continue state | Enter -> - match Stdlib.List.getAt (rows state) (Stdlib.Int.fromInt64 state.cursor) with + match Stdlib.List.getAt (rows state) state.cursor with | Some(FlagRow(d, _)) -> KeyResult.Continue (toggleFlag state d) | Some(RuleRow spec) -> KeyResult.Continue (editSpec state spec) | Some AddRuleRow -> - KeyResult.Continue ({ state with screen = Screen.AddPickDomain 0L }) + KeyResult.Continue ({ state with screen = Screen.AddPickDomain 0I }) | None -> KeyResult.Continue state | _ -> match keyChar with - | Some "a" -> KeyResult.Continue ({ state with screen = Screen.AddPickDomain 0L }) - | Some "p" -> KeyResult.Continue ({ state with screen = Screen.PickProfile 0L }) + | Some "a" -> KeyResult.Continue ({ state with screen = Screen.AddPickDomain 0I }) + | Some "p" -> KeyResult.Continue ({ state with screen = Screen.PickProfile 0I }) | Some "d" -> - match Stdlib.List.getAt (rows state) (Stdlib.Int.fromInt64 state.cursor) with + match Stdlib.List.getAt (rows state) state.cursor with | Some(RuleRow spec) -> KeyResult.Continue (clampCursor (removeSpec state spec)) | _ -> KeyResult.Continue state | Some "w" -> @@ -168,17 +168,17 @@ let handleBrowsing | _ -> KeyResult.Continue state let handleMenu - (cursor: Int64) - (count: Int64) + (cursor: Int) + (count: Int) (key: Stdlib.Cli.Stdin.Key.Key) - : Stdlib.Option.Option = + : Stdlib.Option.Option = // returns Some newCursor while browsing; None signals Enter/Escape handled by caller via key match match key with | UpArrow -> - let c = if cursor > 0L then cursor - 1L else 0L + let c = if cursor > 0I then cursor - 1I else 0I Stdlib.Option.Option.Some c | DownArrow -> - let c = if cursor < count - 1L then cursor + 1L else count - 1L + let c = if cursor < count - 1I then cursor + 1I else count - 1I Stdlib.Option.Option.Some c | _ -> Stdlib.Option.Option.None @@ -194,18 +194,18 @@ let handleKey match key with | Escape -> KeyResult.Continue ({ state with screen = Screen.Browsing }) | Enter -> - match Stdlib.List.getAt ruleDomains (Stdlib.Int.fromInt64 cursor) with + match Stdlib.List.getAt ruleDomains cursor with | Some d -> KeyResult.Continue (editNew state d) | None -> KeyResult.Continue ({ state with screen = Screen.Browsing }) | _ -> - match handleMenu cursor (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length ruleDomains))) key with + match handleMenu cursor (Stdlib.List.length ruleDomains) key with | Some c -> KeyResult.Continue ({ state with screen = Screen.AddPickDomain c }) | None -> KeyResult.Continue state | PickProfile cursor -> match key with | Escape -> KeyResult.Continue ({ state with screen = Screen.Browsing }) | Enter -> - match Stdlib.List.getAt Command.profiles (Stdlib.Int.fromInt64 cursor) with + match Stdlib.List.getAt Command.profiles cursor with | Some((_, specs)) -> // a profile can have fewer rows than the current grant — clamp the cursor back in range KeyResult.Continue @@ -213,7 +213,7 @@ let handleKey ({ state with specs = specs; dirty = true; screen = Screen.Browsing })) | None -> KeyResult.Continue ({ state with screen = Screen.Browsing }) | _ -> - match handleMenu cursor (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length Command.profiles))) key with + match handleMenu cursor (Stdlib.List.length Command.profiles) key with | Some c -> KeyResult.Continue ({ state with screen = Screen.PickProfile c }) | None -> KeyResult.Continue state | EditHttp(orig, editor) -> @@ -245,7 +245,7 @@ let private rowText (row: Row) : String = | RuleRow spec -> Darklang.PrettyPrinter.Capabilities.line spec | AddRuleRow -> "+ Add rule…" -let private printOneRow (state: State) (pair: (Int64 * Row)) : Unit = +let private printOneRow (state: State) (pair: (Int * Row)) : Unit = let (i, r) = pair let selected = i == state.cursor let prefix = if selected then "›" else " " @@ -258,8 +258,8 @@ let private printOneRow (state: State) (pair: (Int64 * Row)) : Unit = // flag checklist on top, then a labelled "Scoped rules" section (existing rules + the "+ Add rule…" // affordance). The cursor index maps into `rows`; the section label is printed between, not selectable. let private printRows (state: State) : Unit = - let flagCount = (Builtin.unwrap (Stdlib.Int.toInt64 (Stdlib.List.length flagDomains))) - let indexed = Stdlib.List.indexedMap (rows state) (fun i r -> (Builtin.unwrap (Stdlib.Int.toInt64 i), r)) + let flagCount = (Stdlib.List.length flagDomains) + let indexed = Stdlib.List.indexedMap (rows state) (fun i r -> (i, r)) indexed |> Stdlib.List.filter (fun pair -> Stdlib.Tuple2.first pair < flagCount) |> Stdlib.List.iter (fun pair -> printOneRow state pair) @@ -269,10 +269,10 @@ let private printRows (state: State) : Unit = |> Stdlib.List.filter (fun pair -> Stdlib.Tuple2.first pair >= flagCount) |> Stdlib.List.iter (fun pair -> printOneRow state pair) -let private printMenu (title: String) (items: List) (cursor: Int64) : Unit = +let private printMenu (title: String) (items: List) (cursor: Int) : Unit = Stdlib.printLine title Stdlib.printLine "" - let indexed = Stdlib.List.indexedMap items (fun i x -> (Builtin.unwrap (Stdlib.Int.toInt64 i), x)) + let indexed = Stdlib.List.indexedMap items (fun i x -> (i, x)) Stdlib.List.iter indexed (fun pair -> let (i, x) = pair let selected = i == cursor From a522afdd550b1647bfe49c0a18fe839754711ebf Mon Sep 17 00:00:00 2001 From: OceanOak Date: Wed, 17 Jun 2026 21:34:52 +0000 Subject: [PATCH 25/61] Migrate search rank / countMatchingPrefix / Stream.take counts to Int --- .../src/Builtins/Builtins.Pure/Libs/Stream.fs | 6 ++-- .../stdlib/language-tools/pickLocation.dark | 20 ++++++------ .../testfiles/execution/stdlib/stream.dark | 16 +++++----- packages/darklang/cli/packages/search.dark | 32 +++++++++---------- .../languageTools/packageManager.dark | 8 ++--- packages/darklang/stdlib/stream.dark | 2 +- 6 files changed, 42 insertions(+), 42 deletions(-) diff --git a/backend/src/Builtins/Builtins.Pure/Libs/Stream.fs b/backend/src/Builtins/Builtins.Pure/Libs/Stream.fs index 6a4e2d1e99..62fb6b405d 100644 --- a/backend/src/Builtins/Builtins.Pure/Libs/Stream.fs +++ b/backend/src/Builtins/Builtins.Pure/Libs/Stream.fs @@ -348,7 +348,7 @@ let fns () : List = typeParams = [ "a" ] parameters = [ Param.make "stream" (TStream varA) "" - Param.make "n" TInt64 "Maximum number of elements to yield." ] + Param.make "n" TInt "Maximum number of elements to yield." ] returnType = TStream varA description = "Returns a new stream that yields at most the first elements @@ -356,10 +356,10 @@ let fns () : List = Terminates early without pulling the source past the limit." fn = (function - | _, _, _, [ DStream(src, _, _); DInt64 n ] -> + | _, _, _, [ DStream(src, _, _); DInt n ] -> // Clamp negative n to 0 — pullStreamImpl treats remaining<=0 // as done, so a negative here becomes an empty stream. - let clamped = max 0L n + let clamped = max 0L (int64 (DarkInt.toBigInt n)) Stream.wrapImpl (Take(src, clamped, ref clamped)) |> Ply | _ -> incorrectArgs ()) sqlSpec = NotYetImplemented diff --git a/backend/testfiles/execution/stdlib/language-tools/pickLocation.dark b/backend/testfiles/execution/stdlib/language-tools/pickLocation.dark index 98b35ae913..dcce7f64f9 100644 --- a/backend/testfiles/execution/stdlib/language-tools/pickLocation.dark +++ b/backend/testfiles/execution/stdlib/language-tools/pickLocation.dark @@ -29,16 +29,16 @@ let emptyCtx () : Darklang.LanguageTools.PackageManager.PickContext = // countMatchingPrefix // ======================================== -Darklang.LanguageTools.PackageManager.countMatchingPrefix [] [] = 0L -Darklang.LanguageTools.PackageManager.countMatchingPrefix ["A"] [] = 0L -Darklang.LanguageTools.PackageManager.countMatchingPrefix [] ["A"] = 0L -Darklang.LanguageTools.PackageManager.countMatchingPrefix ["A"] ["A"] = 1L -Darklang.LanguageTools.PackageManager.countMatchingPrefix ["A"; "B"] ["A"; "B"] = 2L -Darklang.LanguageTools.PackageManager.countMatchingPrefix ["A"; "B"; "C"] ["A"; "B"; "C"] = 3L -Darklang.LanguageTools.PackageManager.countMatchingPrefix ["A"; "B"] ["A"; "X"] = 1L -Darklang.LanguageTools.PackageManager.countMatchingPrefix ["X"; "B"] ["A"; "B"] = 0L -Darklang.LanguageTools.PackageManager.countMatchingPrefix ["A"; "B"; "C"] ["A"; "B"] = 2L -Darklang.LanguageTools.PackageManager.countMatchingPrefix ["A"; "B"] ["A"; "B"; "C"] = 2L +Darklang.LanguageTools.PackageManager.countMatchingPrefix [] [] = 0I +Darklang.LanguageTools.PackageManager.countMatchingPrefix ["A"] [] = 0I +Darklang.LanguageTools.PackageManager.countMatchingPrefix [] ["A"] = 0I +Darklang.LanguageTools.PackageManager.countMatchingPrefix ["A"] ["A"] = 1I +Darklang.LanguageTools.PackageManager.countMatchingPrefix ["A"; "B"] ["A"; "B"] = 2I +Darklang.LanguageTools.PackageManager.countMatchingPrefix ["A"; "B"; "C"] ["A"; "B"; "C"] = 3I +Darklang.LanguageTools.PackageManager.countMatchingPrefix ["A"; "B"] ["A"; "X"] = 1I +Darklang.LanguageTools.PackageManager.countMatchingPrefix ["X"; "B"] ["A"; "B"] = 0I +Darklang.LanguageTools.PackageManager.countMatchingPrefix ["A"; "B"; "C"] ["A"; "B"] = 2I +Darklang.LanguageTools.PackageManager.countMatchingPrefix ["A"; "B"] ["A"; "B"; "C"] = 2I // ======================================== diff --git a/backend/testfiles/execution/stdlib/stream.dark b/backend/testfiles/execution/stdlib/stream.dark index 9a483413fb..a859f77cb3 100644 --- a/backend/testfiles/execution/stdlib/stream.dark +++ b/backend/testfiles/execution/stdlib/stream.dark @@ -53,17 +53,17 @@ // take caps at n (let s = Stdlib.Stream.fromList [ 10L; 20L; 30L; 40L ] - let first2 = Stdlib.Stream.take s 2L + let first2 = Stdlib.Stream.take s 2I Stdlib.Stream.toList first2) = [ 10L; 20L ] // take more than available returns all available (let s = Stdlib.Stream.fromList [ 7L; 8L ] - let wide = Stdlib.Stream.take s 10L + let wide = Stdlib.Stream.take s 10I Stdlib.Stream.toList wide) = [ 7L; 8L ] // take 0 returns empty without pulling (let s = Stdlib.Stream.fromList [ 1L; 2L ] - let none = Stdlib.Stream.take s 0L + let none = Stdlib.Stream.take s 0I Stdlib.Stream.toList none) = [] // concat drains streams in list order @@ -88,7 +88,7 @@ (let s = Stdlib.Stream.fromList [ 1L; 2L; 3L; 4L; 5L; 6L; 7L; 8L; 9L; 10L ] let filtered = Stdlib.Stream.filter s (fun n -> n % 2L == 0L) let mapped = Stdlib.Stream.map filtered (fun n -> n + 1L) - let taken = Stdlib.Stream.take mapped 3L + let taken = Stdlib.Stream.take mapped 3I Stdlib.Stream.toList taken) = [ 3L; 5L; 7L ] @@ -102,12 +102,12 @@ // take after map — the take limit applies to the mapped output (let s = Stdlib.Stream.fromList [ 1L; 2L; 3L; 4L; 5L ] let mapped = Stdlib.Stream.map s (fun n -> n * 10L) - let taken = Stdlib.Stream.take mapped 2L + let taken = Stdlib.Stream.take mapped 2I Stdlib.Stream.toList taken) = [ 10L; 20L ] // map after take — map only applies to elements that survive the take (let s = Stdlib.Stream.fromList [ 1L; 2L; 3L; 4L; 5L ] - let taken = Stdlib.Stream.take s 3L + let taken = Stdlib.Stream.take s 3I let mapped = Stdlib.Stream.map taken (fun n -> n * n) Stdlib.Stream.toList mapped) = [ 1L; 4L; 9L ] @@ -122,7 +122,7 @@ // filter then take: early-terminate once Take is satisfied (let s = Stdlib.Stream.fromList [ 1L; 2L; 3L; 4L; 5L; 6L; 7L; 8L ] let evens = Stdlib.Stream.filter s (fun n -> n % 2L == 0L) - let firstTwo = Stdlib.Stream.take evens 2L + let firstTwo = Stdlib.Stream.take evens 2I Stdlib.Stream.toList firstTwo) = [ 2L; 4L ] // concat of concats flattens correctly @@ -137,7 +137,7 @@ (let s = Stdlib.Stream.fromList [] let mapped = Stdlib.Stream.map s (fun n -> n + 1L) let filtered = Stdlib.Stream.filter mapped (fun n -> n > 0L) - let taken = Stdlib.Stream.take filtered 5L + let taken = Stdlib.Stream.take filtered 5I Stdlib.Stream.toList taken) = [] // Stream round-trips via fromList/toList diff --git a/packages/darklang/cli/packages/search.dark b/packages/darklang/cli/packages/search.dark index cbff120ad9..26143b8725 100644 --- a/packages/darklang/cli/packages/search.dark +++ b/packages/darklang/cli/packages/search.dark @@ -35,14 +35,14 @@ let operatorAlias (query: String) : Stdlib.Option.Option = // the canonical operation the camelCase concept is built on. A hit matched only // via its doc comment (the query token isn't in the name at all) ranks last, so // the name-relevant results aren't pushed under the display cap. Case-insensitive. -let matchRank (query: String) (name: String) : Int64 = +let matchRank (query: String) (name: String) : Int = let q = Stdlib.String.toLowercase query let n = Stdlib.String.toLowercase name - if n == q then 0L - else if Stdlib.String.startsWith q n then 1L // query elaborates name: parseInt ⊃ parse - else if Stdlib.String.startsWith n q then 2L // name elaborates query: parseIntLiteral ⊃ parseInt - else if Stdlib.String.contains n q then 3L - else 4L + if n == q then 0I + else if Stdlib.String.startsWith q n then 1I // query elaborates name: parseInt ⊃ parse + else if Stdlib.String.startsWith n q then 2I // name elaborates query: parseIntLiteral ⊃ parseInt + else if Stdlib.String.contains n q then 3I + else 4I let isStdlib (owner: String) (modules: List) : Bool = @@ -58,7 +58,7 @@ let sortKey (modules: List) (name: String) : String = - let mr = Stdlib.Int64.toString (matchRank query name) + let mr = Stdlib.Int.toString (matchRank query name) let st = if isStdlib owner modules then "0" else "1" $"{mr}{st}:{name}" @@ -67,16 +67,16 @@ let sortKey let bestItemRank (query: String) (items: List>) - : Int64 = + : Int = items - |> Stdlib.List.fold 9L (fun acc item -> + |> Stdlib.List.fold 9I (fun acc item -> let r = matchRank query item.location.name if r < acc then r else acc) -let bestModuleRank (query: String) (modules: List>) : Int64 = +let bestModuleRank (query: String) (modules: List>) : Int = modules - |> Stdlib.List.fold 9L (fun acc modulePath -> + |> Stdlib.List.fold 9I (fun acc modulePath -> let modName = Stdlib.Option.withDefault (Stdlib.List.last modulePath) "" let r = matchRank query modName if r < acc then r else acc) @@ -297,16 +297,16 @@ let execute (state: Cli.AppState) (args: List) : Cli.AppState = if Stdlib.List.isEmpty parsed.entityTypes then bestModuleRank queryText results.submodules else - 9L + 9I // Suffix orders sections on a rank tie. Modules are navigation, not the // usual discovery target, so they sort last - a wall of namespace // matches shouldn't precede an equally-ranked fn/type/value hit. let sectionKeys = - [ ($"{Stdlib.Int64.toString moduleRank}4", "module") - ($"{Stdlib.Int64.toString (bestItemRank queryText results.types)}1", "type") - ($"{Stdlib.Int64.toString (bestItemRank queryText results.values)}2", "value") - ($"{Stdlib.Int64.toString (bestItemRank queryText results.fns)}3", "function") ] + [ ($"{Stdlib.Int.toString moduleRank}4", "module") + ($"{Stdlib.Int.toString (bestItemRank queryText results.types)}1", "type") + ($"{Stdlib.Int.toString (bestItemRank queryText results.values)}2", "value") + ($"{Stdlib.Int.toString (bestItemRank queryText results.fns)}3", "function") ] let order = sectionKeys diff --git a/packages/darklang/languageTools/packageManager.dark b/packages/darklang/languageTools/packageManager.dark index c744ed507b..62e54e0518 100644 --- a/packages/darklang/languageTools/packageManager.dark +++ b/packages/darklang/languageTools/packageManager.dark @@ -17,14 +17,14 @@ module PickContext = PickContext { currentModule = [] } /// Count how many leading segments of two lists match. -let countMatchingPrefix (a: List) (b: List) : Int64 = +let countMatchingPrefix (a: List) (b: List) : Int = match (a, b) with | (aHead :: aTail, bHead :: bTail) -> if aHead == bHead then - 1L + (countMatchingPrefix aTail bTail) + 1I + (countMatchingPrefix aTail bTail) else - 0L - | _ -> 0L + 0I + | _ -> 0I /// Given a list of locations for a hash, pick the best one using context. /// Scoring: most matching prefix segments with currentModule, then shortest path, diff --git a/packages/darklang/stdlib/stream.dark b/packages/darklang/stdlib/stream.dark index 0e885d72c4..a7260ba76a 100644 --- a/packages/darklang/stdlib/stream.dark +++ b/packages/darklang/stdlib/stream.dark @@ -51,7 +51,7 @@ let filter (stream: Stream<'a>) (pred: 'a -> Bool) : Stream<'a> = /// Returns a new Stream yielding at most elements from the /// front of . Lazy; the source advances exactly /// times (or fewer, if the source exhausts first). -let take (stream: Stream<'a>) (n: Int64) : Stream<'a> = +let take (stream: Stream<'a>) (n: Int) : Stream<'a> = Builtin.streamTake<'a> stream n From f6da743f32e5d9b35b05b9bb2c9e57c0b6764943 Mon Sep 17 00:00:00 2001 From: OceanOak Date: Thu, 18 Jun 2026 08:36:15 +0000 Subject: [PATCH 26/61] Add JSON Int overflow tests --- backend/testfiles/execution/stdlib/json.dark | 92 ++++++++++--------- .../darklang/languageTools/parser/core.dark | 14 +-- 2 files changed, 58 insertions(+), 48 deletions(-) diff --git a/backend/testfiles/execution/stdlib/json.dark b/backend/testfiles/execution/stdlib/json.dark index 19e2be0f70..3ea8b5a487 100644 --- a/backend/testfiles/execution/stdlib/json.dark +++ b/backend/testfiles/execution/stdlib/json.dark @@ -71,6 +71,57 @@ module Bool = Result.Error "Not JSON" +module Int = + module Basic = + Stdlib.Json.serialize 0I = "0" + Stdlib.Json.serialize 12345I = "12345" + Stdlib.Json.serialize -12345I = "-12345" + Stdlib.Json.parse "0" = Result.Ok 0I + Stdlib.Json.parse "12345" = Result.Ok 12345I + Stdlib.Json.parse "-12345" = Result.Ok(-12345I) + + module Huge = + // arbitrary precision: well past Int64, exact round-trip + Stdlib.Json.serialize 123456789012345678901234567890I = "123456789012345678901234567890" + Stdlib.Json.parse "123456789012345678901234567890" = Result.Ok 123456789012345678901234567890I + Stdlib.Json.parse "-123456789012345678901234567890" = Result.Ok(-123456789012345678901234567890I) + (Stdlib.Json.parse (Stdlib.Json.serialize 99999999999999999999999999999999I)) = Result.Ok 99999999999999999999999999999999I + + module PastInt64 = + // Int is unbounded: it serializes/parses values that overflow Int64. + // Compare the Int64Limits module above, which *errors* on these exact values. + Stdlib.Json.serialize 9223372036854775808I = "9223372036854775808" + Stdlib.Json.parse "9223372036854775808" = Result.Ok 9223372036854775808I + Stdlib.Json.parse "-9223372036854775809" = Result.Ok(-9223372036854775809I) + // a float-form just above the Int64 max (Int64 rejects "9.3E18") + Stdlib.Json.parse "9.3E18" = Result.Ok 9300000000000000000I + + module IntegerValuedFloatForms = + // integer-valued decimal/exponent forms are accepted, parsed EXACTLY + // (the same forms the fixed-width int parsers accept) + Stdlib.Json.parse "0.0" = Result.Ok 0I + Stdlib.Json.parse "-1.0" = Result.Ok(-1I) + Stdlib.Json.parse "1.2E2" = Result.Ok 120I + Stdlib.Json.parse "1.2E+2" = Result.Ok 120I + Stdlib.Json.parse "1200E-1" = Result.Ok 120I + // exact even past 2^53 — guards the precision-loss regression + Stdlib.Json.parse "9007199254740993.0" = Result.Ok 9007199254740993I + + module Errors = + // genuinely fractional values are rejected, never rounded + (Stdlib.Json.parse "1.5") |> err = Result.Error "Can't parse JSON `1.5` as type `Int` at path: `root`" + (Stdlib.Json.parse "9007199254740993.5") |> err = Result.Error "Can't parse JSON `9007199254740993.5` as type `Int` at path: `root`" + (Stdlib.Json.parse "\"42\"") |> err = Result.Error "Can't parse JSON `\"42\"` as type `Int` at path: `root`" + (Stdlib.Json.parse "null") |> err = Result.Error "Can't parse JSON `null` as type `Int` at path: `root`" + + // extreme exponents are rejected cleanly, never crash or hang the parser + (Stdlib.Json.parse "1e2147483647") |> err = Result.Error "Can't parse JSON `1e2147483647` as type `Int` at path: `root`" + (Stdlib.Json.parse "1e-2147483647") |> err = Result.Error "Can't parse JSON `1e-2147483647` as type `Int` at path: `root`" + (Stdlib.Json.parse "1e-2147483648") |> err = Result.Error "Can't parse JSON `1e-2147483648` as type `Int` at path: `root`" + // ...but zero with an extreme negative exponent is still exactly zero + Stdlib.Json.parse "0e-2147483648" = Result.Ok 0I + + module Int64 = module Basic = Stdlib.Json.serialize 0L = "0" @@ -1448,44 +1499,3 @@ module Package = // ## Nested types (lists, tuples, records, etc.) // Stdlib.Json.serialize> * Dict>>>>> = Ok "test" // Stdlib.Json.serialize> * Dict>>>>> = Ok "test" - -module Int = - module Basic = - Stdlib.Json.serialize 0I = "0" - Stdlib.Json.serialize 12345I = "12345" - Stdlib.Json.serialize -12345I = "-12345" - Stdlib.Json.parse "0" = Result.Ok 0I - Stdlib.Json.parse "12345" = Result.Ok 12345I - Stdlib.Json.parse "-12345" = Result.Ok(-12345I) - - module Huge = - // arbitrary precision: well past Int64, exact round-trip - Stdlib.Json.serialize 123456789012345678901234567890I = "123456789012345678901234567890" - Stdlib.Json.parse "123456789012345678901234567890" = Result.Ok 123456789012345678901234567890I - Stdlib.Json.parse "-123456789012345678901234567890" = Result.Ok(-123456789012345678901234567890I) - (Stdlib.Json.parse (Stdlib.Json.serialize 99999999999999999999999999999999I)) = Result.Ok 99999999999999999999999999999999I - - module IntegerValuedFloatForms = - // integer-valued decimal/exponent forms are accepted, parsed EXACTLY - // (the same forms the fixed-width int parsers accept) - Stdlib.Json.parse "0.0" = Result.Ok 0I - Stdlib.Json.parse "-1.0" = Result.Ok(-1I) - Stdlib.Json.parse "1.2E2" = Result.Ok 120I - Stdlib.Json.parse "1.2E+2" = Result.Ok 120I - Stdlib.Json.parse "1200E-1" = Result.Ok 120I - // exact even past 2^53 — guards the precision-loss regression - Stdlib.Json.parse "9007199254740993.0" = Result.Ok 9007199254740993I - - module Errors = - // genuinely fractional values are rejected, never rounded - (Stdlib.Json.parse "1.5") |> err = Result.Error "Can't parse JSON `1.5` as type `Int` at path: `root`" - (Stdlib.Json.parse "9007199254740993.5") |> err = Result.Error "Can't parse JSON `9007199254740993.5` as type `Int` at path: `root`" - (Stdlib.Json.parse "\"42\"") |> err = Result.Error "Can't parse JSON `\"42\"` as type `Int` at path: `root`" - (Stdlib.Json.parse "null") |> err = Result.Error "Can't parse JSON `null` as type `Int` at path: `root`" - - // extreme exponents are rejected cleanly, never crash or hang the parser - (Stdlib.Json.parse "1e2147483647") |> err = Result.Error "Can't parse JSON `1e2147483647` as type `Int` at path: `root`" - (Stdlib.Json.parse "1e-2147483647") |> err = Result.Error "Can't parse JSON `1e-2147483647` as type `Int` at path: `root`" - (Stdlib.Json.parse "1e-2147483648") |> err = Result.Error "Can't parse JSON `1e-2147483648` as type `Int` at path: `root`" - // ...but zero with an extreme negative exponent is still exactly zero - Stdlib.Json.parse "0e-2147483648" = Result.Ok 0I diff --git a/packages/darklang/languageTools/parser/core.dark b/packages/darklang/languageTools/parser/core.dark index f9674e2fd3..089b3c9347 100644 --- a/packages/darklang/languageTools/parser/core.dark +++ b/packages/darklang/languageTools/parser/core.dark @@ -159,13 +159,13 @@ let decodeEscapeNode // Number of chars in the escape (including the leading `\`), based on the // char following `\`. Mirrors the shapes accepted by `decodeSingleEscape`. -let escapeLength (afterBackslash: Char) : Int64 = +let escapeLength (afterBackslash: Char) : Int = match afterBackslash with - | 'x' -> 4L // \xHH - | 'X' -> 6L // \XHHHH - | 'u' -> 6L // \uHHHH - | 'U' -> 10L // \UHHHHHHHH - | _ -> 2L // \n \t \r \\ \" \' \/ \a \b \f \v + | 'x' -> 4I // \xHH + | 'X' -> 6I // \XHHHH + | 'u' -> 6I // \uHHHH + | 'U' -> 10I // \UHHHHHHHH + | _ -> 2I // \n \t \r \\ \" \' \/ \a \b \f \v let charsToString (chars: List) : String = @@ -187,7 +187,7 @@ let decodeChars match chars with | [] -> Stdlib.Result.Result.Ok acc | '\\' :: afterBackslash :: _ -> - let len = Stdlib.Int.fromInt64 (escapeLength afterBackslash) + let len = escapeLength afterBackslash let escapeChars = Stdlib.List.take chars len let remaining = Stdlib.List.drop chars len if Stdlib.List.length escapeChars < len then From 507a0c786930e39729264456bf1ea4949ba95a87 Mon Sep 17 00:00:00 2001 From: OceanOak Date: Thu, 18 Jun 2026 08:45:34 +0000 Subject: [PATCH 27/61] Migrate package-manager Stats counts from Int64 to Int --- backend/src/Builtins/Builtins.Matter/Libs/PM/Packages.fs | 6 +++--- packages/darklang/dark-packages.dark | 6 +++--- packages/darklang/internal/dark-packages/dark-packages.dark | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/backend/src/Builtins/Builtins.Matter/Libs/PM/Packages.fs b/backend/src/Builtins/Builtins.Matter/Libs/PM/Packages.fs index 648aa5d92d..3692ff7875 100644 --- a/backend/src/Builtins/Builtins.Matter/Libs/PM/Packages.fs +++ b/backend/src/Builtins/Builtins.Matter/Libs/PM/Packages.fs @@ -59,9 +59,9 @@ let fns (pm : PT.PackageManager) : List = statsTypeName (), statsTypeName (), [], - [ "types", DInt64 stats.types - "values", DInt64 stats.values - "fns", DInt64 stats.fns ] + [ "types", Dval.int (bigint stats.types) + "values", Dval.int (bigint stats.values) + "fns", Dval.int (bigint stats.fns) ] |> Map ) } diff --git a/packages/darklang/dark-packages.dark b/packages/darklang/dark-packages.dark index d351dd9db5..dd6eb9250c 100644 --- a/packages/darklang/dark-packages.dark +++ b/packages/darklang/dark-packages.dark @@ -2,6 +2,6 @@ module Darklang.DarkPackages type Stats = - { types: Int64 - values: Int64 - fns: Int64 } \ No newline at end of file + { types: Int + values: Int + fns: Int } \ No newline at end of file diff --git a/packages/darklang/internal/dark-packages/dark-packages.dark b/packages/darklang/internal/dark-packages/dark-packages.dark index e40f57f77a..a47535020d 100644 --- a/packages/darklang/internal/dark-packages/dark-packages.dark +++ b/packages/darklang/internal/dark-packages/dark-packages.dark @@ -142,9 +142,9 @@ let statsHandlerFn (req: HttpRequest) : HttpResponse = let stats = Builtin.pmGetStats () let body = $"Package stats: -- types: {stats.types |> Stdlib.Int64.toString} -- fns: {stats.fns |> Stdlib.Int64.toString} -- values: {stats.values |> Stdlib.Int64.toString}" +- types: {stats.types |> Stdlib.Int.toString} +- fns: {stats.fns |> Stdlib.Int.toString} +- values: {stats.values |> Stdlib.Int.toString}" Stdlib.Http.responseWithText body 200I let statsHandler: Handler = From 5432cc38e3c3e42f29db18b2e0356d07c674a157 Mon Sep 17 00:00:00 2001 From: OceanOak Date: Thu, 18 Jun 2026 08:59:13 +0000 Subject: [PATCH 28/61] Fix Discord embed color Int64/Int mismatch --- packages/darklang/discord.dark | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/darklang/discord.dark b/packages/darklang/discord.dark index 53b7ca186c..44beb97640 100644 --- a/packages/darklang/discord.dark +++ b/packages/darklang/discord.dark @@ -28,7 +28,7 @@ type Embed = /// ISO8601 timestamp string, e.g. from Stdlib.DateTime.toString. timestamp: Stdlib.Option.Option /// Sidebar color as a decimal RGB integer, e.g. 0xFF0000 = 16711680 = red. - color: Stdlib.Option.Option + color: Stdlib.Option.Option footer: Stdlib.Option.Option imageUrl: Stdlib.Option.Option thumbnailUrl: Stdlib.Option.Option From 2b50cb91407e73554edde95f0f8dff700252f9b5 Mon Sep 17 00:00:00 2001 From: OceanOak Date: Thu, 18 Jun 2026 09:06:35 +0000 Subject: [PATCH 29/61] Migrate JSON-RPC error codes from Int64 to Int --- packages/darklang/json-rpc.dark | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/darklang/json-rpc.dark b/packages/darklang/json-rpc.dark index 8bdf7d6652..ccc85c1eb9 100644 --- a/packages/darklang/json-rpc.dark +++ b/packages/darklang/json-rpc.dark @@ -262,21 +262,21 @@ module Response = module Error = module KnownErrorCodes = - let parserError = -32700L - let invalidRequest = -32600L - let methodNotFound = -32601L - let invalidParams = -32602L - let internalError = -32603L + let parserError = -32700I + let invalidRequest = -32600I + let methodNotFound = -32601I + let invalidParams = -32602I + let internalError = -32603I let make (requestId: Stdlib.Option.Option) - (errorCode: Int64) + (errorCode: Int) (errorMessage: String) (errorData: Stdlib.Option.Option) : Json = let errorDetailFeilds = [ Stdlib.Option.Option.Some( - ("code", Json.Number(Stdlib.Int64.toFloat errorCode)) + ("code", Json.Number(Stdlib.Int.toFloat errorCode)) ) Stdlib.Option.Option.Some(("message", Json.String errorMessage)) (errorData |> Stdlib.Option.map (fun data -> ("data", data))) ] From d04c1ef9b7602d8df61d12699a767b9e5d5d437f Mon Sep 17 00:00:00 2001 From: OceanOak Date: Thu, 18 Jun 2026 09:14:08 +0000 Subject: [PATCH 30/61] Migrate tailscale serve port from Int64 to Int --- packages/darklang/cli/devices.dark | 2 +- packages/darklang/tailscale.dark | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/darklang/cli/devices.dark b/packages/darklang/cli/devices.dark index 32c9d0a089..ad717bbe0b 100644 --- a/packages/darklang/cli/devices.dark +++ b/packages/darklang/cli/devices.dark @@ -24,7 +24,7 @@ let execute (state: AppState) (args: List) : AppState = state | [ "serve"; portStr ] -> - match Stdlib.Int64.parse portStr with + match Stdlib.Int.parse portStr with | Ok port -> match Darklang.Tailscale.serve port with | Ok() -> diff --git a/packages/darklang/tailscale.dark b/packages/darklang/tailscale.dark index c7c1f5aff1..c49b3f2346 100644 --- a/packages/darklang/tailscale.dark +++ b/packages/darklang/tailscale.dark @@ -22,9 +22,9 @@ let status () : Stdlib.Result.Result = run "status" // Expose this instance's local HTTP server over TLS on the tailnet (`tailscale serve --https=443`). -let serve (localPort: Int64) : Stdlib.Result.Result = +let serve (localPort: Int) : Stdlib.Result.Result = Stdlib.Cli.executeWithUnitOrStdErr - ("tailscale serve --https=443 " ++ Stdlib.Int64.toString localPort) + ("tailscale serve --https=443 " ++ Stdlib.Int.toString localPort) // Reachability check to a peer by MagicDNS name (`tailscale ping `). let ping (peer: String) : Stdlib.Result.Result = From 5376eb407c9067b2cd83bc1e138ede4b3b737d09 Mon Sep 17 00:00:00 2001 From: OceanOak Date: Thu, 18 Jun 2026 09:41:27 +0000 Subject: [PATCH 31/61] Migrate ports, config ints, and protocol error codes from Int64 to Int --- packages/darklang/cli/apps/command.dark | 8 +++----- packages/darklang/cli/apps/examples.dark | 18 +++++++++--------- packages/darklang/cli/apps/servers.dark | 8 ++++---- packages/darklang/cli/config.dark | 6 +++--- .../darklang/modelContextProtocol/common.dark | 18 +++++++++--------- .../modelContextProtocol/serverBuilder/io.dark | 2 +- packages/darklang/stdlib/httpserver.dark | 2 +- 7 files changed, 30 insertions(+), 32 deletions(-) diff --git a/packages/darklang/cli/apps/command.dark b/packages/darklang/cli/apps/command.dark index ac79075a0b..b3a0196612 100644 --- a/packages/darklang/cli/apps/command.dark +++ b/packages/darklang/cli/apps/command.dark @@ -8,9 +8,7 @@ module Darklang.Cli.Apps.Command /// The port a running HTTP daemon bound to, read from its log (`… on http://localhost:`). This is /// the *actual* port (default or config override), so it's accurate without the browser knowing defaults. /// `None` for daemons that aren't HTTP servers (they never log a port). - -// TODO: Log text isn't a reliable source of truth; store structured daemon metadata instead. -let daemonPort (slug: String) : Stdlib.Option.Option = +let daemonPort (slug: String) : Stdlib.Option.Option = let portLines = (Stdlib.Cli.Daemon.tailLog slug 25I) |> Stdlib.List.filter (fun l -> Stdlib.String.contains l "localhost:") @@ -20,7 +18,7 @@ let daemonPort (slug: String) : Stdlib.Option.Option = | Some line -> match Stdlib.List.last (Stdlib.String.split line "localhost:") with | None -> Stdlib.Option.Option.None - | Some tail -> Stdlib.Result.toOption (Stdlib.Int64.parse (Stdlib.String.trim tail)) + | Some tail -> Stdlib.Result.toOption (Stdlib.Int.parse (Stdlib.String.trim tail)) /// The live state of a daemon, for listing: "running (pid N) :port" / "stale (pid N)" / "stopped". /// HTTP daemons append the port they actually bound to. @@ -30,7 +28,7 @@ let daemonState (slug: String) : String = if Stdlib.Cli.Posix.isProcessRunning pid then let portStr = match daemonPort slug with - | Some p -> $" :{Stdlib.Int64.toString p}" + | Some p -> $" :{Stdlib.Int.toString p}" | None -> "" $"running (pid {Stdlib.Int64.toString pid}){portStr}" else diff --git a/packages/darklang/cli/apps/examples.dark b/packages/darklang/cli/apps/examples.dark index c88b4a3666..b3e01b25c5 100644 --- a/packages/darklang/cli/apps/examples.dark +++ b/packages/darklang/cli/apps/examples.dark @@ -7,31 +7,31 @@ module Darklang.Cli.Apps.Examples // One beat: log the time + pid, sleep the interval, recurse. `remaining` is a very large step count // (≈ forever); the daemon is meant to be ended by `apps stop` (SIGTERM), not by running out. -let beat (name: String) (intervalMs: Int64) (remaining: Int64) : Int64 = - if remaining <= 0L then - 0L +let beat (name: String) (intervalMs: Int) (remaining: Int) : Int = + if remaining <= 0I then + 0I else let pid = Stdlib.Cli.Sys.currentPid () Stdlib.printLine $"{name}: beat (pid {Stdlib.Int64.toString pid})" - Stdlib.Cli.Posix.sleep (Stdlib.Int64.toFloat intervalMs) - beat name intervalMs (remaining - 1L) + Stdlib.Cli.Posix.sleep (Stdlib.Int.toFloat intervalMs) + beat name intervalMs (remaining - 1I) // The daemon entrypoint: claim the pidfile (recording THIS detached process's pid), then beat forever. // Invoked as `Darklang.Cli.Apps.Examples.heartbeat "heartbeat"` by `apps start`. The interval is read // from config (`apps..intervalMs`, default 5000) — daemons take their config from cli-config.json, // not argv. -let heartbeat (name: String) : Int64 = - let intervalMs = Config.getInt ("apps." ++ name ++ ".intervalMs") 5000L +let heartbeat (name: String) : Int = + let intervalMs = Config.getInt ("apps." ++ name ++ ".intervalMs") 5000I let _logged = match Stdlib.Cli.Daemon.claimPidfile name with | Error e -> Stdlib.printLine $"{name}: could not write pidfile: {e}" | Ok _ -> Stdlib.printLine - $"{name}: started (pid {Stdlib.Int64.toString (Stdlib.Cli.Sys.currentPid ())}, interval {Stdlib.Int64.toString intervalMs}ms)" + $"{name}: started (pid {Stdlib.Int64.toString (Stdlib.Cli.Sys.currentPid ())}, interval {Stdlib.Int.toString intervalMs}ms)" - beat name intervalMs 1000000000L + beat name intervalMs 1000000000I module TextEdit = diff --git a/packages/darklang/cli/apps/servers.dark b/packages/darklang/cli/apps/servers.dark index 871b47bcdf..0acc1d730b 100644 --- a/packages/darklang/cli/apps/servers.dark +++ b/packages/darklang/cli/apps/servers.dark @@ -8,21 +8,21 @@ module Darklang.Cli.Apps.Servers // Claim the pidfile, resolve the port (config `apps..port`, else `defaultPort`), then serve `router`. let httpDaemon (name: String) - (defaultPort: Int64) + (defaultPort: Int) (label: String) (router: Stdlib.Http.Request -> Stdlib.Http.Response) : Unit = let _claimed = Stdlib.Cli.Daemon.claimPidfile name let port = Config.getInt ("apps." ++ name ++ ".port") defaultPort - Stdlib.printLine $"{name}: serving {label} on http://localhost:{Stdlib.Int64.toString port}" + Stdlib.printLine $"{name}: serving {label} on http://localhost:{Stdlib.Int.toString port}" Stdlib.HttpServer.serve (Stdlib.HttpServer.Config.defaults port) router // `dark-packages` — the package API server that powers wip.darklang.com/packages. Defaults to 9090, a // port the devcontainer forwards (9090–9099), so it's reachable from the host; override via config. let darkPackages (name: String) : Unit = - httpDaemon name 9090L "DarkPackages.router" Darklang.Internal.DarkPackages.router + httpDaemon name 9090I "DarkPackages.router" Darklang.Internal.DarkPackages.router // `demo-http` — a tiny demo server (/, /hello, /echo). Defaults to 9091 (a devcontainer-forwarded port). let demoHttp (name: String) : Unit = - httpDaemon name 9091L "HttpServerTest.router" Darklang.DemoData.HttpServerTest.router + httpDaemon name 9091I "HttpServerTest.router" Darklang.DemoData.HttpServerTest.router diff --git a/packages/darklang/cli/config.dark b/packages/darklang/cli/config.dark index e8a50db128..65d4c974f4 100644 --- a/packages/darklang/cli/config.dark +++ b/packages/darklang/cli/config.dark @@ -39,10 +39,10 @@ let get (key: String) : Stdlib.Option.Option = let config = readConfig () Stdlib.Dict.get config key -// A single Int64 config value, falling back to `default_` when absent or unparseable. -let getInt (key: String) (default_: Int64) : Int64 = +// A single Int config value, falling back to `default_` when absent or unparseable. +let getInt (key: String) (default_: Int) : Int = match get key with - | Some s -> Stdlib.Result.withDefault (Stdlib.Int64.parse s) default_ + | Some s -> Stdlib.Result.withDefault (Stdlib.Int.parse s) default_ | None -> default_ diff --git a/packages/darklang/modelContextProtocol/common.dark b/packages/darklang/modelContextProtocol/common.dark index 3f94fd404e..32655128a0 100644 --- a/packages/darklang/modelContextProtocol/common.dark +++ b/packages/darklang/modelContextProtocol/common.dark @@ -150,12 +150,12 @@ type CompletionCapabilities = /// Error codes for the Model Context Protocol module ErrorCodes = - let parseError = -32700L - let invalidRequest = -32600L - let methodNotFound = -32601L - let invalidParams = -32602L - let internalError = -32603L - let resourceNotFound = -32800L - let resourceAccessDenied = -32801L - let toolExecutionError = -32900L - let promptNotFound = -32950L \ No newline at end of file + let parseError = -32700I + let invalidRequest = -32600I + let methodNotFound = -32601I + let invalidParams = -32602I + let internalError = -32603I + let resourceNotFound = -32800I + let resourceAccessDenied = -32801I + let toolExecutionError = -32900I + let promptNotFound = -32950I \ No newline at end of file diff --git a/packages/darklang/modelContextProtocol/serverBuilder/io.dark b/packages/darklang/modelContextProtocol/serverBuilder/io.dark index c439fdbeea..dcac34428b 100644 --- a/packages/darklang/modelContextProtocol/serverBuilder/io.dark +++ b/packages/darklang/modelContextProtocol/serverBuilder/io.dark @@ -30,7 +30,7 @@ let sendSuccessResponseWithPath let sendErrorResponseWithPath (logFilePath: String) (requestId: Stdlib.Option.Option) - (code: Int64) + (code: Int) (message: String) : Unit = let response = JsonRPC.Response.Error.make requestId code message Stdlib.Option.Option.None diff --git a/packages/darklang/stdlib/httpserver.dark b/packages/darklang/stdlib/httpserver.dark index a8f531dc06..069bf448da 100644 --- a/packages/darklang/stdlib/httpserver.dark +++ b/packages/darklang/stdlib/httpserver.dark @@ -189,7 +189,7 @@ let getPathParam (req: Http.Request) (routePattern: String) (paramName: String) /// Configuration for `serve`. Build defaults with `Config.defaults port`, then override any field with -/// record-update, e.g. `{ HttpServer.Config.defaults 8080L with logRequests = false }`. +/// record-update, e.g. `{ HttpServer.Config.defaults 8080I with logRequests = false }`. module Config = type Config = { port: Int From 3a912033a74fc84d522118871cd6cb1bdbc21638 Mon Sep 17 00:00:00 2001 From: OceanOak Date: Thu, 18 Jun 2026 10:37:43 +0000 Subject: [PATCH 32/61] Migrate tracing maxDepth from Int64 to Int --- packages/darklang/cli/tracing.dark | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/darklang/cli/tracing.dark b/packages/darklang/cli/tracing.dark index 06acdd83cb..d9e45b27e0 100644 --- a/packages/darklang/cli/tracing.dark +++ b/packages/darklang/cli/tracing.dark @@ -14,7 +14,7 @@ type TraceData = Darklang.Tracing.TraceData /// nodes but recurses into their children at the SAME indent level so the /// surrounding structure stays intact. type ViewOptions = - { maxDepth: Stdlib.Option.Option + { maxDepth: Stdlib.Option.Option hideBuiltins: Bool hideStdlib: Bool filter: Stdlib.Option.Option @@ -94,9 +94,9 @@ let parseViewOptions | [] -> Stdlib.Result.Result.Ok opts | "--depth" :: n :: rest | "-d" :: n :: rest -> - match Stdlib.Int64.parse n with + match Stdlib.Int.parse n with | Ok depth -> - if depth < 0L then + if depth < 0I then Stdlib.Result.Result.Error $"--depth must be ≥ 0 (got {n})" else parseViewOptions @@ -975,7 +975,7 @@ let renderCall (branchId: Uuid) (childrenMap: Dict>) (call: FnCall) - (depth: Int64) + (depth: Int) (ancestorMatched: Bool) : List = let depthExceeded = @@ -996,14 +996,14 @@ let renderCall | None -> [] // When this call is hidden we keep child indent at our level so the // tree doesn't develop ghost gaps where the hidden line would have been. - let childDepth = if visible then depth + 1L else depth + let childDepth = if visible then depth + 1I else depth let childrenRendered = children |> Stdlib.List.map (fun c -> renderCall opts branchId childrenMap c childDepth matchedHere) |> Stdlib.List.flatten if visible then - let indent = Stdlib.String.repeat " " (Stdlib.Int.fromInt64 (depth + 1L)) + let indent = Stdlib.String.repeat " " (depth + 1I) let resultRepr = compactDval branchId call.result let durationSuffix = if call.durationMs > 0L then @@ -1054,14 +1054,14 @@ let formatFnCalls let rendered = roots |> Stdlib.List.map (fun r -> - renderCall opts branchId childrenMap r 0L false) + renderCall opts branchId childrenMap r 0I false) |> Stdlib.List.flatten match rendered with | [] -> // The empty case can happen for several reasons; help the user // figure out which by surfacing the most-likely cause first. match opts.maxDepth with - | Some 0L -> " (depth limit 0 — no calls shown)" + | Some 0I -> " (depth limit 0 — no calls shown)" | _ -> " (no calls match the active filters)" | _ -> Stdlib.String.join rendered "\n" From 5bfd7fc5aee9e7792a81721ea03c74ed3d8731f5 Mon Sep 17 00:00:00 2001 From: OceanOak Date: Thu, 18 Jun 2026 11:14:58 +0000 Subject: [PATCH 33/61] Migrate tracing from Int64 to Int --- .../Builtins/Builtins.Matter/Libs/Traces.fs | 66 +++--- backend/src/LibExecution/ValueType.fs | 1 + packages/darklang/cli/tracing.dark | 200 +++++++++--------- packages/darklang/tracing/format.dark | 6 +- packages/darklang/tracing/types.dark | 2 +- 5 files changed, 141 insertions(+), 134 deletions(-) diff --git a/backend/src/Builtins/Builtins.Matter/Libs/Traces.fs b/backend/src/Builtins/Builtins.Matter/Libs/Traces.fs index cf9cd6eed1..be6f601ede 100644 --- a/backend/src/Builtins/Builtins.Matter/Libs/Traces.fs +++ b/backend/src/Builtins/Builtins.Matter/Libs/Traces.fs @@ -108,7 +108,7 @@ let private loadFnCalls (traceId : string) : Ply = "lambdaExprId", lambdaExprIdDval "args", Dval.list dvalKT args "result", result - "durationMs", DInt64 ev.durationMs ] + "durationMs", Dval.int (bigint ev.durationMs) ] Some(DRecord(typeName, typeName, [], fields)) with ex -> print $"[tracing] dropping corrupt fn_call row: {ex.Message}" @@ -124,12 +124,13 @@ let private loadFnCalls (traceId : string) : Ply = let fns () : List = [ { name = fn "tracesList" 0 typeParams = [] - parameters = [ Param.make "limit" TInt64 "Max number of traces to return" ] + parameters = [ Param.make "limit" TInt "Max number of traces to return" ] returnType = TList(TVariable "a") description = "List recent traces" fn = (function - | _, _, _, [ DInt64 limit ] -> + | _, _, _, [ DInt limitArg ] -> + let limit = int64 (DarkInt.toBigInt limitArg) uply { let typeName = traceSummaryTypeName () let! rows = @@ -221,12 +222,13 @@ let fns () : List = typeParams = [] parameters = [ Param.make "fnName" TString "Function name to search for" - Param.make "limit" TInt64 "Max number of traces to return" ] + Param.make "limit" TInt "Max number of traces to return" ] returnType = TList(TVariable "a") description = "List traces that called a specific function" fn = (function - | _, _, _, [ DString fnName; DInt64 limit ] -> + | _, _, _, [ DString fnName; DInt limitArg ] -> + let limit = int64 (DarkInt.toBigInt limitArg) uply { // Both builtins and package fns store their display name in // fn_hash (resolved at write time), so one LIKE matches either. @@ -277,14 +279,15 @@ let fns () : List = parameters = [ Param.make "traceLimit" - TInt64 + TInt "Aggregate over the last N traces (e.g. 100)" ] - returnType = TList(TTuple(TString, TInt64, [ TInt64; TInt64 ])) + returnType = TList(TTuple(TString, TInt, [ TInt; TInt ])) description = "Per-handler aggregate over the last N traces: (handler, traceCount, totalMs, maxMs). Total ms sums every fn-call duration in each trace; per-trace latency would need a separate column on `traces`." fn = (function - | _, _, _, [ DInt64 traceLimit ] -> + | _, _, _, [ DInt traceLimitArg ] -> + let traceLimit = int64 (DarkInt.toBigInt traceLimitArg) uply { // Subquery: the last N trace IDs (and their handler_desc). // LEFT JOIN so traces with zero fn_calls still get counted. @@ -314,10 +317,10 @@ let fns () : List = |> List.map (fun r -> DTuple( DString r.handler, - DInt64 r.traceCount, - [ DInt64 r.totalMs; DInt64 r.maxMs ] + Dval.int (bigint r.traceCount), + [ Dval.int (bigint r.totalMs); Dval.int (bigint r.maxMs) ] )) - |> Dval.list (KTTuple(VT.string, VT.int64, [ VT.int64; VT.int64 ])) + |> Dval.list (KTTuple(VT.string, VT.int, [ VT.int; VT.int ])) } | _ -> incorrectArgs ()) sqlSpec = NotQueryable @@ -331,14 +334,15 @@ let fns () : List = parameters = [ Param.make "traceLimit" - TInt64 + TInt "Aggregate over the last N traces (e.g. 100)" ] - returnType = TList(TTuple(TString, TInt64, [ TInt64; TInt64 ])) + returnType = TList(TTuple(TString, TInt, [ TInt; TInt ])) description = "Aggregate fn-call timing across the last N traces. Returns (fnName, callCount, totalMs, maxMs) tuples sorted by totalMs desc. Lambdas are excluded (no fn_hash to bucket by); builtins included but always have 0ms duration." fn = (function - | _, _, _, [ DInt64 traceLimit ] -> + | _, _, _, [ DInt traceLimitArg ] -> + let traceLimit = int64 (DarkInt.toBigInt traceLimitArg) uply { // Subquery: the last N trace IDs by recency. // Outer GROUP BY rolls duration up per fn_hash. @@ -369,10 +373,10 @@ let fns () : List = |> List.map (fun r -> DTuple( DString r.name, - DInt64 r.callCount, - [ DInt64 r.totalMs; DInt64 r.maxMs ] + Dval.int (bigint r.callCount), + [ Dval.int (bigint r.totalMs); Dval.int (bigint r.maxMs) ] )) - |> Dval.list (KTTuple(VT.string, VT.int64, [ VT.int64; VT.int64 ])) + |> Dval.list (KTTuple(VT.string, VT.int, [ VT.int; VT.int ])) } | _ -> incorrectArgs ()) sqlSpec = NotQueryable @@ -392,13 +396,14 @@ let fns () : List = typeParams = [] parameters = [ Param.make "pattern" TString "Substring to find in inputs/args/results" - Param.make "limit" TInt64 "Max number of traces to return" ] + Param.make "limit" TInt "Max number of traces to return" ] returnType = TList(TVariable "a") description = "List traces whose recorded input or any fn-call args/result contains the substring (case-sensitive). Match is on the developer-repr form of each Dval." fn = (function - | exeState, _, _, [ DString pattern; DInt64 limit ] -> + | exeState, _, _, [ DString pattern; DInt limitArg ] -> + let limit = int64 (DarkInt.toBigInt limitArg) uply { let typeName = traceSummaryTypeName () @@ -597,7 +602,7 @@ let fns () : List = "cutoffISO" TString "ISO 8601 timestamp (e.g. 2026-05-02T01:00:00Z); traces with timestamp < cutoff are deleted." ] - returnType = TInt64 + returnType = TInt description = "Delete traces older than the given cutoff (and their fn_calls). Returns count deleted. Caller is responsible for computing the cutoff (e.g. `DateTime.now() |> subtractSeconds 3600` for 'last hour')." fn = @@ -628,7 +633,7 @@ let fns () : List = ("DELETE FROM traces WHERE timestamp < @cutoff", p) ] () - return DInt64 count + return Dval.int (bigint count) } | _ -> incorrectArgs ()) sqlSpec = NotQueryable @@ -640,7 +645,7 @@ let fns () : List = { name = fn "tracesClear" 0 typeParams = [] parameters = [ Param.make "unit" TUnit "Ignored" ] - returnType = TInt64 + returnType = TInt description = "Delete all traces, returns count deleted" fn = (function @@ -655,7 +660,7 @@ let fns () : List = Sql.executeTransactionSync [ ("DELETE FROM trace_fn_calls", [ [] ]) ("DELETE FROM traces", [ [] ]) ] - return DInt64 count + return Dval.int (bigint count) } | _ -> incorrectArgs ()) sqlSpec = NotQueryable @@ -667,7 +672,7 @@ let fns () : List = { name = fn "tracesDelete" 0 typeParams = [] parameters = [ Param.make "traceID" TString "Full trace ID to delete" ] - returnType = TInt64 + returnType = TInt description = "Delete one trace (and its fn_calls). Returns 1 if a row was deleted, 0 otherwise. Caller is responsible for resolving prefixes via tracesResolveID first." fn = @@ -679,7 +684,7 @@ let fns () : List = |> Sql.parameters [ "traceId", Sql.string traceID ] |> Sql.executeRowOptionAsync (fun _ -> ()) match existed with - | None -> return DInt64 0L + | None -> return Dval.int 0I | Some _ -> do! Sql.query "DELETE FROM trace_fn_calls WHERE trace_id = @traceId" @@ -689,7 +694,7 @@ let fns () : List = Sql.query "DELETE FROM traces WHERE id = @traceId" |> Sql.parameters [ "traceId", Sql.string traceID ] |> Sql.executeStatementAsync - return DInt64 1L + return Dval.int 1I } | _ -> incorrectArgs ()) sqlSpec = NotQueryable @@ -701,13 +706,14 @@ let fns () : List = { name = fn "tracesPruneKeep" 0 typeParams = [] parameters = - [ Param.make "keepN" TInt64 "Number of most-recent traces to keep" ] - returnType = TInt64 + [ Param.make "keepN" TInt "Number of most-recent traces to keep" ] + returnType = TInt description = "Delete all but the N most-recent traces (and their fn_calls). Returns the count deleted. Useful for bounded retention." fn = (function - | _, _, _, [ DInt64 keepN ] -> + | _, _, _, [ DInt keepNArg ] -> + let keepN = int64 (DarkInt.toBigInt keepNArg) uply { // Subquery picks the rowids to keep; outer DELETE removes the rest. // Wipe child rows first to avoid dangling fn_calls — there's no @@ -747,7 +753,7 @@ let fns () : List = p) ] () - return DInt64 count + return Dval.int (bigint count) } | _ -> incorrectArgs ()) sqlSpec = NotQueryable diff --git a/backend/src/LibExecution/ValueType.fs b/backend/src/LibExecution/ValueType.fs index 15c843995a..21754fa09f 100644 --- a/backend/src/LibExecution/ValueType.fs +++ b/backend/src/LibExecution/ValueType.fs @@ -25,6 +25,7 @@ let int64 = known KTInt64 let uint64 = known KTUInt64 let int128 = known KTInt128 let uint128 = known KTUInt128 +let int = known KTInt let float = known KTFloat let char = known KTChar let string = known KTString diff --git a/packages/darklang/cli/tracing.dark b/packages/darklang/cli/tracing.dark index d9e45b27e0..c949a334ee 100644 --- a/packages/darklang/cli/tracing.dark +++ b/packages/darklang/cli/tracing.dark @@ -22,7 +22,7 @@ type ViewOptions = /// Children still recurse so the surrounding structure stays intact. exclude: Stdlib.Option.Option /// When Some N, hide calls whose durationMs < N (keeps the slow stuff). - slowThresholdMs: Stdlib.Option.Option } + slowThresholdMs: Stdlib.Option.Option } let defaultViewOptions: ViewOptions = @@ -37,14 +37,14 @@ let defaultViewOptions: ViewOptions = /// English ordinal suffix for a non-negative integer. "1st", "2nd", /// "3rd", "4th"… honoring the 11/12/13 exception (always "th"). -let ordinalSuffix (n: Int64) : String = - let mod100 = n % 100L - if mod100 >= 11L && mod100 <= 13L then "th" +let ordinalSuffix (n: Int) : String = + let mod100 = n % 100I + if mod100 >= 11I && mod100 <= 13I then "th" else - match n % 10L with - | 1L -> "st" - | 2L -> "nd" - | 3L -> "rd" + match n % 10I with + | 1I -> "st" + | 2I -> "nd" + | 3I -> "rd" | _ -> "th" @@ -128,12 +128,12 @@ let parseViewOptions | "--slow" :: rest -> // Bare `--slow` defaults to 10ms. For a custom threshold, use --slow-ms. parseViewOptions - { opts with slowThresholdMs = Stdlib.Option.Option.Some 10L } + { opts with slowThresholdMs = Stdlib.Option.Option.Some 10I } rest | "--slow-ms" :: numStr :: rest -> - match Stdlib.Int64.parse numStr with + match Stdlib.Int.parse numStr with | Ok n -> - if n < 0L then + if n < 0I then Stdlib.Result.Result.Error $"--slow-ms must be ≥ 0 (got {numStr})" else parseViewOptions @@ -192,7 +192,7 @@ let execute (state: Cli.AppState) (args: List) : Cli.AppState = state | [ "list" ] -> - if wantsJson then executeListJson state 20L else executeList state 20L + if wantsJson then executeListJson state 20I else executeList state 20I | [ "list"; "--fn" ] -> Stdlib.printLine (Colors.error "Usage: traces list --fn [limit] [--json]") @@ -202,24 +202,24 @@ let execute (state: Cli.AppState) (args: List) : Cli.AppState = (Colors.error "Usage: traces list --route [limit] [--json]") state | [ "list"; limitStr ] -> - match Stdlib.Int64.parse limitStr with + match Stdlib.Int.parse limitStr with | Ok limit -> if wantsJson then executeListJson state limit else executeList state limit | Error _ -> Stdlib.printLine (Colors.error (parsePositionalErr limitStr "limit")) state | [ "list"; "--fn"; fnName ] -> - executeListByFn state fnName 20L wantsJson + executeListByFn state fnName 20I wantsJson | [ "list"; "--fn"; fnName; limitStr ] -> - match Stdlib.Int64.parse limitStr with + match Stdlib.Int.parse limitStr with | Ok limit -> executeListByFn state fnName limit wantsJson | Error _ -> Stdlib.printLine (Colors.error (parsePositionalErr limitStr "limit")) state | [ "list"; "--route"; route ] -> - executeListByRoute state route 20L wantsJson + executeListByRoute state route 20I wantsJson | [ "list"; "--route"; route; limitStr ] -> - match Stdlib.Int64.parse limitStr with + match Stdlib.Int.parse limitStr with | Ok limit -> executeListByRoute state route limit wantsJson | Error _ -> Stdlib.printLine (Colors.error (parsePositionalErr limitStr "limit")) @@ -231,16 +231,16 @@ let execute (state: Cli.AppState) (args: List) : Cli.AppState = executeFollow state (Stdlib.Option.Option.Some route) wantsJson | [ "stats" ] -> - if wantsJson then executeStatsJson state 100L else executeStats state 100L + if wantsJson then executeStatsJson state 100I else executeStats state 100I | [ "stats"; limitStr ] -> - match Stdlib.Int64.parse limitStr with + match Stdlib.Int.parse limitStr with | Ok limit -> if wantsJson then executeStatsJson state limit else executeStats state limit | Error _ -> Stdlib.printLine (Colors.error (parsePositionalErr limitStr "limit")) state - | [ "tail" ] -> executeTail state Stdlib.Option.Option.None 1L + | [ "tail" ] -> executeTail state Stdlib.Option.Option.None 1I // Flag-without-arg case must precede the `[ "tail"; nStr ]` arm // (which would otherwise treat "--route" as a malformed N). | [ "tail"; "--route" ] -> @@ -248,16 +248,16 @@ let execute (state: Cli.AppState) (args: List) : Cli.AppState = (Colors.error "Usage: traces tail [N] --route ") state | [ "tail"; nStr ] -> - match Stdlib.Int64.parse nStr with + match Stdlib.Int.parse nStr with | Ok n -> executeTail state Stdlib.Option.Option.None n | Error _ -> Stdlib.printLine (Colors.error (parsePositionalErr nStr "trace number")) state | [ "tail"; "--route"; route ] -> - executeTail state (Stdlib.Option.Option.Some route) 1L + executeTail state (Stdlib.Option.Option.Some route) 1I | [ "tail"; "--route"; route; nStr ] | [ "tail"; nStr; "--route"; route ] -> - match Stdlib.Int64.parse nStr with + match Stdlib.Int.parse nStr with | Ok n -> executeTail state (Stdlib.Option.Option.Some route) n | Error _ -> Stdlib.printLine (Colors.error (parsePositionalErr nStr "trace number")) @@ -267,11 +267,11 @@ let execute (state: Cli.AppState) (args: List) : Cli.AppState = if wantsFindView then executeFindView state pattern elif wantsJson then - executeFindJson state pattern 20L + executeFindJson state pattern 20I else - executeFind state pattern 20L + executeFind state pattern 20I | [ "find"; pattern; limitStr ] -> - match Stdlib.Int64.parse limitStr with + match Stdlib.Int.parse limitStr with | Ok limit -> if wantsJson then executeFindJson state pattern limit else executeFind state pattern limit @@ -280,10 +280,10 @@ let execute (state: Cli.AppState) (args: List) : Cli.AppState = state | [ "hotspots" ] -> - if wantsJson then executeHotspotsJson state 100L - else executeHotspots state 100L + if wantsJson then executeHotspotsJson state 100I + else executeHotspots state 100I | [ "hotspots"; limitStr ] -> - match Stdlib.Int64.parse limitStr with + match Stdlib.Int.parse limitStr with | Ok limit -> if wantsJson then executeHotspotsJson state limit else executeHotspots state limit @@ -326,11 +326,11 @@ let execute (state: Cli.AppState) (args: List) : Cli.AppState = state | [ "delete"; "--keep"; nStr ] -> - match Stdlib.Int64.parse nStr with + match Stdlib.Int.parse nStr with | Ok n -> if confirmDestructive autoConfirm - $"Keep the {Stdlib.Int64.toString n} most-recent traces and drop the rest?" then + $"Keep the {Stdlib.Int.toString n} most-recent traces and drop the rest?" then executePruneKeep state n else Stdlib.printLine "Cancelled." @@ -450,8 +450,8 @@ let execute (state: Cli.AppState) (args: List) : Cli.AppState = state -let executeList (state: Cli.AppState) (limit: Int64) : Cli.AppState = - if limit < 1L then +let executeList (state: Cli.AppState) (limit: Int) : Cli.AppState = + if limit < 1I then Stdlib.printLine (Colors.error "Limit must be ≥ 1") state else @@ -465,7 +465,7 @@ let executeList (state: Cli.AppState) (limit: Int64) : Cli.AppState = "(Traces are recorded by `darklang eval`, `darklang run`, or HTTP handlers under `darklang serve`.)") state | _ -> - Stdlib.printLine $"Recent traces (last {Stdlib.Int64.toString limit}):" + Stdlib.printLine $"Recent traces (last {Stdlib.Int.toString limit}):" Stdlib.printLine "" printTraceRows rows Stdlib.printLine "" @@ -476,8 +476,8 @@ let executeList (state: Cli.AppState) (limit: Int64) : Cli.AppState = /// `traces list --json [N]` — same data as `traces list` but emitted as a /// JSON array of `{traceId, handler, timestamp}` objects, no headers or /// footers. Designed for piping into jq / scripts. Empty store prints `[]`. -let executeListJson (state: Cli.AppState) (limit: Int64) : Cli.AppState = - if limit < 1L then +let executeListJson (state: Cli.AppState) (limit: Int) : Cli.AppState = + if limit < 1I then Stdlib.printLine (Colors.error "Limit must be ≥ 1") state else @@ -489,13 +489,13 @@ let executeListJson (state: Cli.AppState) (limit: Int64) : Cli.AppState = let executeListByFn (state: Cli.AppState) (fnName: String) - (limit: Int64) + (limit: Int) (jsonMode: Bool) : Cli.AppState = if Stdlib.String.trim fnName == "" then Stdlib.printLine (Colors.error "--fn pattern must not be empty") state - else if limit < 1L then + else if limit < 1I then Stdlib.printLine (Colors.error "Limit must be ≥ 1") state else @@ -509,7 +509,7 @@ let executeListByFn Stdlib.printLine $"No traces found calling '{fnName}'." state | _ -> - Stdlib.printLine $"Traces calling '{fnName}' (last {Stdlib.Int64.toString limit}):" + Stdlib.printLine $"Traces calling '{fnName}' (last {Stdlib.Int.toString limit}):" Stdlib.printLine "" printTraceRows rows Stdlib.printLine "" @@ -522,9 +522,9 @@ let executeListByFn /// descending. The "where is my time going?" view. let executeHotspots (state: Cli.AppState) - (traceLimit: Int64) + (traceLimit: Int) : Cli.AppState = - if traceLimit < 1L then + if traceLimit < 1I then Stdlib.printLine (Colors.error "Limit must be ≥ 1") state else @@ -532,21 +532,21 @@ let executeHotspots match rows with | [] -> - Stdlib.printLine $"No fn-call data in the last {Stdlib.Int64.toString traceLimit} traces." + Stdlib.printLine $"No fn-call data in the last {Stdlib.Int.toString traceLimit} traces." state | _ -> let fnCount = Stdlib.List.length rows let fnWord = if fnCount == 1I then "fn" else "fns" Stdlib.printLine - $"Hotspots (last {Stdlib.Int64.toString traceLimit} traces, top {Stdlib.Int.toString fnCount} {fnWord} by total ms):" + $"Hotspots (last {Stdlib.Int.toString traceLimit} traces, top {Stdlib.Int.toString fnCount} {fnWord} by total ms):" Stdlib.printLine "" Stdlib.printLine " total ms │ max ms │ count │ fn" Stdlib.printLine " ─────────┼──────────┼───────┼─────────────────────────" Stdlib.List.iter rows (fun row -> let (name, count, total, max) = row - let totalStr = padNum total 9L - let maxStr = padNum max 8L - let countStr = padNum count 5L + let totalStr = padNum total 9I + let maxStr = padNum max 8I + let countStr = padNum count 5I Stdlib.printLine $" {totalStr} │ {maxStr} │ {countStr} │ {name}") state @@ -556,9 +556,9 @@ let executeHotspots /// piping. Empty store prints `[]`. let executeHotspotsJson (state: Cli.AppState) - (traceLimit: Int64) + (traceLimit: Int) : Cli.AppState = - if traceLimit < 1L then + if traceLimit < 1I then Stdlib.printLine (Colors.error "Limit must be ≥ 1") state else @@ -568,9 +568,9 @@ let executeHotspotsJson |> Stdlib.List.map (fun row -> let (name, count, total, max) = row $"{{\"name\":\"{jsonEscape name}\"" - ++ $",\"count\":{Stdlib.Int64.toString count}" - ++ $",\"totalMs\":{Stdlib.Int64.toString total}" - ++ $",\"maxMs\":{Stdlib.Int64.toString max}}}") + ++ $",\"count\":{Stdlib.Int.toString count}" + ++ $",\"totalMs\":{Stdlib.Int.toString total}" + ++ $",\"maxMs\":{Stdlib.Int.toString max}}}") |> Stdlib.String.join "," Stdlib.printLine $"[{body}]" state @@ -580,7 +580,7 @@ let executeHotspotsJson /// Stdlib.padStart returns Result; this helper unwraps with empty-Error /// fallback (only fails on bad padWith, which we hardcode here). // Formatting helpers moved to `Darklang.Tracing.Format`. -let padNum (n: Int64) (width: Int64) : String = +let padNum (n: Int) (width: Int) : String = Darklang.Tracing.Format.padNum n width let jsonEscape (s: String) : String = Darklang.Tracing.Format.jsonEscape s @@ -593,12 +593,12 @@ let jsonEscape (s: String) : String = Darklang.Tracing.Format.jsonEscape s let executeFind (state: Cli.AppState) (pattern: String) - (limit: Int64) + (limit: Int) : Cli.AppState = if pattern == "" then Stdlib.printLine (Colors.error "find pattern must not be empty") state - else if limit < 1L then + else if limit < 1I then Stdlib.printLine (Colors.error "Limit must be ≥ 1") state else @@ -610,7 +610,7 @@ let executeFind state | _ -> Stdlib.printLine - $"Traces matching '{pattern}' (last {Stdlib.Int64.toString limit}):" + $"Traces matching '{pattern}' (last {Stdlib.Int.toString limit}):" Stdlib.printLine "" printTraceRows rows Stdlib.printLine "" @@ -624,12 +624,12 @@ let executeFind let executeFindJson (state: Cli.AppState) (pattern: String) - (limit: Int64) + (limit: Int) : Cli.AppState = if pattern == "" then Stdlib.printLine (Colors.error "find pattern must not be empty") state - else if limit < 1L then + else if limit < 1I then Stdlib.printLine (Colors.error "Limit must be ≥ 1") state else @@ -646,7 +646,7 @@ let executeFindView (state: Cli.AppState) (pattern: String) : Cli.AppState = Stdlib.printLine (Colors.error "find pattern must not be empty") state else - let rows = Builtin.tracesFind pattern 1L + let rows = Builtin.tracesFind pattern 1I match rows with | [] -> Stdlib.printLine $"No traces match '{pattern}'." @@ -666,13 +666,13 @@ let executeFindView (state: Cli.AppState) (pattern: String) : Cli.AppState = let executeTail (state: Cli.AppState) (routeFilter: Stdlib.Option.Option) - (n: Int64) + (n: Int) : Cli.AppState = let routeIsEmpty = match routeFilter with | Some r -> Stdlib.String.trim r == "" | None -> false - if n < 1L then + if n < 1I then Stdlib.printLine (Colors.error "tail N must be ≥ 1") state else if routeIsEmpty then @@ -683,7 +683,7 @@ let executeTail // unfiltered case picks straight from the first N rows. let fetch = match routeFilter with - | Some _ -> 500L + | Some _ -> 500I | None -> n let allRows = Builtin.tracesList fetch let candidates = @@ -697,7 +697,7 @@ let executeTail | None -> allRows // Drop the first (n-1) — the Nth-most-recent is what's left at head. - let after = Stdlib.List.drop candidates (Stdlib.Int.fromInt64 (n - 1L)) + let after = Stdlib.List.drop candidates (n - 1I) match after with | [] -> let suffix = @@ -707,9 +707,9 @@ let executeTail // N=1 reads better as "No traces yet" — for N>1, use proper // English ordinals (2nd/3rd/22nd/etc) via ordinalSuffix. let msg = - if n == 1L then $"No traces yet{suffix}." + if n == 1I then $"No traces yet{suffix}." else - let nStr = Stdlib.Int64.toString n + let nStr = Stdlib.Int.toString n $"No {nStr}{ordinalSuffix n}-most-recent trace{suffix}." Stdlib.printLine msg state @@ -720,8 +720,8 @@ let executeTail /// trace count, total ms (sum of every fn-call duration in each trace), /// max single-call ms. Pairs with `traces hotspots` (per-fn aggregate) /// for "which routes are heavy?" vs "which fns are heavy?". -let executeStats (state: Cli.AppState) (limit: Int64) : Cli.AppState = - if limit < 1L then +let executeStats (state: Cli.AppState) (limit: Int) : Cli.AppState = + if limit < 1I then Stdlib.printLine (Colors.error "Limit must be ≥ 1") state else @@ -733,15 +733,15 @@ let executeStats (state: Cli.AppState) (limit: Int64) : Cli.AppState = state | _ -> Stdlib.printLine - $"Per-handler stats (last {Stdlib.Int64.toString limit} traces):" + $"Per-handler stats (last {Stdlib.Int.toString limit} traces):" Stdlib.printLine "" Stdlib.printLine " total ms │ max ms │ count │ handler" Stdlib.printLine " ─────────┼──────────┼───────┼─────────────────────────" Stdlib.List.iter rows (fun row -> let (handler, count, total, max) = row - let totalStr = padNum total 9L - let maxStr = padNum max 8L - let countStr = padNum count 5L + let totalStr = padNum total 9I + let maxStr = padNum max 8I + let countStr = padNum count 5I Stdlib.printLine $" {totalStr} │ {maxStr} │ {countStr} │ {handler}") Stdlib.printLine "" // The route-drill hint only makes sense if there are HTTP @@ -761,8 +761,8 @@ let executeStats (state: Cli.AppState) (limit: Int64) : Cli.AppState = /// `traces stats --json [limit]` — same data as a JSON array of /// `{handler, count, totalMs, maxMs}` objects, no headers/footers, /// for piping. Empty store prints `[]`. -let executeStatsJson (state: Cli.AppState) (limit: Int64) : Cli.AppState = - if limit < 1L then +let executeStatsJson (state: Cli.AppState) (limit: Int) : Cli.AppState = + if limit < 1I then Stdlib.printLine (Colors.error "Limit must be ≥ 1") state else @@ -772,9 +772,9 @@ let executeStatsJson (state: Cli.AppState) (limit: Int64) : Cli.AppState = |> Stdlib.List.map (fun row -> let (handler, count, total, max) = row $"{{\"handler\":\"{jsonEscape handler}\"" - ++ $",\"count\":{Stdlib.Int64.toString count}" - ++ $",\"totalMs\":{Stdlib.Int64.toString total}" - ++ $",\"maxMs\":{Stdlib.Int64.toString max}}}") + ++ $",\"count\":{Stdlib.Int.toString count}" + ++ $",\"totalMs\":{Stdlib.Int.toString total}" + ++ $",\"maxMs\":{Stdlib.Int.toString max}}}") |> Stdlib.String.join "," Stdlib.printLine $"[{body}]" state @@ -790,7 +790,7 @@ let rec followLoop (lastSeen: String) (jsonMode: Bool) : Unit = - let rows = Builtin.tracesList 50L + let rows = Builtin.tracesList 50I let candidates = rows |> Stdlib.List.takeWhile (fun row -> row.traceId != lastSeen) @@ -850,7 +850,7 @@ let executeFollow Stdlib.printLine "" // Anchor: ignore traces that already existed when we started. - let initialRows = Builtin.tracesList 1L + let initialRows = Builtin.tracesList 1I let initialSeen = match initialRows with | [] -> "" @@ -866,20 +866,20 @@ let executeFollow let executeListByRoute (state: Cli.AppState) (route: String) - (limit: Int64) + (limit: Int) (jsonMode: Bool) : Cli.AppState = if Stdlib.String.trim route == "" then Stdlib.printLine (Colors.error "--route pattern must not be empty") state - else if limit < 1L then + else if limit < 1I then Stdlib.printLine (Colors.error "Limit must be ≥ 1") state else // Over-fetch then filter; tracesList returns the most-recent N rows // unfiltered, so to find N matching we may need to pull more. Cap at // 500 to bound the fetch. - let overFetch = if limit < 50L then 500L else limit * 10L + let overFetch = if limit < 50I then 500I else limit * 10I let allRows = Builtin.tracesList overFetch let routeUpper = Stdlib.String.toUppercase route let matching = @@ -887,7 +887,7 @@ let executeListByRoute |> Stdlib.List.filter (fun row -> Stdlib.String.contains (Stdlib.String.toUppercase row.handler) routeUpper) - |> Stdlib.List.take (Stdlib.Int.fromInt64 limit) + |> Stdlib.List.take limit if jsonMode then Stdlib.printLine (Stdlib.Json.serialize> matching) @@ -898,7 +898,7 @@ let executeListByRoute Stdlib.printLine $"No traces found for route filter '{route}'." state | _ -> - Stdlib.printLine $"Traces matching route '{route}' (last {Stdlib.Int64.toString limit}):" + Stdlib.printLine $"Traces matching route '{route}' (last {Stdlib.Int.toString limit}):" Stdlib.printLine "" printTraceRows matching Stdlib.printLine "" @@ -1006,8 +1006,8 @@ let renderCall let indent = Stdlib.String.repeat " " (depth + 1I) let resultRepr = compactDval branchId call.result let durationSuffix = - if call.durationMs > 0L then - $" ({Stdlib.Int64.toString call.durationMs}ms)" + if call.durationMs > 0I then + $" ({Stdlib.Int.toString call.durationMs}ms)" else "" let header = @@ -1127,12 +1127,12 @@ let executeReplay (state: Cli.AppState) (traceID: String) : Cli.AppState = let executeClear (state: Cli.AppState) : Cli.AppState = let count = Builtin.tracesClear () match count with - | 0L -> + | 0I -> Stdlib.printLine "No traces to clear." state | _ -> - let traceWord = if count == 1L then "trace" else "traces" - Stdlib.printLine $"Cleared {Stdlib.Int64.toString count} {traceWord}." + let traceWord = if count == 1I then "trace" else "traces" + Stdlib.printLine $"Cleared {Stdlib.Int.toString count} {traceWord}." state @@ -1164,13 +1164,13 @@ let executeClearBefore let cutoff = Stdlib.DateTime.toString cutoffDt let count = Builtin.tracesClearBefore cutoff match count with - | 0L -> + | 0I -> Stdlib.printLine $"No traces older than {durationStr}." state | _ -> - let traceWord = if count == 1L then "trace" else "traces" + let traceWord = if count == 1I then "trace" else "traces" Stdlib.printLine - $"Cleared {Stdlib.Int64.toString count} {traceWord} older than {durationStr}." + $"Cleared {Stdlib.Int.toString count} {traceWord} older than {durationStr}." state @@ -1179,7 +1179,7 @@ let executeClearBefore let executeDelete (state: Cli.AppState) (traceID: String) : Cli.AppState = let deleted = Builtin.tracesDelete traceID match deleted with - | 0L -> + | 0I -> Stdlib.printLine (Colors.error $"Trace not found: {traceID}") state | _ -> @@ -1190,25 +1190,25 @@ let executeDelete (state: Cli.AppState) (traceID: String) : Cli.AppState = /// `traces delete --keep ` — keep the N most-recent traces, drop the /// rest (with their fn_calls). For bounded retention as the trace store /// grows; pair with `traces delete --all` for a full wipe. -let executePruneKeep (state: Cli.AppState) (keepN: Int64) : Cli.AppState = - if keepN < 0L then +let executePruneKeep (state: Cli.AppState) (keepN: Int) : Cli.AppState = + if keepN < 0I then Stdlib.printLine (Colors.error "--keep N must be ≥ 0") state else let deleted = Builtin.tracesPruneKeep keepN match deleted with - | 0L -> + | 0I -> Stdlib.printLine - $"Already at or below {Stdlib.Int64.toString keepN} traces; nothing to prune." + $"Already at or below {Stdlib.Int.toString keepN} traces; nothing to prune." state | _ -> - let traceWord = if deleted == 1L then "trace" else "traces" + let traceWord = if deleted == 1I then "trace" else "traces" let keptPhrase = - if keepN == 0L then "none kept" - else if keepN == 1L then "kept the most-recent" - else $"kept the {Stdlib.Int64.toString keepN} most-recent" + if keepN == 0I then "none kept" + else if keepN == 1I then "kept the most-recent" + else $"kept the {Stdlib.Int.toString keepN} most-recent" Stdlib.printLine - $"Pruned {Stdlib.Int64.toString deleted} {traceWord}; {keptPhrase}." + $"Pruned {Stdlib.Int.toString deleted} {traceWord}; {keptPhrase}." state diff --git a/packages/darklang/tracing/format.dark b/packages/darklang/tracing/format.dark index bd034071e3..b354e3067d 100644 --- a/packages/darklang/tracing/format.dark +++ b/packages/darklang/tracing/format.dark @@ -8,9 +8,9 @@ module Darklang.Tracing.Format /// Stdlib.padStart returns Result; this helper unwraps with empty-Error /// fallback (impossible in practice — padStart only fails on negative /// width). -let padNum (n: Int64) (width: Int64) : String = - let s = Stdlib.Int64.toString n - match Stdlib.String.padStart s " " (Stdlib.Int.fromInt64 width) with +let padNum (n: Int) (width: Int) : String = + let s = Stdlib.Int.toString n + match Stdlib.String.padStart s " " width with | Ok r -> r | Error _ -> s diff --git a/packages/darklang/tracing/types.dark b/packages/darklang/tracing/types.dark index 6996655399..d792eba941 100644 --- a/packages/darklang/tracing/types.dark +++ b/packages/darklang/tracing/types.dark @@ -33,7 +33,7 @@ type FnCall = args: List result: LanguageTools.RuntimeTypes.Dval /// Frame-entry-to-exit duration in ms. Builtins always 0 (no entry hook). - durationMs: Int64 } + durationMs: Int } /// Full trace payload — summary fields plus the input/fn-call lists. From c0f84c943e114fac894ec41078d9e6d5adcaee03 Mon Sep 17 00:00:00 2001 From: OceanOak Date: Thu, 18 Jun 2026 12:14:21 +0000 Subject: [PATCH 34/61] Migrate LSP TextDocumentItem.version and DiagnosticCode to Int --- packages/darklang/cli/packages/fn.dark | 26 +++++++++---------- .../languageServerProtocol/common.dark | 8 +++--- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/packages/darklang/cli/packages/fn.dark b/packages/darklang/cli/packages/fn.dark index 9703dd80a7..ab411721e4 100644 --- a/packages/darklang/cli/packages/fn.dark +++ b/packages/darklang/cli/packages/fn.dark @@ -7,7 +7,7 @@ let execute (state: Cli.AppState) (args: List) : Cli.AppState = // fn SomeModule.myFn (param: Type): ReturnType = body | location :: definitionParts -> - // Strip leading "=" if present (since users naturally type "fn foo (x: Int64): Int64 = ...") + // Strip leading "=" if present (since users naturally type "fn foo (x: Int): Int = ...") let cleanedParts = match definitionParts with | "=" :: rest -> rest @@ -31,14 +31,14 @@ let execute (state: Cli.AppState) (args: List) : Cli.AppState = " fn - (read body from stdin)" "" "Examples:" - " fn double (x: Int64): Int64 = Stdlib.Int64.multiply x 2L" + " fn double (x: Int): Int = Stdlib.Int.multiply x 2" " fn greet (name: String): String = \"Hello, \" ++ name" "" " # Multi-line body via stdin (run from shell, not the REPL):" " ./scripts/run-cli fn fib - <<'EOF'" - " (n: Int64): Int64 =" - " if n < 2L then n" - " else fib (n - 1L) + fib (n - 2L)" + " (n: Int): Int =" + " if n < 2 then n" + " else fib (n - 1) + fib (n - 2)" " EOF" "" ] |> Stdlib.printLines @@ -145,7 +145,7 @@ let createFnInline (Colors.error "Failed to parse function definition") "" "Make sure your syntax is correct. Examples:" - " fn double (x: Int64): Int64 = Stdlib.Int64.multiply x 2L" + " fn double (x: Int): Int = Stdlib.Int.multiply x 2" " fn greet (name: String): String = \"Hello, \" ++ name" "" ] |> Stdlib.printLines @@ -166,26 +166,26 @@ let help (state: Cli.AppState) : Cli.AppState = "" "Examples:" " # Simple function:" - " fn double (x: Int64): Int64 = Stdlib.Int64.multiply x 2L" + " fn double (x: Int): Int = Stdlib.Int.multiply x 2" "" " # String function:" " fn greet (name: String): String = \"Hello, \" ++ name" "" " # Multiple parameters:" - " fn add (a: Int64) (b: Int64): Int64 = Stdlib.Int64.add a b" + " fn add (a: Int) (b: Int): Int = Stdlib.Int.add a b" "" " # Boolean function:" - " fn isPositive (x: Int64): Bool = x > 0L" + " fn isPositive (x: Int): Bool = x > 0" "" " # Multi-line body via stdin (run from shell, not the REPL — '-' reads stdin):" " ./scripts/run-cli fn fib - <<'EOF'" - " (n: Int64): Int64 =" - " if n < 2L then n" - " else fib (n - 1L) + fib (n - 2L)" + " (n: Int): Int =" + " if n < 2 then n" + " else fib (n - 1) + fib (n - 2)" " EOF" "" "Location can be relative or absolute:" - " fn helper (x: Int64): Int64 = ... # Relative to current location" + " fn helper (x: Int): Int = ... # Relative to current location" " fn /Darklang.Foo.bar (x: String): String = ... # Absolute path" "" ] |> Stdlib.printLines diff --git a/packages/darklang/languageServerProtocol/common.dark b/packages/darklang/languageServerProtocol/common.dark index 0d2524ef4c..3447acb57e 100644 --- a/packages/darklang/languageServerProtocol/common.dark +++ b/packages/darklang/languageServerProtocol/common.dark @@ -187,7 +187,7 @@ module TextDocumentItem = /// The version number of this document /// (it will increase after each change, including undo/redo). - version: Int64 + version: Int /// The content of the opened text document. text: String @@ -196,7 +196,7 @@ module TextDocumentItem = let toJson (i: TextDocumentItem) : Json = [ ("uri", Json.String i.uri) ("languageId", Json.String i.languageId) - ("version", Json.Number(Stdlib.Int64.toFloat i.version)) + ("version", Json.Number(Stdlib.Int.toFloat i.version)) ("text", Json.String i.text) ] |> Json.Object @@ -482,12 +482,12 @@ module CodeDescription = module DiagnosticCode = type DiagnosticCode = - | Number of Int64 + | Number of Int | String of String let toJson (c: DiagnosticCode) : Json = match c with - | Number n -> (Stdlib.Int64.toFloat n) |> Json.Number + | Number n -> (Stdlib.Int.toFloat n) |> Json.Number | String s -> Json.String s module Diagnostic = From d68a82c2a56c2162879f7591c6a5316b58b4bfdf Mon Sep 17 00:00:00 2001 From: OceanOak Date: Thu, 18 Jun 2026 12:20:32 +0000 Subject: [PATCH 35/61] Migrate CLI TestSummary counts from Int64 to Int --- packages/darklang/cli/tests/tests.dark | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/darklang/cli/tests/tests.dark b/packages/darklang/cli/tests/tests.dark index 84862c053d..3ea7b833c9 100644 --- a/packages/darklang/cli/tests/tests.dark +++ b/packages/darklang/cli/tests/tests.dark @@ -180,9 +180,9 @@ let allTests (): List = ] type TestSummary = - { totalTests: Int64 - passedTests: Int64 - failedTests: Int64 + { totalTests: Int + passedTests: Int + failedTests: Int failedTestNames: List } // Sequential test execution - proven to be ~30-50% faster than parallel for CLI tests @@ -196,9 +196,9 @@ let runAllTests (): Int64 = let initialSummary = TestSummary - { totalTests = 0L - passedTests = 0L - failedTests = 0L + { totalTests = 0I + passedTests = 0I + failedTests = 0I failedTestNames = [] } let finalSummary = @@ -208,27 +208,27 @@ let runAllTests (): Int64 = Stdlib.printLine $"Running: {name} ..." let newSummary = - { summary with totalTests = summary.totalTests + 1L } + { summary with totalTests = summary.totalTests + 1I } match testFn () with | Pass -> Stdlib.printLine $"✓ PASS - {name}" - { newSummary with passedTests = newSummary.passedTests + 1L } + { newSummary with passedTests = newSummary.passedTests + 1I } | Fail message -> Stdlib.printLine $"✗ FAIL - {name}" Stdlib.printLine $" Reason: {message}" { newSummary with - failedTests = newSummary.failedTests + 1L + failedTests = newSummary.failedTests + 1I failedTestNames = Stdlib.List.push newSummary.failedTestNames name }) Stdlib.printLine "" Stdlib.printLine "📊 Test Results Summary" Stdlib.printLine "======================" - Stdlib.printLine $"Total tests: {Stdlib.Int64.toString finalSummary.totalTests}" - Stdlib.printLine $"Passed: {Stdlib.Int64.toString finalSummary.passedTests}" - Stdlib.printLine $"Failed: {Stdlib.Int64.toString finalSummary.failedTests}" + Stdlib.printLine $"Total tests: {Stdlib.Int.toString finalSummary.totalTests}" + Stdlib.printLine $"Passed: {Stdlib.Int.toString finalSummary.passedTests}" + Stdlib.printLine $"Failed: {Stdlib.Int.toString finalSummary.failedTests}" - if finalSummary.failedTests == 0L then + if finalSummary.failedTests == 0I then Stdlib.printLine "🎉 All tests passed!" 0L else From de6313af624aba9edf07a7223786401a03775078 Mon Sep 17 00:00:00 2001 From: OceanOak Date: Thu, 18 Jun 2026 13:22:02 +0000 Subject: [PATCH 36/61] Migrate parser Point positions from Int64 to Int --- .../Builtins/Builtins.Language/Libs/Parser.fs | 3 +- .../Builtins/Builtins.Matter/Libs/Traces.fs | 13 +- backend/src/LibExecution/DvalDecoder.fs | 5 + backend/testfiles/execution/stdlib/json.dark | 2 +- .../stdlib/language-tools/parser.dark | 34 +- .../language-tools/semanticTokenization.dark | 1382 ++++++++--------- backend/tests/Tests/HttpClient.Tests.fs | 4 +- packages/darklang/cli/packages/errors.dark | 8 +- packages/darklang/cli/packages/fn.dark | 2 +- packages/darklang/cli/packages/type.dark | 12 +- packages/darklang/cli/packages/value.dark | 2 +- .../cli/utils/syntaxHighlighting.dark | 10 +- .../lsp-server/cursorPosition.dark | 14 +- .../lsp-server/handleIncomingMessage.dark | 8 +- .../languageTools/lsp-server/hover.dark | 4 +- .../lsp-server/semanticTokens.dark | 18 +- .../languageTools/parser/cliScript.dark | 8 +- .../darklang/languageTools/parser/core.dark | 2 +- packages/internal/tests.dark | 4 +- 19 files changed, 766 insertions(+), 769 deletions(-) diff --git a/backend/src/Builtins/Builtins.Language/Libs/Parser.fs b/backend/src/Builtins/Builtins.Language/Libs/Parser.fs index 09a541179b..14664a040a 100644 --- a/backend/src/Builtins/Builtins.Language/Libs/Parser.fs +++ b/backend/src/Builtins/Builtins.Language/Libs/Parser.fs @@ -47,7 +47,8 @@ let fns () : List = let fields = let mapPoint (point : Point) = let fields = - [ "row", DInt64 point.row; "column", DInt64 point.column ] + [ "row", Dval.int (bigint point.row) + "column", Dval.int (bigint point.column) ] DRecord(pointTypeName (), pointTypeName (), [], Map fields) let startPos = cursor.Current.StartPosition diff --git a/backend/src/Builtins/Builtins.Matter/Libs/Traces.fs b/backend/src/Builtins/Builtins.Matter/Libs/Traces.fs index be6f601ede..351b112356 100644 --- a/backend/src/Builtins/Builtins.Matter/Libs/Traces.fs +++ b/backend/src/Builtins/Builtins.Matter/Libs/Traces.fs @@ -277,10 +277,7 @@ let fns () : List = { name = fn "tracesStatsByHandler" 0 typeParams = [] parameters = - [ Param.make - "traceLimit" - TInt - "Aggregate over the last N traces (e.g. 100)" ] + [ Param.make "traceLimit" TInt "Aggregate over the last N traces (e.g. 100)" ] returnType = TList(TTuple(TString, TInt, [ TInt; TInt ])) description = "Per-handler aggregate over the last N traces: (handler, traceCount, totalMs, maxMs). Total ms sums every fn-call duration in each trace; per-trace latency would need a separate column on `traces`." @@ -332,10 +329,7 @@ let fns () : List = { name = fn "tracesHotspots" 0 typeParams = [] parameters = - [ Param.make - "traceLimit" - TInt - "Aggregate over the last N traces (e.g. 100)" ] + [ Param.make "traceLimit" TInt "Aggregate over the last N traces (e.g. 100)" ] returnType = TList(TTuple(TString, TInt, [ TInt; TInt ])) description = "Aggregate fn-call timing across the last N traces. Returns (fnName, callCount, totalMs, maxMs) tuples sorted by totalMs desc. Lambdas are excluded (no fn_hash to bucket by); builtins included but always have 0ms duration." @@ -705,8 +699,7 @@ let fns () : List = { name = fn "tracesPruneKeep" 0 typeParams = [] - parameters = - [ Param.make "keepN" TInt "Number of most-recent traces to keep" ] + parameters = [ Param.make "keepN" TInt "Number of most-recent traces to keep" ] returnType = TInt description = "Delete all but the N most-recent traces (and their fn_calls). Returns the count deleted. Useful for bounded retention." diff --git a/backend/src/LibExecution/DvalDecoder.fs b/backend/src/LibExecution/DvalDecoder.fs index ff660f6f7e..b45311edb6 100644 --- a/backend/src/LibExecution/DvalDecoder.fs +++ b/backend/src/LibExecution/DvalDecoder.fs @@ -50,6 +50,11 @@ let int64 (dv : Dval) : int64 = | DInt64 i -> i | _ -> f "int64" dv +let darkInt (dv : Dval) : bigint = + match dv with + | DInt i -> DarkInt.toBigInt i + | _ -> f "int" dv + let uInt64 (dv : Dval) : uint64 = match dv with | DUInt64 i -> i diff --git a/backend/testfiles/execution/stdlib/json.dark b/backend/testfiles/execution/stdlib/json.dark index 3ea8b5a487..95abdfe1ff 100644 --- a/backend/testfiles/execution/stdlib/json.dark +++ b/backend/testfiles/execution/stdlib/json.dark @@ -1498,4 +1498,4 @@ module Package = // ## Nested types (lists, tuples, records, etc.) // Stdlib.Json.serialize> * Dict>>>>> = Ok "test" -// Stdlib.Json.serialize> * Dict>>>>> = Ok "test" +// Stdlib.Json.serialize> * Dict>>>>> = Ok "test" \ No newline at end of file diff --git a/backend/testfiles/execution/stdlib/language-tools/parser.dark b/backend/testfiles/execution/stdlib/language-tools/parser.dark index aaada5846e..b6517c7b74 100644 --- a/backend/testfiles/execution/stdlib/language-tools/parser.dark +++ b/backend/testfiles/execution/stdlib/language-tools/parser.dark @@ -3,7 +3,7 @@ type Point = Darklang.LanguageTools.Parser.Point type Range = Darklang.LanguageTools.Parser.Range type ParsedNode = Darklang.LanguageTools.Parser.ParsedNode -let range (s: Int64 * Int64) (e: Int64 * Int64) : Range = +let range (s: Int * Int) (e: Int * Int) : Range = let (startRow, startColumn) = s let (endRow, endColumn) = e @@ -33,58 +33,58 @@ module ParseToSimplifiedTree = { typ = "source_file" fieldName = Stdlib.Option.Option.None text = "type ID = Int64" - range = range (0L, 0L) (0L, 15L) + range = range (0I, 0I) (0I, 15I) children = [ ParsedNode { fieldName = Stdlib.Option.Option.None typ = "type_decl" text = "type ID = Int64" - range = range (0L, 0L) (0L, 15L) + range = range (0I, 0I) (0I, 15I) children = [ ParsedNode { fieldName = Stdlib.Option.Option.Some "keyword_type" typ = "keyword" text = "type" - range = range (0L, 0L) (0L, 4L) + range = range (0I, 0I) (0I, 4I) children = [] } ParsedNode { fieldName = Stdlib.Option.Option.Some "name" typ = "type_identifier" text = "ID" - range = range (0L, 5L) (0L, 7L) + range = range (0I, 5I) (0I, 7I) children = [] } ParsedNode { fieldName = Stdlib.Option.Option.Some "symbol_equals" typ = "symbol" text = "=" - range = range (0L, 8L) (0L, 9L) + range = range (0I, 8I) (0I, 9I) children = [] } ParsedNode { fieldName = Stdlib.Option.Option.Some "typ" typ = "type_decl_def" text = "Int64" - range = range (0L, 10L) (0L, 15L) + range = range (0I, 10I) (0I, 15I) children = [ ParsedNode { fieldName = Stdlib.Option.Option.None typ = "type_decl_def_alias" text = "Int64" - range = range (0L, 10L) (0L, 15L) + range = range (0I, 10I) (0I, 15I) children = [ ParsedNode { fieldName = Stdlib.Option.Option.None typ = "type_reference" text = "Int64" - range = range (0L, 10L) (0L, 15L) + range = range (0I, 10I) (0I, 15I) children = [ ParsedNode { fieldName = Stdlib.Option.Option.None typ = "builtin_type" text = "Int64" - range = range (0L, 10L) (0L, 15L) + range = range (0I, 10I) (0I, 15I) children = [] } ] } ] } ] } ] } ] } @@ -93,7 +93,7 @@ module ParseToSimplifiedTree = { typ = "source_file" fieldName = Stdlib.Option.Option.None text = "" - range = range (0L, 0L) (0L, 0L) + range = range (0I, 0I) (0I, 0I) children = [] } @@ -109,24 +109,24 @@ module ParseNodeToWrittenTypes = |> Builtin.unwrap) = Darklang.LanguageTools.WrittenTypes.ParsedFile.SourceFile( Darklang.LanguageTools.WrittenTypes.SourceFile.SourceFile - { range = range (0L, 0L) (0L, 17L) + { range = range (0I, 0I) (0I, 17I) declarations = [ Darklang.LanguageTools.WrittenTypes.SourceFile.SourceFileDeclaration.Type( Darklang.LanguageTools.WrittenTypes.TypeDeclaration.TypeDeclaration - { range = range (0L, 0L) (0L, 17L) + { range = range (0I, 0I) (0I, 17I) name = Darklang.LanguageTools.WrittenTypes.TypeIdentifier - { range = range (0L, 5L) (0L, 9L); name = "MyID" } + { range = range (0I, 5I) (0I, 9I); name = "MyID" } typeParams = [] definition = Darklang.LanguageTools.WrittenTypes.TypeDeclaration.Definition.Alias( Darklang.LanguageTools.WrittenTypes.TypeReference.TypeReference.Builtin( - Darklang.LanguageTools.WrittenTypes.TypeReference.Builtin.TInt64(range (0L, 12L) (0L, 17L)) + Darklang.LanguageTools.WrittenTypes.TypeReference.Builtin.TInt64(range (0I, 12I) (0I, 17I)) ) ) description = "" - keywordType = range (0L, 0L) (0L, 4L) - symbolEquals = range (0L, 10L) (0L, 11L) } + keywordType = range (0I, 0I) (0I, 4I) + symbolEquals = range (0I, 10I) (0I, 11I) } ) ] unparseableStuff = [] exprsToEval = [] } diff --git a/backend/testfiles/execution/stdlib/language-tools/semanticTokenization.dark b/backend/testfiles/execution/stdlib/language-tools/semanticTokenization.dark index 4b2c7dd6b6..c5e1e1e779 100644 --- a/backend/testfiles/execution/stdlib/language-tools/semanticTokenization.dark +++ b/backend/testfiles/execution/stdlib/language-tools/semanticTokenization.dark @@ -3,7 +3,7 @@ type TokenType = Darklang.LanguageTools.SemanticTokens.TokenType let tokenize (text: String) - : List<(Darklang.LanguageTools.SemanticTokens.TokenType * (Int64 * Int64) * (Int64 * Int64))> + : List<(Darklang.LanguageTools.SemanticTokens.TokenType * (Int * Int) * (Int * Int))> = text |> Darklang.LanguageTools.Parser.parseToSimplifiedTree @@ -18,878 +18,878 @@ let tokenize module TokenizeTypeReference = ("type MyUnit = Unit" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 4L)) - (TokenType.TypeName, (0L, 5L), (0L, 11L)) - (TokenType.Symbol, (0L, 12L), (0L, 13L)) - (TokenType.TypeName, (0L, 14L), (0L, 18L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 4I)) + (TokenType.TypeName, (0I, 5I), (0I, 11I)) + (TokenType.Symbol, (0I, 12I), (0I, 13I)) + (TokenType.TypeName, (0I, 14I), (0I, 18I)) ] ("type MyBool = Bool" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 4L)) - (TokenType.TypeName, (0L, 5L), (0L, 11L)) - (TokenType.Symbol, (0L, 12L), (0L, 13L)) - (TokenType.TypeName, (0L, 14L), (0L, 18L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 4I)) + (TokenType.TypeName, (0I, 5I), (0I, 11I)) + (TokenType.Symbol, (0I, 12I), (0I, 13I)) + (TokenType.TypeName, (0I, 14I), (0I, 18I)) ] ("type MyInt8 = Int8" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 4L)) - (TokenType.TypeName, (0L, 5L), (0L, 11L)) - (TokenType.Symbol, (0L, 12L), (0L, 13L)) - (TokenType.TypeName, (0L, 14L), (0L, 18L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 4I)) + (TokenType.TypeName, (0I, 5I), (0I, 11I)) + (TokenType.Symbol, (0I, 12I), (0I, 13I)) + (TokenType.TypeName, (0I, 14I), (0I, 18I)) ] ("type MyUInt8 = UInt8" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 4L)) - (TokenType.TypeName, (0L, 5L), (0L, 12L)) - (TokenType.Symbol, (0L, 13L), (0L, 14L)) - (TokenType.TypeName, (0L, 15L), (0L, 20L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 4I)) + (TokenType.TypeName, (0I, 5I), (0I, 12I)) + (TokenType.Symbol, (0I, 13I), (0I, 14I)) + (TokenType.TypeName, (0I, 15I), (0I, 20I)) ] ("type MyInt16 = Int16" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 4L)) - (TokenType.TypeName, (0L, 5L), (0L, 12L)) - (TokenType.Symbol, (0L, 13L), (0L, 14L)) - (TokenType.TypeName, (0L, 15L), (0L, 20L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 4I)) + (TokenType.TypeName, (0I, 5I), (0I, 12I)) + (TokenType.Symbol, (0I, 13I), (0I, 14I)) + (TokenType.TypeName, (0I, 15I), (0I, 20I)) ] ("type MyUInt16 = UInt16" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 4L)) - (TokenType.TypeName, (0L, 5L), (0L, 13L)) - (TokenType.Symbol, (0L, 14L), (0L, 15L)) - (TokenType.TypeName, (0L, 16L), (0L, 22L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 4I)) + (TokenType.TypeName, (0I, 5I), (0I, 13I)) + (TokenType.Symbol, (0I, 14I), (0I, 15I)) + (TokenType.TypeName, (0I, 16I), (0I, 22I)) ] ("type MyInt32 = Int32" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 4L)) - (TokenType.TypeName, (0L, 5L), (0L, 12L)) - (TokenType.Symbol, (0L, 13L), (0L, 14L)) - (TokenType.TypeName, (0L, 15L), (0L, 20L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 4I)) + (TokenType.TypeName, (0I, 5I), (0I, 12I)) + (TokenType.Symbol, (0I, 13I), (0I, 14I)) + (TokenType.TypeName, (0I, 15I), (0I, 20I)) ] ("type MyUInt32 = UInt32" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 4L)) - (TokenType.TypeName, (0L, 5L), (0L, 13L)) - (TokenType.Symbol, (0L, 14L), (0L, 15L)) - (TokenType.TypeName, (0L, 16L), (0L, 22L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 4I)) + (TokenType.TypeName, (0I, 5I), (0I, 13I)) + (TokenType.Symbol, (0I, 14I), (0I, 15I)) + (TokenType.TypeName, (0I, 16I), (0I, 22I)) ] ("type MyInt64 = Int64" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 4L)) - (TokenType.TypeName, (0L, 5L), (0L, 12L)) - (TokenType.Symbol, (0L, 13L), (0L, 14L)) - (TokenType.TypeName, (0L, 15L), (0L, 20L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 4I)) + (TokenType.TypeName, (0I, 5I), (0I, 12I)) + (TokenType.Symbol, (0I, 13I), (0I, 14I)) + (TokenType.TypeName, (0I, 15I), (0I, 20I)) ] ("type MyUInt64 = UInt64" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 4L)) - (TokenType.TypeName, (0L, 5L), (0L, 13L)) - (TokenType.Symbol, (0L, 14L), (0L, 15L)) - (TokenType.TypeName, (0L, 16L), (0L, 22L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 4I)) + (TokenType.TypeName, (0I, 5I), (0I, 13I)) + (TokenType.Symbol, (0I, 14I), (0I, 15I)) + (TokenType.TypeName, (0I, 16I), (0I, 22I)) ] ("type MyInt128 = Int128" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 4L)) - (TokenType.TypeName, (0L, 5L), (0L, 13L)) - (TokenType.Symbol, (0L, 14L), (0L, 15L)) - (TokenType.TypeName, (0L, 16L), (0L, 22L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 4I)) + (TokenType.TypeName, (0I, 5I), (0I, 13I)) + (TokenType.Symbol, (0I, 14I), (0I, 15I)) + (TokenType.TypeName, (0I, 16I), (0I, 22I)) ] ("type MyUInt128 = UInt128" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 4L)) - (TokenType.TypeName, (0L, 5L), (0L, 14L)) - (TokenType.Symbol, (0L, 15L), (0L, 16L)) - (TokenType.TypeName, (0L, 17L), (0L, 24L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 4I)) + (TokenType.TypeName, (0I, 5I), (0I, 14I)) + (TokenType.Symbol, (0I, 15I), (0I, 16I)) + (TokenType.TypeName, (0I, 17I), (0I, 24I)) ] ("type MyFloat = Float" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 4L)) - (TokenType.TypeName, (0L, 5L), (0L, 12L)) - (TokenType.Symbol, (0L, 13L), (0L, 14L)) - (TokenType.TypeName, (0L, 15L), (0L, 20L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 4I)) + (TokenType.TypeName, (0I, 5I), (0I, 12I)) + (TokenType.Symbol, (0I, 13I), (0I, 14I)) + (TokenType.TypeName, (0I, 15I), (0I, 20I)) ] ("type MyChar = Char" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 4L)) - (TokenType.TypeName, (0L, 5L), (0L, 11L)) - (TokenType.Symbol, (0L, 12L), (0L, 13L)) - (TokenType.TypeName, (0L, 14L), (0L, 18L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 4I)) + (TokenType.TypeName, (0I, 5I), (0I, 11I)) + (TokenType.Symbol, (0I, 12I), (0I, 13I)) + (TokenType.TypeName, (0I, 14I), (0I, 18I)) ] ("type MyString = String" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 4L)) - (TokenType.TypeName, (0L, 5L), (0L, 13L)) - (TokenType.Symbol, (0L, 14L), (0L, 15L)) - (TokenType.TypeName, (0L, 16L), (0L, 22L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 4I)) + (TokenType.TypeName, (0I, 5I), (0I, 13I)) + (TokenType.Symbol, (0I, 14I), (0I, 15I)) + (TokenType.TypeName, (0I, 16I), (0I, 22I)) ] ("type MyUUID = UUID" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 4L)) - (TokenType.TypeName, (0L, 5L), (0L, 11L)) - (TokenType.Symbol, (0L, 12L), (0L, 13L)) - (TokenType.TypeName, (0L, 14L), (0L, 18L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 4I)) + (TokenType.TypeName, (0I, 5I), (0I, 11I)) + (TokenType.Symbol, (0I, 12I), (0I, 13I)) + (TokenType.TypeName, (0I, 14I), (0I, 18I)) ] ("type MyDateTime = DateTime" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 4L)) - (TokenType.TypeName, (0L, 5L), (0L, 15L)) - (TokenType.Symbol, (0L, 16L), (0L, 17L)) - (TokenType.TypeName, (0L, 18L), (0L, 26L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 4I)) + (TokenType.TypeName, (0I, 5I), (0I, 15I)) + (TokenType.Symbol, (0I, 16I), (0I, 17I)) + (TokenType.TypeName, (0I, 18I), (0I, 26I)) ] ("type MyList = List" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 4L)) - (TokenType.TypeName, (0L, 5L), (0L, 11L)) - (TokenType.Symbol, (0L, 12L), (0L, 13L)) - (TokenType.Keyword, (0L, 14L), (0L, 18L)) - (TokenType.Symbol, (0L, 18L), (0L, 19L)) - (TokenType.TypeName, (0L, 19L), (0L, 25L)) - (TokenType.Symbol, (0L, 25L), (0L, 26L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 4I)) + (TokenType.TypeName, (0I, 5I), (0I, 11I)) + (TokenType.Symbol, (0I, 12I), (0I, 13I)) + (TokenType.Keyword, (0I, 14I), (0I, 18I)) + (TokenType.Symbol, (0I, 18I), (0I, 19I)) + (TokenType.TypeName, (0I, 19I), (0I, 25I)) + (TokenType.Symbol, (0I, 25I), (0I, 26I)) ] ("type MyDict = Dict" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 4L)) - (TokenType.TypeName, (0L, 5L), (0L, 11L)) - (TokenType.Symbol, (0L, 12L), (0L, 13L)) - (TokenType.Keyword, (0L, 14L), (0L, 18L)) - (TokenType.Symbol, (0L, 18L), (0L, 19L)) - (TokenType.TypeName, (0L, 19L), (0L, 24L)) - (TokenType.Symbol, (0L, 24L), (0L, 25L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 4I)) + (TokenType.TypeName, (0I, 5I), (0I, 11I)) + (TokenType.Symbol, (0I, 12I), (0I, 13I)) + (TokenType.Keyword, (0I, 14I), (0I, 18I)) + (TokenType.Symbol, (0I, 18I), (0I, 19I)) + (TokenType.TypeName, (0I, 19I), (0I, 24I)) + (TokenType.Symbol, (0I, 24I), (0I, 25I)) ] ("type MyTuple2 = (String * Int64)" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 4L)) - (TokenType.TypeName, (0L, 5L), (0L, 13L)) - (TokenType.Symbol, (0L, 14L), (0L, 15L)) - (TokenType.Symbol, (0L, 16L), (0L, 17L)) - (TokenType.TypeName, (0L, 17L), (0L, 23L)) - (TokenType.Symbol, (0L, 24L), (0L, 25L)) - (TokenType.TypeName, (0L, 26L), (0L, 31L)) - (TokenType.Symbol, (0L, 31L), (0L, 32L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 4I)) + (TokenType.TypeName, (0I, 5I), (0I, 13I)) + (TokenType.Symbol, (0I, 14I), (0I, 15I)) + (TokenType.Symbol, (0I, 16I), (0I, 17I)) + (TokenType.TypeName, (0I, 17I), (0I, 23I)) + (TokenType.Symbol, (0I, 24I), (0I, 25I)) + (TokenType.TypeName, (0I, 26I), (0I, 31I)) + (TokenType.Symbol, (0I, 31I), (0I, 32I)) ] ("type MyTuple3 = (String * Int64 * Bool)" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 4L)) - (TokenType.TypeName, (0L, 5L), (0L, 13L)) - (TokenType.Symbol, (0L, 14L), (0L, 15L)) - (TokenType.Symbol, (0L, 16L), (0L, 17L)) - (TokenType.TypeName, (0L, 17L), (0L, 23L)) - (TokenType.Symbol, (0L, 24L), (0L, 25L)) - (TokenType.TypeName, (0L, 26L), (0L, 31L)) - (TokenType.Symbol, (0L, 32L), (0L, 33L)) - (TokenType.TypeName, (0L, 34L), (0L, 38L)) - (TokenType.Symbol, (0L, 38L), (0L, 39L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 4I)) + (TokenType.TypeName, (0I, 5I), (0I, 13I)) + (TokenType.Symbol, (0I, 14I), (0I, 15I)) + (TokenType.Symbol, (0I, 16I), (0I, 17I)) + (TokenType.TypeName, (0I, 17I), (0I, 23I)) + (TokenType.Symbol, (0I, 24I), (0I, 25I)) + (TokenType.TypeName, (0I, 26I), (0I, 31I)) + (TokenType.Symbol, (0I, 32I), (0I, 33I)) + (TokenType.TypeName, (0I, 34I), (0I, 38I)) + (TokenType.Symbol, (0I, 38I), (0I, 39I)) ] ("type MyFn = 'a -> String" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 4L)) - (TokenType.TypeName, (0L, 5L), (0L, 9L)) - (TokenType.Symbol, (0L, 10L), (0L, 11L)) - (TokenType.Symbol, (0L, 12L), (0L, 13L)) - (TokenType.TypeName, (0L, 13L), (0L, 14L)) - (TokenType.Symbol, (0L, 15L), (0L, 17L)) - (TokenType.TypeName, (0L, 18L), (0L, 24L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 4I)) + (TokenType.TypeName, (0I, 5I), (0I, 9I)) + (TokenType.Symbol, (0I, 10I), (0I, 11I)) + (TokenType.Symbol, (0I, 12I), (0I, 13I)) + (TokenType.TypeName, (0I, 13I), (0I, 14I)) + (TokenType.Symbol, (0I, 15I), (0I, 17I)) + (TokenType.TypeName, (0I, 18I), (0I, 24I)) ] ("type MyDB = DB<'a>" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 4L)) - (TokenType.TypeName, (0L, 5L), (0L, 9L)) - (TokenType.Symbol, (0L, 10L), (0L, 11L)) - (TokenType.Keyword, (0L, 12L), (0L, 14L)) - (TokenType.Symbol, (0L, 14L), (0L, 15L)) - (TokenType.Symbol, (0L, 15L), (0L, 16L)) - (TokenType.TypeName, (0L, 16L), (0L, 17L)) - (TokenType.Symbol, (0L, 17L), (0L, 18L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 4I)) + (TokenType.TypeName, (0I, 5I), (0I, 9I)) + (TokenType.Symbol, (0I, 10I), (0I, 11I)) + (TokenType.Keyword, (0I, 12I), (0I, 14I)) + (TokenType.Symbol, (0I, 14I), (0I, 15I)) + (TokenType.Symbol, (0I, 15I), (0I, 16I)) + (TokenType.TypeName, (0I, 16I), (0I, 17I)) + (TokenType.Symbol, (0I, 17I), (0I, 18I)) ] ("type MyVar = 'a" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 4L)) - (TokenType.TypeName, (0L, 5L), (0L, 10L)) - (TokenType.Symbol, (0L, 11L), (0L, 12L)) - (TokenType.Symbol, (0L, 13L), (0L, 14L)) - (TokenType.TypeName, (0L, 14L), (0L, 15L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 4I)) + (TokenType.TypeName, (0I, 5I), (0I, 10I)) + (TokenType.Symbol, (0I, 11I), (0I, 12I)) + (TokenType.Symbol, (0I, 13I), (0I, 14I)) + (TokenType.TypeName, (0I, 14I), (0I, 15I)) ] ("type MyFullyQualifiedTypeAlias = Stdlib.Option.Option" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 4L)) - (TokenType.TypeName, (0L, 5L), (0L, 30L)) - (TokenType.Symbol, (0L, 31L), (0L, 32L)) - (TokenType.ModuleName, (0L, 33L), (0L, 39L)) - (TokenType.ModuleName, (0L, 40L), (0L, 46L)) - (TokenType.TypeName, (0L, 47L), (0L, 53L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 4I)) + (TokenType.TypeName, (0I, 5I), (0I, 30I)) + (TokenType.Symbol, (0I, 31I), (0I, 32I)) + (TokenType.ModuleName, (0I, 33I), (0I, 39I)) + (TokenType.ModuleName, (0I, 40I), (0I, 46I)) + (TokenType.TypeName, (0I, 47I), (0I, 53I)) ] module TokenizeTypeDeclaration = ("type MyAlias = Int64" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 4L)) - (TokenType.TypeName, (0L, 5L), (0L, 12L)) - (TokenType.Symbol, (0L, 13L), (0L, 14L)) - (TokenType.TypeName, (0L, 15L), (0L, 20L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 4I)) + (TokenType.TypeName, (0I, 5I), (0I, 12I)) + (TokenType.Symbol, (0I, 13I), (0I, 14I)) + (TokenType.TypeName, (0I, 15I), (0I, 20I)) ] ("type MyType<'a> = List<'a>" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 4L)) - (TokenType.TypeName, (0L, 5L), (0L, 11L)) - (TokenType.TypeParameter, (0L, 12L), (0L, 14L)) - (TokenType.Symbol, (0L, 16L), (0L, 17L)) - (TokenType.Keyword, (0L, 18L), (0L, 22L)) - (TokenType.Symbol, (0L, 22L), (0L, 23L)) - (TokenType.Symbol, (0L, 23L), (0L, 24L)) - (TokenType.TypeName, (0L, 24L), (0L, 25L)) - (TokenType.Symbol, (0L, 25L), (0L, 26L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 4I)) + (TokenType.TypeName, (0I, 5I), (0I, 11I)) + (TokenType.TypeParameter, (0I, 12I), (0I, 14I)) + (TokenType.Symbol, (0I, 16I), (0I, 17I)) + (TokenType.Keyword, (0I, 18I), (0I, 22I)) + (TokenType.Symbol, (0I, 22I), (0I, 23I)) + (TokenType.Symbol, (0I, 23I), (0I, 24I)) + (TokenType.TypeName, (0I, 24I), (0I, 25I)) + (TokenType.Symbol, (0I, 25I), (0I, 26I)) ] ("type MyRecord = { x: Int64; y: String }" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 4L)) - (TokenType.TypeName, (0L, 5L), (0L, 13L)) - (TokenType.Symbol, (0L, 14L), (0L, 15L)) - (TokenType.Property, (0L, 18L), (0L, 19L)) - (TokenType.Symbol, (0L, 19L), (0L, 20L)) - (TokenType.TypeName, (0L, 21L), (0L, 26L)) - (TokenType.Symbol, (0L, 26L), (0L, 27L)) - (TokenType.Property, (0L, 28L), (0L, 29L)) - (TokenType.Symbol, (0L, 29L), (0L, 30L)) - (TokenType.TypeName, (0L, 31L), (0L, 37L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 4I)) + (TokenType.TypeName, (0I, 5I), (0I, 13I)) + (TokenType.Symbol, (0I, 14I), (0I, 15I)) + (TokenType.Property, (0I, 18I), (0I, 19I)) + (TokenType.Symbol, (0I, 19I), (0I, 20I)) + (TokenType.TypeName, (0I, 21I), (0I, 26I)) + (TokenType.Symbol, (0I, 26I), (0I, 27I)) + (TokenType.Property, (0I, 28I), (0I, 29I)) + (TokenType.Symbol, (0I, 29I), (0I, 30I)) + (TokenType.TypeName, (0I, 31I), (0I, 37I)) ] ("type MyEnum =\n | A of Int64\n | B of y: String" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 4L)) - (TokenType.TypeName, (0L, 5L), (0L, 11L)) - (TokenType.Symbol, (0L, 12L), (0L, 13L)) - (TokenType.Symbol, (1L, 2L), (1L, 3L)) - (TokenType.EnumMember, (1L, 4L), (1L, 5L)) - (TokenType.Keyword, (1L, 6L), (1L, 8L)) - (TokenType.TypeName, (1L, 9L), (1L, 14L)) - (TokenType.Symbol, (2L, 2L), (2L, 3L)) - (TokenType.EnumMember, (2L, 4L), (2L, 5L)) - (TokenType.Keyword, (2L, 6L), (2L, 8L)) - (TokenType.Property, (2L, 9L), (2L, 10L)) - (TokenType.Symbol, (2L, 10L), (2L, 11L)) - (TokenType.TypeName, (2L, 12L), (2L, 18L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 4I)) + (TokenType.TypeName, (0I, 5I), (0I, 11I)) + (TokenType.Symbol, (0I, 12I), (0I, 13I)) + (TokenType.Symbol, (1I, 2I), (1I, 3I)) + (TokenType.EnumMember, (1I, 4I), (1I, 5I)) + (TokenType.Keyword, (1I, 6I), (1I, 8I)) + (TokenType.TypeName, (1I, 9I), (1I, 14I)) + (TokenType.Symbol, (2I, 2I), (2I, 3I)) + (TokenType.EnumMember, (2I, 4I), (2I, 5I)) + (TokenType.Keyword, (2I, 6I), (2I, 8I)) + (TokenType.Property, (2I, 9I), (2I, 10I)) + (TokenType.Symbol, (2I, 10I), (2I, 11I)) + (TokenType.TypeName, (2I, 12I), (2I, 18I)) ] module TokenizeFunctionDeclaration = ("let myFn () : Int64 = 1L" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 3L)) - (TokenType.FunctionName, (0L, 4L), (0L, 8L)) - (TokenType.Symbol, (0L, 9L), (0L, 11L)) - (TokenType.Symbol, (0L, 12L), (0L, 13L)) - (TokenType.TypeName, (0L, 14L), (0L, 19L)) - (TokenType.Symbol, (0L, 20L), (0L, 21L)) - (TokenType.Number, (0L, 22L), (0L, 23L)) - (TokenType.Symbol, (0L, 23L), (0L, 24L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 3I)) + (TokenType.FunctionName, (0I, 4I), (0I, 8I)) + (TokenType.Symbol, (0I, 9I), (0I, 11I)) + (TokenType.Symbol, (0I, 12I), (0I, 13I)) + (TokenType.TypeName, (0I, 14I), (0I, 19I)) + (TokenType.Symbol, (0I, 20I), (0I, 21I)) + (TokenType.Number, (0I, 22I), (0I, 23I)) + (TokenType.Symbol, (0I, 23I), (0I, 24I)) ] ("let myFn (a: Int64) : Int64 = a" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 3L)) - (TokenType.FunctionName, (0L, 4L), (0L, 8L)) - (TokenType.Symbol, (0L, 9L), (0L, 10L)) - (TokenType.ParameterName, (0L, 10L), (0L, 11L)) - (TokenType.Symbol, (0L, 11L), (0L, 12L)) - (TokenType.TypeName, (0L, 13L), (0L, 18L)) - (TokenType.Symbol, (0L, 18L), (0L, 19L)) - (TokenType.Symbol, (0L, 20L), (0L, 21L)) - (TokenType.TypeName, (0L, 22L), (0L, 27L)) - (TokenType.Symbol, (0L, 28L), (0L, 29L)) - (TokenType.VariableName, (0L, 30L), (0L, 31L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 3I)) + (TokenType.FunctionName, (0I, 4I), (0I, 8I)) + (TokenType.Symbol, (0I, 9I), (0I, 10I)) + (TokenType.ParameterName, (0I, 10I), (0I, 11I)) + (TokenType.Symbol, (0I, 11I), (0I, 12I)) + (TokenType.TypeName, (0I, 13I), (0I, 18I)) + (TokenType.Symbol, (0I, 18I), (0I, 19I)) + (TokenType.Symbol, (0I, 20I), (0I, 21I)) + (TokenType.TypeName, (0I, 22I), (0I, 27I)) + (TokenType.Symbol, (0I, 28I), (0I, 29I)) + (TokenType.VariableName, (0I, 30I), (0I, 31I)) ] ("let add (a: Int64) (b: Int64) : Int64 = (a + b)" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 3L)) - (TokenType.FunctionName, (0L, 4L), (0L, 7L)) - (TokenType.Symbol, (0L, 8L), (0L, 9L)) - (TokenType.ParameterName, (0L, 9L), (0L, 10L)) - (TokenType.Symbol, (0L, 10L), (0L, 11L)) - (TokenType.TypeName, (0L, 12L), (0L, 17L)) - (TokenType.Symbol, (0L, 17L), (0L, 18L)) - (TokenType.Symbol, (0L, 19L), (0L, 20L)) - (TokenType.ParameterName, (0L, 20L), (0L, 21L)) - (TokenType.Symbol, (0L, 21L), (0L, 22L)) - (TokenType.TypeName, (0L, 23L), (0L, 28L)) - (TokenType.Symbol, (0L, 28L), (0L, 29L)) - (TokenType.Symbol, (0L, 30L), (0L, 31L)) - (TokenType.TypeName, (0L, 32L), (0L, 37L)) - (TokenType.Symbol, (0L, 38L), (0L, 39L)) - (TokenType.VariableName, (0L, 41L), (0L, 42L)) - (TokenType.Operator, (0L, 43L), (0L, 44L)) - (TokenType.VariableName, (0L, 45L), (0L, 46L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 3I)) + (TokenType.FunctionName, (0I, 4I), (0I, 7I)) + (TokenType.Symbol, (0I, 8I), (0I, 9I)) + (TokenType.ParameterName, (0I, 9I), (0I, 10I)) + (TokenType.Symbol, (0I, 10I), (0I, 11I)) + (TokenType.TypeName, (0I, 12I), (0I, 17I)) + (TokenType.Symbol, (0I, 17I), (0I, 18I)) + (TokenType.Symbol, (0I, 19I), (0I, 20I)) + (TokenType.ParameterName, (0I, 20I), (0I, 21I)) + (TokenType.Symbol, (0I, 21I), (0I, 22I)) + (TokenType.TypeName, (0I, 23I), (0I, 28I)) + (TokenType.Symbol, (0I, 28I), (0I, 29I)) + (TokenType.Symbol, (0I, 30I), (0I, 31I)) + (TokenType.TypeName, (0I, 32I), (0I, 37I)) + (TokenType.Symbol, (0I, 38I), (0I, 39I)) + (TokenType.VariableName, (0I, 41I), (0I, 42I)) + (TokenType.Operator, (0I, 43I), (0I, 44I)) + (TokenType.VariableName, (0I, 45I), (0I, 46I)) ] ("let myFn<'a, 'b> (paramOne: 'a) (paramTwo: 'b): Unit = ()" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 3L)) - (TokenType.FunctionName, (0L, 4L), (0L, 8L)) - (TokenType.TypeParameter, (0L, 9L), (0L, 11L)) - (TokenType.TypeParameter, (0L, 13L), (0L, 15L)) - (TokenType.Symbol, (0L, 17L), (0L, 18L)) - (TokenType.ParameterName, (0L, 18L), (0L, 26L)) - (TokenType.Symbol, (0L, 26L), (0L, 27L)) - (TokenType.Symbol, (0L, 28L), (0L, 29L)) - (TokenType.TypeName, (0L, 29L), (0L, 30L)) - (TokenType.Symbol, (0L, 30L), (0L, 31L)) - (TokenType.Symbol, (0L, 32L), (0L, 33L)) - (TokenType.ParameterName, (0L, 33L), (0L, 41L)) - (TokenType.Symbol, (0L, 41L), (0L, 42L)) - (TokenType.Symbol, (0L, 43L), (0L, 44L)) - (TokenType.TypeName, (0L, 44L), (0L, 45L)) - (TokenType.Symbol, (0L, 45L), (0L, 46L)) - (TokenType.Symbol, (0L, 46L), (0L, 47L)) - (TokenType.TypeName, (0L, 48L), (0L, 52L)) - (TokenType.Symbol, (0L, 53L), (0L, 54L)) - (TokenType.Symbol, (0L, 55L), (0L, 57L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 3I)) + (TokenType.FunctionName, (0I, 4I), (0I, 8I)) + (TokenType.TypeParameter, (0I, 9I), (0I, 11I)) + (TokenType.TypeParameter, (0I, 13I), (0I, 15I)) + (TokenType.Symbol, (0I, 17I), (0I, 18I)) + (TokenType.ParameterName, (0I, 18I), (0I, 26I)) + (TokenType.Symbol, (0I, 26I), (0I, 27I)) + (TokenType.Symbol, (0I, 28I), (0I, 29I)) + (TokenType.TypeName, (0I, 29I), (0I, 30I)) + (TokenType.Symbol, (0I, 30I), (0I, 31I)) + (TokenType.Symbol, (0I, 32I), (0I, 33I)) + (TokenType.ParameterName, (0I, 33I), (0I, 41I)) + (TokenType.Symbol, (0I, 41I), (0I, 42I)) + (TokenType.Symbol, (0I, 43I), (0I, 44I)) + (TokenType.TypeName, (0I, 44I), (0I, 45I)) + (TokenType.Symbol, (0I, 45I), (0I, 46I)) + (TokenType.Symbol, (0I, 46I), (0I, 47I)) + (TokenType.TypeName, (0I, 48I), (0I, 52I)) + (TokenType.Symbol, (0I, 53I), (0I, 54I)) + (TokenType.Symbol, (0I, 55I), (0I, 57I)) ] module TokenizeValueDeclaration = ("val unitValue = ()" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 3L)) - (TokenType.VariableName, (0L, 4L), (0L, 13L)) - (TokenType.Symbol, (0L, 14L), (0L, 15L)) - (TokenType.Symbol, (0L, 16L), (0L, 18L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 3I)) + (TokenType.VariableName, (0I, 4I), (0I, 13I)) + (TokenType.Symbol, (0I, 14I), (0I, 15I)) + (TokenType.Symbol, (0I, 16I), (0I, 18I)) ] ("val myIntValue = 1L" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 3L)) - (TokenType.VariableName, (0L, 4L), (0L, 14L)) - (TokenType.Symbol, (0L, 15L), (0L, 16L)) - (TokenType.Number, (0L, 17L), (0L, 18L)) - (TokenType.Symbol, (0L, 18L), (0L, 19L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 3I)) + (TokenType.VariableName, (0I, 4I), (0I, 14I)) + (TokenType.Symbol, (0I, 15I), (0I, 16I)) + (TokenType.Number, (0I, 17I), (0I, 18I)) + (TokenType.Symbol, (0I, 18I), (0I, 19I)) ] ("val boolValue = true" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 3L)) - (TokenType.VariableName, (0L, 4L), (0L, 13L)) - (TokenType.Symbol, (0L, 14L), (0L, 15L)) - (TokenType.Keyword, (0L, 16L), (0L, 20L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 3I)) + (TokenType.VariableName, (0I, 4I), (0I, 13I)) + (TokenType.Symbol, (0I, 14I), (0I, 15I)) + (TokenType.Keyword, (0I, 16I), (0I, 20I)) ] ("val stringValue = \"hello\"" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 3L)) - (TokenType.VariableName, (0L, 4L), (0L, 15L)) - (TokenType.Symbol, (0L, 16L), (0L, 17L)) - (TokenType.Symbol, (0L, 18L), (0L, 19L)) - (TokenType.String, (0L, 19L), (0L, 24L)) - (TokenType.Symbol, (0L, 24L), (0L, 25L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 3I)) + (TokenType.VariableName, (0I, 4I), (0I, 15I)) + (TokenType.Symbol, (0I, 16I), (0I, 17I)) + (TokenType.Symbol, (0I, 18I), (0I, 19I)) + (TokenType.String, (0I, 19I), (0I, 24I)) + (TokenType.Symbol, (0I, 24I), (0I, 25I)) ] ("val charValue = 'a'" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 3L)) - (TokenType.VariableName, (0L, 4L), (0L, 13L)) - (TokenType.Symbol, (0L, 14L), (0L, 15L)) - (TokenType.Symbol, (0L, 16L), (0L, 17L)) - (TokenType.String, (0L, 17L), (0L, 18L)) - (TokenType.Symbol, (0L, 18L), (0L, 19L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 3I)) + (TokenType.VariableName, (0I, 4I), (0I, 13I)) + (TokenType.Symbol, (0I, 14I), (0I, 15I)) + (TokenType.Symbol, (0I, 16I), (0I, 17I)) + (TokenType.String, (0I, 17I), (0I, 18I)) + (TokenType.Symbol, (0I, 18I), (0I, 19I)) ] ("val floatValue = 1.0" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 3L)) - (TokenType.VariableName, (0L, 4L), (0L, 14L)) - (TokenType.Symbol, (0L, 15L), (0L, 16L)) - (TokenType.Number, (0L, 17L), (0L, 20L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 3I)) + (TokenType.VariableName, (0I, 4I), (0I, 14I)) + (TokenType.Symbol, (0I, 15I), (0I, 16I)) + (TokenType.Number, (0I, 17I), (0I, 20I)) ] ("val listValue = [1L; 2L; 3L]" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 3L)) - (TokenType.VariableName, (0L, 4L), (0L, 13L)) - (TokenType.Symbol, (0L, 14L), (0L, 15L)) - (TokenType.Symbol, (0L, 16L), (0L, 17L)) - (TokenType.Number, (0L, 17L), (0L, 18L)) - (TokenType.Symbol, (0L, 18L), (0L, 19L)) - (TokenType.Number, (0L, 21L), (0L, 22L)) - (TokenType.Symbol, (0L, 22L), (0L, 23L)) - (TokenType.Number, (0L, 25L), (0L, 26L)) - (TokenType.Symbol, (0L, 26L), (0L, 27L)) - (TokenType.Symbol, (0L, 27L), (0L, 28L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 3I)) + (TokenType.VariableName, (0I, 4I), (0I, 13I)) + (TokenType.Symbol, (0I, 14I), (0I, 15I)) + (TokenType.Symbol, (0I, 16I), (0I, 17I)) + (TokenType.Number, (0I, 17I), (0I, 18I)) + (TokenType.Symbol, (0I, 18I), (0I, 19I)) + (TokenType.Number, (0I, 21I), (0I, 22I)) + (TokenType.Symbol, (0I, 22I), (0I, 23I)) + (TokenType.Number, (0I, 25I), (0I, 26I)) + (TokenType.Symbol, (0I, 26I), (0I, 27I)) + (TokenType.Symbol, (0I, 27I), (0I, 28I)) ] ("val tupleValue = (1L, 2L, 3L)" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 3L)) - (TokenType.VariableName, (0L, 4L), (0L, 14L)) - (TokenType.Symbol, (0L, 15L), (0L, 16L)) - (TokenType.Symbol, (0L, 17L), (0L, 18L)) - (TokenType.Number, (0L, 18L), (0L, 19L)) - (TokenType.Symbol, (0L, 19L), (0L, 20L)) - (TokenType.Symbol, (0L, 20L), (0L, 21L)) - (TokenType.Number, (0L, 22L), (0L, 23L)) - (TokenType.Symbol, (0L, 23L), (0L, 24L)) - (TokenType.Symbol, (0L, 24L), (0L, 25L)) - (TokenType.Number, (0L, 26L), (0L, 27L)) - (TokenType.Symbol, (0L, 27L), (0L, 28L)) - (TokenType.Symbol, (0L, 28L), (0L, 29L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 3I)) + (TokenType.VariableName, (0I, 4I), (0I, 14I)) + (TokenType.Symbol, (0I, 15I), (0I, 16I)) + (TokenType.Symbol, (0I, 17I), (0I, 18I)) + (TokenType.Number, (0I, 18I), (0I, 19I)) + (TokenType.Symbol, (0I, 19I), (0I, 20I)) + (TokenType.Symbol, (0I, 20I), (0I, 21I)) + (TokenType.Number, (0I, 22I), (0I, 23I)) + (TokenType.Symbol, (0I, 23I), (0I, 24I)) + (TokenType.Symbol, (0I, 24I), (0I, 25I)) + (TokenType.Number, (0I, 26I), (0I, 27I)) + (TokenType.Symbol, (0I, 27I), (0I, 28I)) + (TokenType.Symbol, (0I, 28I), (0I, 29I)) ] ("val dictValue = Dict { a = 1L; b = 2L }" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 3L)) - (TokenType.VariableName, (0L, 4L), (0L, 13L)) - (TokenType.Symbol, (0L, 14L), (0L, 15L)) - (TokenType.Keyword, (0L, 16L), (0L, 20L)) - (TokenType.Symbol, (0L, 21L), (0L, 22L)) - (TokenType.Property, (0L, 23L), (0L, 24L)) - (TokenType.Number, (0L, 27L), (0L, 28L)) - (TokenType.Symbol, (0L, 28L), (0L, 29L)) - (TokenType.Property, (0L, 31L), (0L, 32L)) - (TokenType.Number, (0L, 35L), (0L, 36L)) - (TokenType.Symbol, (0L, 36L), (0L, 37L)) - (TokenType.Symbol, (0L, 38L), (0L, 39L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 3I)) + (TokenType.VariableName, (0I, 4I), (0I, 13I)) + (TokenType.Symbol, (0I, 14I), (0I, 15I)) + (TokenType.Keyword, (0I, 16I), (0I, 20I)) + (TokenType.Symbol, (0I, 21I), (0I, 22I)) + (TokenType.Property, (0I, 23I), (0I, 24I)) + (TokenType.Number, (0I, 27I), (0I, 28I)) + (TokenType.Symbol, (0I, 28I), (0I, 29I)) + (TokenType.Property, (0I, 31I), (0I, 32I)) + (TokenType.Number, (0I, 35I), (0I, 36I)) + (TokenType.Symbol, (0I, 36I), (0I, 37I)) + (TokenType.Symbol, (0I, 38I), (0I, 39I)) ] ("val enumValue = Stdlib.Option.Option.Some(1L)" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 3L)) - (TokenType.VariableName, (0L, 4L), (0L, 13L)) - (TokenType.Symbol, (0L, 14L), (0L, 15L)) - (TokenType.ModuleName, (0L, 16L), (0L, 22L)) - (TokenType.ModuleName, (0L, 23L), (0L, 29L)) - (TokenType.TypeName, (0L, 30L), (0L, 36L)) - (TokenType.Symbol, (0L, 36L), (0L, 37L)) - (TokenType.EnumMember, (0L, 37L), (0L, 41L)) - (TokenType.Number, (0L, 42L), (0L, 43L)) - (TokenType.Symbol, (0L, 43L), (0L, 44L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 3I)) + (TokenType.VariableName, (0I, 4I), (0I, 13I)) + (TokenType.Symbol, (0I, 14I), (0I, 15I)) + (TokenType.ModuleName, (0I, 16I), (0I, 22I)) + (TokenType.ModuleName, (0I, 23I), (0I, 29I)) + (TokenType.TypeName, (0I, 30I), (0I, 36I)) + (TokenType.Symbol, (0I, 36I), (0I, 37I)) + (TokenType.EnumMember, (0I, 37I), (0I, 41I)) + (TokenType.Number, (0I, 42I), (0I, 43I)) + (TokenType.Symbol, (0I, 43I), (0I, 44I)) ] ("val enumValue = MyEnum.A(1L, 2L)" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 3L)) - (TokenType.VariableName, (0L, 4L), (0L, 13L)) - (TokenType.Symbol, (0L, 14L), (0L, 15L)) - (TokenType.TypeName, (0L, 16L), (0L, 22L)) - (TokenType.Symbol, (0L, 22L), (0L, 23L)) - (TokenType.EnumMember, (0L, 23L), (0L, 24L)) - (TokenType.Number, (0L, 25L), (0L, 26L)) - (TokenType.Symbol, (0L, 26L), (0L, 27L)) - (TokenType.Number, (0L, 29L), (0L, 30L)) - (TokenType.Symbol, (0L, 30L), (0L, 31L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 3I)) + (TokenType.VariableName, (0I, 4I), (0I, 13I)) + (TokenType.Symbol, (0I, 14I), (0I, 15I)) + (TokenType.TypeName, (0I, 16I), (0I, 22I)) + (TokenType.Symbol, (0I, 22I), (0I, 23I)) + (TokenType.EnumMember, (0I, 23I), (0I, 24I)) + (TokenType.Number, (0I, 25I), (0I, 26I)) + (TokenType.Symbol, (0I, 26I), (0I, 27I)) + (TokenType.Number, (0I, 29I), (0I, 30I)) + (TokenType.Symbol, (0I, 30I), (0I, 31I)) ] module TokenizeExpression = - ("()" |> tokenize) = [ (TokenType.Symbol, (0L, 0L), (0L, 2L)) ] - ("true" |> tokenize) = [ (TokenType.Keyword, (0L, 0L), (0L, 4L)) ] + ("()" |> tokenize) = [ (TokenType.Symbol, (0I, 0I), (0I, 2I)) ] + ("true" |> tokenize) = [ (TokenType.Keyword, (0I, 0I), (0I, 4I)) ] - ("1y" |> tokenize) = [ (TokenType.Number, (0L, 0L), (0L, 1L)) - (TokenType.Symbol, (0L, 1L), (0L, 2L)) ] + ("1y" |> tokenize) = [ (TokenType.Number, (0I, 0I), (0I, 1I)) + (TokenType.Symbol, (0I, 1I), (0I, 2I)) ] - ("1uy" |> tokenize) = [ (TokenType.Number, (0L, 0L), (0L, 1L)) - (TokenType.Symbol, (0L, 1L), (0L, 3L)) ] + ("1uy" |> tokenize) = [ (TokenType.Number, (0I, 0I), (0I, 1I)) + (TokenType.Symbol, (0I, 1I), (0I, 3I)) ] - ("1s" |> tokenize) = [ (TokenType.Number, (0L, 0L), (0L, 1L)) - (TokenType.Symbol, (0L, 1L), (0L, 2L)) ] + ("1s" |> tokenize) = [ (TokenType.Number, (0I, 0I), (0I, 1I)) + (TokenType.Symbol, (0I, 1I), (0I, 2I)) ] - ("1us" |> tokenize) = [ (TokenType.Number, (0L, 0L), (0L, 1L)) - (TokenType.Symbol, (0L, 1L), (0L, 3L)) ] + ("1us" |> tokenize) = [ (TokenType.Number, (0I, 0I), (0I, 1I)) + (TokenType.Symbol, (0I, 1I), (0I, 3I)) ] - ("1l" |> tokenize) = [ (TokenType.Number, (0L, 0L), (0L, 1L)) - (TokenType.Symbol, (0L, 1L), (0L, 2L)) ] + ("1l" |> tokenize) = [ (TokenType.Number, (0I, 0I), (0I, 1I)) + (TokenType.Symbol, (0I, 1I), (0I, 2I)) ] - ("1ul" |> tokenize) = [ (TokenType.Number, (0L, 0L), (0L, 1L)) - (TokenType.Symbol, (0L, 1L), (0L, 3L)) ] + ("1ul" |> tokenize) = [ (TokenType.Number, (0I, 0I), (0I, 1I)) + (TokenType.Symbol, (0I, 1I), (0I, 3I)) ] - ("1L" |> tokenize) = [ (TokenType.Number, (0L, 0L), (0L, 1L)) - (TokenType.Symbol, (0L, 1L), (0L, 2L)) ] + ("1L" |> tokenize) = [ (TokenType.Number, (0I, 0I), (0I, 1I)) + (TokenType.Symbol, (0I, 1I), (0I, 2I)) ] - ("1UL" |> tokenize) = [ (TokenType.Number, (0L, 0L), (0L, 1L)) - (TokenType.Symbol, (0L, 1L), (0L, 3L)) ] + ("1UL" |> tokenize) = [ (TokenType.Number, (0I, 0I), (0I, 1I)) + (TokenType.Symbol, (0I, 1I), (0I, 3I)) ] - ("1Q" |> tokenize) = [ (TokenType.Number, (0L, 0L), (0L, 1L)) - (TokenType.Symbol, (0L, 1L), (0L, 2L)) ] + ("1Q" |> tokenize) = [ (TokenType.Number, (0I, 0I), (0I, 1I)) + (TokenType.Symbol, (0I, 1I), (0I, 2I)) ] - ("1Z" |> tokenize) = [ (TokenType.Number, (0L, 0L), (0L, 1L)) - (TokenType.Symbol, (0L, 1L), (0L, 2L)) ] + ("1Z" |> tokenize) = [ (TokenType.Number, (0I, 0I), (0I, 1I)) + (TokenType.Symbol, (0I, 1I), (0I, 2I)) ] // suffixless Int literal: just a Number token, no suffix Symbol - ("1" |> tokenize) = [ (TokenType.Number, (0L, 0L), (0L, 1L)) ] + ("1" |> tokenize) = [ (TokenType.Number, (0I, 0I), (0I, 1I)) ] ("12345678901234567890" |> tokenize) = - [ (TokenType.Number, (0L, 0L), (0L, 20L)) ] + [ (TokenType.Number, (0I, 0I), (0I, 20I)) ] - ("1.0" |> tokenize) = [ (TokenType.Number, (0L, 0L), (0L, 3L)) ] + ("1.0" |> tokenize) = [ (TokenType.Number, (0I, 0I), (0I, 3I)) ] ("\"hello\"" |> tokenize) = - [ (TokenType.Symbol, (0L, 0L), (0L, 1L)) - (TokenType.String, (0L, 1L), (0L, 6L)) - (TokenType.Symbol, (0L, 6L), (0L, 7L)) ] + [ (TokenType.Symbol, (0I, 0I), (0I, 1I)) + (TokenType.String, (0I, 1I), (0I, 6I)) + (TokenType.Symbol, (0I, 6I), (0I, 7I)) ] ("$\"hello {name}\"" |> tokenize) = - [ (TokenType.Symbol, (0L, 0L), (0L, 1L)) - (TokenType.Symbol, (0L, 1L), (0L, 2L)) - (TokenType.String, (0L, 2L), (0L, 8L)) - (TokenType.Symbol, (0L, 8L), (0L, 9L)) - (TokenType.VariableName, (0L, 9L), (0L, 13L)) - (TokenType.Symbol, (0L, 13L), (0L, 14L)) - (TokenType.Symbol, (0L, 14L), (0L, 15L)) ] + [ (TokenType.Symbol, (0I, 0I), (0I, 1I)) + (TokenType.Symbol, (0I, 1I), (0I, 2I)) + (TokenType.String, (0I, 2I), (0I, 8I)) + (TokenType.Symbol, (0I, 8I), (0I, 9I)) + (TokenType.VariableName, (0I, 9I), (0I, 13I)) + (TokenType.Symbol, (0I, 13I), (0I, 14I)) + (TokenType.Symbol, (0I, 14I), (0I, 15I)) ] ("$\"Name: {name}, Age: {age}\"" |> tokenize) = - [ (TokenType.Symbol, (0L, 0L), (0L, 1L)) - (TokenType.Symbol, (0L, 1L), (0L, 2L)) - (TokenType.String, (0L, 2L), (0L, 8L)) - (TokenType.Symbol, (0L, 8L), (0L, 9L)) - (TokenType.VariableName, (0L, 9L), (0L, 13L)) - (TokenType.Symbol, (0L, 13L), (0L, 14L)) - (TokenType.String, (0L, 14L), (0L, 21L)) - (TokenType.Symbol, (0L, 21L), (0L, 22L)) - (TokenType.VariableName, (0L, 22L), (0L, 25L)) - (TokenType.Symbol, (0L, 25L), (0L, 26L)) - (TokenType.Symbol, (0L, 26L), (0L, 27L)) ] + [ (TokenType.Symbol, (0I, 0I), (0I, 1I)) + (TokenType.Symbol, (0I, 1I), (0I, 2I)) + (TokenType.String, (0I, 2I), (0I, 8I)) + (TokenType.Symbol, (0I, 8I), (0I, 9I)) + (TokenType.VariableName, (0I, 9I), (0I, 13I)) + (TokenType.Symbol, (0I, 13I), (0I, 14I)) + (TokenType.String, (0I, 14I), (0I, 21I)) + (TokenType.Symbol, (0I, 21I), (0I, 22I)) + (TokenType.VariableName, (0I, 22I), (0I, 25I)) + (TokenType.Symbol, (0I, 25I), (0I, 26I)) + (TokenType.Symbol, (0I, 26I), (0I, 27I)) ] ("[true; false; true]" |> tokenize) = - [ (TokenType.Symbol, (0L, 0L), (0L, 1L)) - (TokenType.Keyword, (0L, 1L), (0L, 5L)) - (TokenType.Keyword, (0L, 7L), (0L, 12L)) - (TokenType.Keyword, (0L, 14L), (0L, 18L)) - (TokenType.Symbol, (0L, 18L), (0L, 19L)) ] + [ (TokenType.Symbol, (0I, 0I), (0I, 1I)) + (TokenType.Keyword, (0I, 1I), (0I, 5I)) + (TokenType.Keyword, (0I, 7I), (0I, 12I)) + (TokenType.Keyword, (0I, 14I), (0I, 18I)) + (TokenType.Symbol, (0I, 18I), (0I, 19I)) ] ("Dict { a = 1L; b = 2L }" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 4L)) - (TokenType.Symbol, (0L, 5L), (0L, 6L)) - (TokenType.Property, (0L, 7L), (0L, 8L)) - (TokenType.Number, (0L, 11L), (0L, 12L)) - (TokenType.Symbol, (0L, 12L), (0L, 13L)) - (TokenType.Property, (0L, 15L), (0L, 16L)) - (TokenType.Number, (0L, 19L), (0L, 20L)) - (TokenType.Symbol, (0L, 20L), (0L, 21L)) - (TokenType.Symbol, (0L, 22L), (0L, 23L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 4I)) + (TokenType.Symbol, (0I, 5I), (0I, 6I)) + (TokenType.Property, (0I, 7I), (0I, 8I)) + (TokenType.Number, (0I, 11I), (0I, 12I)) + (TokenType.Symbol, (0I, 12I), (0I, 13I)) + (TokenType.Property, (0I, 15I), (0I, 16I)) + (TokenType.Number, (0I, 19I), (0I, 20I)) + (TokenType.Symbol, (0I, 20I), (0I, 21I)) + (TokenType.Symbol, (0I, 22I), (0I, 23I)) ] ("(true, false, true)" |> tokenize) = - [ (TokenType.Symbol, (0L, 0L), (0L, 1L)) - (TokenType.Keyword, (0L, 1L), (0L, 5L)) - (TokenType.Symbol, (0L, 5L), (0L, 6L)) - (TokenType.Keyword, (0L, 7L), (0L, 12L)) - (TokenType.Symbol, (0L, 12L), (0L, 13L)) - (TokenType.Keyword, (0L, 14L), (0L, 18L)) - (TokenType.Symbol, (0L, 18L), (0L, 19L)) ] + [ (TokenType.Symbol, (0I, 0I), (0I, 1I)) + (TokenType.Keyword, (0I, 1I), (0I, 5I)) + (TokenType.Symbol, (0I, 5I), (0I, 6I)) + (TokenType.Keyword, (0I, 7I), (0I, 12I)) + (TokenType.Symbol, (0I, 12I), (0I, 13I)) + (TokenType.Keyword, (0I, 14I), (0I, 18I)) + (TokenType.Symbol, (0I, 18I), (0I, 19I)) ] // Record/record-update tokenization regression coverage. // A previous .range-related RTE in this area makes this worth keeping explicit. ("MyRecord {fieldOne = 1L; fieldTwo = 2L} " |> tokenize) = - [ (TokenType.TypeName, (0L, 0L), (0L, 8L)) - (TokenType.Symbol, (0L, 9L), (0L, 10L)) - (TokenType.Property, (0L, 10L), (0L, 18L)) - (TokenType.Symbol, (0L, 19L), (0L, 20L)) - (TokenType.Number, (0L, 21L), (0L, 22L)) - (TokenType.Symbol, (0L, 22L), (0L, 23L)) - (TokenType.Property, (0L, 25L), (0L, 33L)) - (TokenType.Symbol, (0L, 34L), (0L, 35L)) - (TokenType.Number, (0L, 36L), (0L, 37L)) - (TokenType.Symbol, (0L, 37L), (0L, 38L)) - (TokenType.Symbol, (0L, 38L), (0L, 39L)) ] + [ (TokenType.TypeName, (0I, 0I), (0I, 8I)) + (TokenType.Symbol, (0I, 9I), (0I, 10I)) + (TokenType.Property, (0I, 10I), (0I, 18I)) + (TokenType.Symbol, (0I, 19I), (0I, 20I)) + (TokenType.Number, (0I, 21I), (0I, 22I)) + (TokenType.Symbol, (0I, 22I), (0I, 23I)) + (TokenType.Property, (0I, 25I), (0I, 33I)) + (TokenType.Symbol, (0I, 34I), (0I, 35I)) + (TokenType.Number, (0I, 36I), (0I, 37I)) + (TokenType.Symbol, (0I, 37I), (0I, 38I)) + (TokenType.Symbol, (0I, 38I), (0I, 39I)) ] ("{ RecordForUpdate { x = true; y = false } with y = true }" |> tokenize) = - [ (TokenType.TypeName, (0L, 2L), (0L, 17L)) - (TokenType.Symbol, (0L, 18L), (0L, 19L)) - (TokenType.Property, (0L, 20L), (0L, 21L)) - (TokenType.Symbol, (0L, 22L), (0L, 23L)) - (TokenType.Keyword, (0L, 24L), (0L, 28L)) - (TokenType.Property, (0L, 30L), (0L, 31L)) - (TokenType.Symbol, (0L, 32L), (0L, 33L)) - (TokenType.Keyword, (0L, 34L), (0L, 39L)) - (TokenType.Symbol, (0L, 40L), (0L, 41L)) - (TokenType.Keyword, (0L, 42L), (0L, 46L)) - (TokenType.Property, (0L, 47L), (0L, 48L)) - (TokenType.Symbol, (0L, 49L), (0L, 50L)) - (TokenType.Keyword, (0L, 51L), (0L, 55L)) ] + [ (TokenType.TypeName, (0I, 2I), (0I, 17I)) + (TokenType.Symbol, (0I, 18I), (0I, 19I)) + (TokenType.Property, (0I, 20I), (0I, 21I)) + (TokenType.Symbol, (0I, 22I), (0I, 23I)) + (TokenType.Keyword, (0I, 24I), (0I, 28I)) + (TokenType.Property, (0I, 30I), (0I, 31I)) + (TokenType.Symbol, (0I, 32I), (0I, 33I)) + (TokenType.Keyword, (0I, 34I), (0I, 39I)) + (TokenType.Symbol, (0I, 40I), (0I, 41I)) + (TokenType.Keyword, (0I, 42I), (0I, 46I)) + (TokenType.Property, (0I, 47I), (0I, 48I)) + (TokenType.Symbol, (0I, 49I), (0I, 50I)) + (TokenType.Keyword, (0I, 51I), (0I, 55I)) ] ("MyEnum.A(1L)" |> tokenize) = - [ (TokenType.TypeName, (0L, 0L), (0L, 6L)) - (TokenType.Symbol, (0L, 6L), (0L, 7L)) - (TokenType.EnumMember, (0L, 7L), (0L, 8L)) - (TokenType.Number, (0L, 9L), (0L, 10L)) - (TokenType.Symbol, (0L, 10L), (0L, 11L)) ] + [ (TokenType.TypeName, (0I, 0I), (0I, 6I)) + (TokenType.Symbol, (0I, 6I), (0I, 7I)) + (TokenType.EnumMember, (0I, 7I), (0I, 8I)) + (TokenType.Number, (0I, 9I), (0I, 10I)) + (TokenType.Symbol, (0I, 10I), (0I, 11I)) ] ("let x = true\n x" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 3L)) - (TokenType.VariableName, (0L, 4L), (0L, 5L)) - (TokenType.Symbol, (0L, 6L), (0L, 7L)) - (TokenType.Keyword, (0L, 8L), (0L, 12L)) - (TokenType.VariableName, (1L, 2L), (1L, 3L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 3I)) + (TokenType.VariableName, (0I, 4I), (0I, 5I)) + (TokenType.Symbol, (0I, 6I), (0I, 7I)) + (TokenType.Keyword, (0I, 8I), (0I, 12I)) + (TokenType.VariableName, (1I, 2I), (1I, 3I)) ] ("myVar" |> tokenize) = - [ (TokenType.VariableName, (0L, 0L), (0L, 5L)) ] + [ (TokenType.VariableName, (0I, 0I), (0I, 5I)) ] ("myRecordVar.field" |> tokenize) = - [ (TokenType.VariableName, (0L, 0L), (0L, 11L)) - (TokenType.Symbol, (0L, 11L), (0L, 12L)) - (TokenType.Property, (0L, 12L), (0L, 17L)) ] + [ (TokenType.VariableName, (0I, 0I), (0I, 11I)) + (TokenType.Symbol, (0I, 11I), (0I, 12I)) + (TokenType.Property, (0I, 12I), (0I, 17I)) ] ("1L + 2L" |> tokenize) = - [ (TokenType.Number, (0L, 0L), (0L, 1L)) - (TokenType.Symbol, (0L, 1L), (0L, 2L)) - (TokenType.Operator, (0L, 3L), (0L, 4L)) - (TokenType.Number, (0L, 5L), (0L, 6L)) - (TokenType.Symbol, (0L, 6L), (0L, 7L)) ] + [ (TokenType.Number, (0I, 0I), (0I, 1I)) + (TokenType.Symbol, (0I, 1I), (0I, 2I)) + (TokenType.Operator, (0I, 3I), (0I, 4I)) + (TokenType.Number, (0I, 5I), (0I, 6I)) + (TokenType.Symbol, (0I, 6I), (0I, 7I)) ] ("fun x -> x" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 3L)) - (TokenType.VariableName, (0L, 4L), (0L, 5L)) - (TokenType.Symbol, (0L, 6L), (0L, 8L)) - (TokenType.VariableName, (0L, 9L), (0L, 10L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 3I)) + (TokenType.VariableName, (0I, 4I), (0I, 5I)) + (TokenType.Symbol, (0I, 6I), (0I, 8I)) + (TokenType.VariableName, (0I, 9I), (0I, 10I)) ] ("Stdlib.Bool.and true false" |> tokenize) = - [ (TokenType.ModuleName, (0L, 0L), (0L, 6L)) - (TokenType.ModuleName, (0L, 7L), (0L, 11L)) - (TokenType.FunctionName, (0L, 12L), (0L, 15L)) - (TokenType.Keyword, (0L, 16L), (0L, 20L)) - (TokenType.Keyword, (0L, 21L), (0L, 26L)) ] + [ (TokenType.ModuleName, (0I, 0I), (0I, 6I)) + (TokenType.ModuleName, (0I, 7I), (0I, 11I)) + (TokenType.FunctionName, (0I, 12I), (0I, 15I)) + (TokenType.Keyword, (0I, 16I), (0I, 20I)) + (TokenType.Keyword, (0I, 21I), (0I, 26I)) ] // // CLEANUP: fix this, the range is correct, but the order isn't for typeArgs // ("Builtin.jsonParse \"true\"" |> tokenize) = - // [ (TokenType.ModuleName, (0L, 0L), (0L, 7L)) - // (TokenType.FunctionName, (0L, 8L), (0L, 17L)) - // (TokenType.TypeName, (0L, 18L), (0L, 22L)) - // (TokenType.Symbol, (0L, 24L), (0L, 25L)) - // (TokenType.String, (0L, 25L), (0L, 29L)) - // (TokenType.Symbol, (0L, 29L), (0L, 30L)) ] + // [ (TokenType.ModuleName, (0I, 0I), (0I, 7I)) + // (TokenType.FunctionName, (0I, 8I), (0I, 17I)) + // (TokenType.TypeName, (0I, 18I), (0I, 22I)) + // (TokenType.Symbol, (0I, 24I), (0I, 25I)) + // (TokenType.String, (0I, 25I), (0I, 29I)) + // (TokenType.Symbol, (0I, 29I), (0I, 30I)) ] ("if true then true else false" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 2L)) - (TokenType.Keyword, (0L, 3L), (0L, 7L)) - (TokenType.Keyword, (0L, 8L), (0L, 12L)) - (TokenType.Keyword, (0L, 13L), (0L, 17L)) - (TokenType.Keyword, (0L, 18L), (0L, 22L)) - (TokenType.Keyword, (0L, 23L), (0L, 28L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 2I)) + (TokenType.Keyword, (0I, 3I), (0I, 7I)) + (TokenType.Keyword, (0I, 8I), (0I, 12I)) + (TokenType.Keyword, (0I, 13I), (0I, 17I)) + (TokenType.Keyword, (0I, 18I), (0I, 22I)) + (TokenType.Keyword, (0I, 23I), (0I, 28I)) ] ("match true with\n| true -> true" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 5L)) - (TokenType.Keyword, (0L, 6L), (0L, 10L)) - (TokenType.Keyword, (0L, 11L), (0L, 15L)) - (TokenType.Symbol, (1L, 0L), (1L, 1L)) - (TokenType.Keyword, (1L, 2L), (1L, 6L)) - (TokenType.Symbol, (1L, 7L), (1L, 9L)) - (TokenType.Keyword, (1L, 10L), (1L, 14L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 5I)) + (TokenType.Keyword, (0I, 6I), (0I, 10I)) + (TokenType.Keyword, (0I, 11I), (0I, 15I)) + (TokenType.Symbol, (1I, 0I), (1I, 1I)) + (TokenType.Keyword, (1I, 2I), (1I, 6I)) + (TokenType.Symbol, (1I, 7I), (1I, 9I)) + (TokenType.Keyword, (1I, 10I), (1I, 14I)) ] ("Stdlib.List.empty" |> tokenize) = - [ (TokenType.ModuleName, (0L, 0L), (0L, 6L)) - (TokenType.ModuleName, (0L, 7L), (0L, 11L)) - (TokenType.VariableName, (0L, 12L), (0L, 17L)) ] + [ (TokenType.ModuleName, (0I, 0I), (0I, 6I)) + (TokenType.ModuleName, (0I, 7I), (0I, 11I)) + (TokenType.VariableName, (0I, 12I), (0I, 17I)) ] module TokenizePipeExpression = ("1L |> (+) 2L" |> tokenize) = - [ (TokenType.Number, (0L, 0L), (0L, 1L)) - (TokenType.Symbol, (0L, 1L), (0L, 2L)) - (TokenType.Operator, (0L, 3L), (0L, 5L)) - (TokenType.Operator, (0L, 7L), (0L, 8L)) - (TokenType.Number, (0L, 10L), (0L, 11L)) - (TokenType.Symbol, (0L, 11L), (0L, 12L)) ] + [ (TokenType.Number, (0I, 0I), (0I, 1I)) + (TokenType.Symbol, (0I, 1I), (0I, 2I)) + (TokenType.Operator, (0I, 3I), (0I, 5I)) + (TokenType.Operator, (0I, 7I), (0I, 8I)) + (TokenType.Number, (0I, 10I), (0I, 11I)) + (TokenType.Symbol, (0I, 11I), (0I, 12I)) ] ("1L |> (fun x -> x + 1L)" |> tokenize) = - [ (TokenType.Number, (0L, 0L), (0L, 1L)) - (TokenType.Symbol, (0L, 1L), (0L, 2L)) - (TokenType.Operator, (0L, 3L), (0L, 5L)) - (TokenType.Keyword, (0L, 7L), (0L, 10L)) - (TokenType.VariableName, (0L, 11L), (0L, 12L)) - (TokenType.Symbol, (0L, 13L), (0L, 15L)) - (TokenType.VariableName, (0L, 16L), (0L, 17L)) - (TokenType.Operator, (0L, 18L), (0L, 19L)) - (TokenType.Number, (0L, 20L), (0L, 21L)) - (TokenType.Symbol, (0L, 21L), (0L, 22L)) ] + [ (TokenType.Number, (0I, 0I), (0I, 1I)) + (TokenType.Symbol, (0I, 1I), (0I, 2I)) + (TokenType.Operator, (0I, 3I), (0I, 5I)) + (TokenType.Keyword, (0I, 7I), (0I, 10I)) + (TokenType.VariableName, (0I, 11I), (0I, 12I)) + (TokenType.Symbol, (0I, 13I), (0I, 15I)) + (TokenType.VariableName, (0I, 16I), (0I, 17I)) + (TokenType.Operator, (0I, 18I), (0I, 19I)) + (TokenType.Number, (0I, 20I), (0I, 21I)) + (TokenType.Symbol, (0I, 21I), (0I, 22I)) ] ("1L |> MyEnum.A" |> tokenize) = - [ (TokenType.Number, (0L, 0L), (0L, 1L)) - (TokenType.Symbol, (0L, 1L), (0L, 2L)) - (TokenType.Operator, (0L, 3L), (0L, 5L)) - (TokenType.TypeName, (0L, 6L), (0L, 12L)) - (TokenType.Symbol, (0L, 12L), (0L, 13L)) - (TokenType.EnumMember, (0L, 13L), (0L, 14L)) ] + [ (TokenType.Number, (0I, 0I), (0I, 1I)) + (TokenType.Symbol, (0I, 1I), (0I, 2I)) + (TokenType.Operator, (0I, 3I), (0I, 5I)) + (TokenType.TypeName, (0I, 6I), (0I, 12I)) + (TokenType.Symbol, (0I, 12I), (0I, 13I)) + (TokenType.EnumMember, (0I, 13I), (0I, 14I)) ] ("1L |> Stdlib.Result.Result.Ok" |> tokenize) = - [ (TokenType.Number, (0L, 0L), (0L, 1L)) - (TokenType.Symbol, (0L, 1L), (0L, 2L)) - (TokenType.Operator, (0L, 3L), (0L, 5L)) - (TokenType.ModuleName, (0L, 6L), (0L, 12L)) - (TokenType.ModuleName, (0L, 13L), (0L, 19L)) - (TokenType.TypeName, (0L, 20L), (0L, 26L)) - (TokenType.Symbol, (0L, 26L), (0L, 27L)) - (TokenType.EnumMember, (0L, 27L), (0L, 29L)) ] + [ (TokenType.Number, (0I, 0I), (0I, 1I)) + (TokenType.Symbol, (0I, 1I), (0I, 2I)) + (TokenType.Operator, (0I, 3I), (0I, 5I)) + (TokenType.ModuleName, (0I, 6I), (0I, 12I)) + (TokenType.ModuleName, (0I, 13I), (0I, 19I)) + (TokenType.TypeName, (0I, 20I), (0I, 26I)) + (TokenType.Symbol, (0I, 26I), (0I, 27I)) + (TokenType.EnumMember, (0I, 27I), (0I, 29I)) ] ("1L |> Stdlib.Int64.add 2L" |> tokenize) = - [ (TokenType.Number, (0L, 0L), (0L, 1L)) - (TokenType.Symbol, (0L, 1L), (0L, 2L)) - (TokenType.Operator, (0L, 3L), (0L, 5L)) - (TokenType.ModuleName, (0L, 6L), (0L, 12L)) - (TokenType.ModuleName, (0L, 13L), (0L, 18L)) - (TokenType.FunctionName, (0L, 19L), (0L, 22L)) - (TokenType.Number, (0L, 23L), (0L, 24L)) - (TokenType.Symbol, (0L, 24L), (0L, 25L)) ] + [ (TokenType.Number, (0I, 0I), (0I, 1I)) + (TokenType.Symbol, (0I, 1I), (0I, 2I)) + (TokenType.Operator, (0I, 3I), (0I, 5I)) + (TokenType.ModuleName, (0I, 6I), (0I, 12I)) + (TokenType.ModuleName, (0I, 13I), (0I, 18I)) + (TokenType.FunctionName, (0I, 19I), (0I, 22I)) + (TokenType.Number, (0I, 23I), (0I, 24I)) + (TokenType.Symbol, (0I, 24I), (0I, 25I)) ] ("\"true\" |> Builtin.jsonParse" |> tokenize) = - [ (TokenType.Symbol, (0L, 0L), (0L, 1L)) - (TokenType.String, (0L, 1L), (0L, 5L)) - (TokenType.Symbol, (0L, 5L), (0L, 6L)) - (TokenType.Operator, (0L, 7L), (0L, 9L)) - (TokenType.ModuleName, (0L, 10L), (0L, 17L)) - (TokenType.FunctionName, (0L, 18L), (0L, 27L)) - (TokenType.TypeName, (0L, 28L), (0L, 32L)) ] + [ (TokenType.Symbol, (0I, 0I), (0I, 1I)) + (TokenType.String, (0I, 1I), (0I, 5I)) + (TokenType.Symbol, (0I, 5I), (0I, 6I)) + (TokenType.Operator, (0I, 7I), (0I, 9I)) + (TokenType.ModuleName, (0I, 10I), (0I, 17I)) + (TokenType.FunctionName, (0I, 18I), (0I, 27I)) + (TokenType.TypeName, (0I, 28I), (0I, 32I)) ] ("1L |> x" |> tokenize) = - [ (TokenType.Number, (0L, 0L), (0L, 1L)) - (TokenType.Symbol, (0L, 1L), (0L, 2L)) - (TokenType.Operator, (0L, 3L), (0L, 5L)) - (TokenType.FunctionName, (0L, 6L), (0L, 7L)) ] + [ (TokenType.Number, (0I, 0I), (0I, 1I)) + (TokenType.Symbol, (0I, 1I), (0I, 2I)) + (TokenType.Operator, (0I, 3I), (0I, 5I)) + (TokenType.FunctionName, (0I, 6I), (0I, 7I)) ] module TokenizeMatchExpression = ("match () with\n| () -> true" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 5L)) - (TokenType.Symbol, (0L, 6L), (0L, 8L)) - (TokenType.Keyword, (0L, 9L), (0L, 13L)) - (TokenType.Symbol, (1L, 0L), (1L, 1L)) - (TokenType.Symbol, (1L, 2L), (1L, 4L)) - (TokenType.Symbol, (1L, 5L), (1L, 7L)) - (TokenType.Keyword, (1L, 8L), (1L, 12L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 5I)) + (TokenType.Symbol, (0I, 6I), (0I, 8I)) + (TokenType.Keyword, (0I, 9I), (0I, 13I)) + (TokenType.Symbol, (1I, 0I), (1I, 1I)) + (TokenType.Symbol, (1I, 2I), (1I, 4I)) + (TokenType.Symbol, (1I, 5I), (1I, 7I)) + (TokenType.Keyword, (1I, 8I), (1I, 12I)) ] ("match x with\n| x -> 1L" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 5L)) - (TokenType.VariableName, (0L, 6L), (0L, 7L)) - (TokenType.Keyword, (0L, 8L), (0L, 12L)) - (TokenType.Symbol, (1L, 0L), (1L, 1L)) - (TokenType.VariableName, (1L, 2L), (1L, 3L)) - (TokenType.Symbol, (1L, 4L), (1L, 6L)) - (TokenType.Number, (1L, 7L), (1L, 8L)) - (TokenType.Symbol, (1L, 8L), (1L, 9L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 5I)) + (TokenType.VariableName, (0I, 6I), (0I, 7I)) + (TokenType.Keyword, (0I, 8I), (0I, 12I)) + (TokenType.Symbol, (1I, 0I), (1I, 1I)) + (TokenType.VariableName, (1I, 2I), (1I, 3I)) + (TokenType.Symbol, (1I, 4I), (1I, 6I)) + (TokenType.Number, (1I, 7I), (1I, 8I)) + (TokenType.Symbol, (1I, 8I), (1I, 9I)) ] // suffixless Int in both pattern and rhs: Number tokens with no suffix Symbol ("match x with\n| 1 -> 2" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 5L)) - (TokenType.VariableName, (0L, 6L), (0L, 7L)) - (TokenType.Keyword, (0L, 8L), (0L, 12L)) - (TokenType.Symbol, (1L, 0L), (1L, 1L)) - (TokenType.Number, (1L, 2L), (1L, 3L)) - (TokenType.Symbol, (1L, 4L), (1L, 6L)) - (TokenType.Number, (1L, 7L), (1L, 8L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 5I)) + (TokenType.VariableName, (0I, 6I), (0I, 7I)) + (TokenType.Keyword, (0I, 8I), (0I, 12I)) + (TokenType.Symbol, (1I, 0I), (1I, 1I)) + (TokenType.Number, (1I, 2I), (1I, 3I)) + (TokenType.Symbol, (1I, 4I), (1I, 6I)) + (TokenType.Number, (1I, 7I), (1I, 8I)) ] ("match 1L with\n| 1L -> 1L" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 5L)) - (TokenType.Number, (0L, 6L), (0L, 7L)) - (TokenType.Symbol, (0L, 7L), (0L, 8L)) - (TokenType.Keyword, (0L, 9L), (0L, 13L)) - (TokenType.Symbol, (1L, 0L), (1L, 1L)) - (TokenType.Number, (1L, 2L), (1L, 3L)) - (TokenType.Symbol, (1L, 3L), (1L, 4L)) - (TokenType.Symbol, (1L, 5L), (1L, 7L)) - (TokenType.Number, (1L, 8L), (1L, 9L)) - (TokenType.Symbol, (1L, 9L), (1L, 10L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 5I)) + (TokenType.Number, (0I, 6I), (0I, 7I)) + (TokenType.Symbol, (0I, 7I), (0I, 8I)) + (TokenType.Keyword, (0I, 9I), (0I, 13I)) + (TokenType.Symbol, (1I, 0I), (1I, 1I)) + (TokenType.Number, (1I, 2I), (1I, 3I)) + (TokenType.Symbol, (1I, 3I), (1I, 4I)) + (TokenType.Symbol, (1I, 5I), (1I, 7I)) + (TokenType.Number, (1I, 8I), (1I, 9I)) + (TokenType.Symbol, (1I, 9I), (1I, 10I)) ] ("match 1.0 with\n| 1.0 -> 1.0" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 5L)) - (TokenType.Number, (0L, 6L), (0L, 9L)) - (TokenType.Keyword, (0L, 10L), (0L, 14L)) - (TokenType.Symbol, (1L, 0L), (1L, 1L)) - (TokenType.Number, (1L, 2L), (1L, 5L)) - (TokenType.Symbol, (1L, 6L), (1L, 8L)) - (TokenType.Number, (1L, 9L), (1L, 12L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 5I)) + (TokenType.Number, (0I, 6I), (0I, 9I)) + (TokenType.Keyword, (0I, 10I), (0I, 14I)) + (TokenType.Symbol, (1I, 0I), (1I, 1I)) + (TokenType.Number, (1I, 2I), (1I, 5I)) + (TokenType.Symbol, (1I, 6I), (1I, 8I)) + (TokenType.Number, (1I, 9I), (1I, 12I)) ] ("match true with\n| true -> true\n| false -> false" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 5L)) - (TokenType.Keyword, (0L, 6L), (0L, 10L)) - (TokenType.Keyword, (0L, 11L), (0L, 15L)) - (TokenType.Symbol, (1L, 0L), (1L, 1L)) - (TokenType.Keyword, (1L, 2L), (1L, 6L)) - (TokenType.Symbol, (1L, 7L), (1L, 9L)) - (TokenType.Keyword, (1L, 10L), (1L, 14L)) - (TokenType.Symbol, (2L, 0L), (2L, 1L)) - (TokenType.Keyword, (2L, 2L), (2L, 7L)) - (TokenType.Symbol, (2L, 8L), (2L, 10L)) - (TokenType.Keyword, (2L, 11L), (2L, 16L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 5I)) + (TokenType.Keyword, (0I, 6I), (0I, 10I)) + (TokenType.Keyword, (0I, 11I), (0I, 15I)) + (TokenType.Symbol, (1I, 0I), (1I, 1I)) + (TokenType.Keyword, (1I, 2I), (1I, 6I)) + (TokenType.Symbol, (1I, 7I), (1I, 9I)) + (TokenType.Keyword, (1I, 10I), (1I, 14I)) + (TokenType.Symbol, (2I, 0I), (2I, 1I)) + (TokenType.Keyword, (2I, 2I), (2I, 7I)) + (TokenType.Symbol, (2I, 8I), (2I, 10I)) + (TokenType.Keyword, (2I, 11I), (2I, 16I)) ] ("match \"str\" with\n| \"str\" -> true" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 5L)) - (TokenType.Symbol, (0L, 6L), (0L, 7L)) - (TokenType.String, (0L, 7L), (0L, 10L)) - (TokenType.Symbol, (0L, 10L), (0L, 11L)) - (TokenType.Keyword, (0L, 12L), (0L, 16L)) - (TokenType.Symbol, (1L, 0L), (1L, 1L)) - (TokenType.Symbol, (1L, 2L), (1L, 3L)) - (TokenType.String, (1L, 3L), (1L, 6L)) - (TokenType.Symbol, (1L, 6L), (1L, 7L)) - (TokenType.Symbol, (1L, 8L), (1L, 10L)) - (TokenType.Keyword, (1L, 11L), (1L, 15L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 5I)) + (TokenType.Symbol, (0I, 6I), (0I, 7I)) + (TokenType.String, (0I, 7I), (0I, 10I)) + (TokenType.Symbol, (0I, 10I), (0I, 11I)) + (TokenType.Keyword, (0I, 12I), (0I, 16I)) + (TokenType.Symbol, (1I, 0I), (1I, 1I)) + (TokenType.Symbol, (1I, 2I), (1I, 3I)) + (TokenType.String, (1I, 3I), (1I, 6I)) + (TokenType.Symbol, (1I, 6I), (1I, 7I)) + (TokenType.Symbol, (1I, 8I), (1I, 10I)) + (TokenType.Keyword, (1I, 11I), (1I, 15I)) ] ("match 'a' with\n| 'a' -> true" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 5L)) - (TokenType.Symbol, (0L, 6L), (0L, 7L)) - (TokenType.String, (0L, 7L), (0L, 8L)) - (TokenType.Symbol, (0L, 8L), (0L, 9L)) - (TokenType.Keyword, (0L, 10L), (0L, 14L)) - (TokenType.Symbol, (1L, 0L), (1L, 1L)) - (TokenType.Symbol, (1L, 2L), (1L, 3L)) - (TokenType.String, (1L, 3L), (1L, 4L)) - (TokenType.Symbol, (1L, 4L), (1L, 5L)) - (TokenType.Symbol, (1L, 6L), (1L, 8L)) - (TokenType.Keyword, (1L, 9L), (1L, 13L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 5I)) + (TokenType.Symbol, (0I, 6I), (0I, 7I)) + (TokenType.String, (0I, 7I), (0I, 8I)) + (TokenType.Symbol, (0I, 8I), (0I, 9I)) + (TokenType.Keyword, (0I, 10I), (0I, 14I)) + (TokenType.Symbol, (1I, 0I), (1I, 1I)) + (TokenType.Symbol, (1I, 2I), (1I, 3I)) + (TokenType.String, (1I, 3I), (1I, 4I)) + (TokenType.Symbol, (1I, 4I), (1I, 5I)) + (TokenType.Symbol, (1I, 6I), (1I, 8I)) + (TokenType.Keyword, (1I, 9I), (1I, 13I)) ] ("match [true; false] with\n| [true; false] -> true" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 5L)) - (TokenType.Symbol, (0L, 6L), (0L, 7L)) - (TokenType.Keyword, (0L, 7L), (0L, 11L)) - (TokenType.Keyword, (0L, 13L), (0L, 18L)) - (TokenType.Symbol, (0L, 18L), (0L, 19L)) - (TokenType.Keyword, (0L, 20L), (0L, 24L)) - (TokenType.Symbol, (1L, 0L), (1L, 1L)) - (TokenType.Symbol, (1L, 2L), (1L, 3L)) - (TokenType.Keyword, (1L, 3L), (1L, 7L)) - (TokenType.Keyword, (1L, 9L), (1L, 14L)) - (TokenType.Symbol, (1L, 14L), (1L, 15L)) - (TokenType.Symbol, (1L, 16L), (1L, 18L)) - (TokenType.Keyword, (1L, 19L), (1L, 23L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 5I)) + (TokenType.Symbol, (0I, 6I), (0I, 7I)) + (TokenType.Keyword, (0I, 7I), (0I, 11I)) + (TokenType.Keyword, (0I, 13I), (0I, 18I)) + (TokenType.Symbol, (0I, 18I), (0I, 19I)) + (TokenType.Keyword, (0I, 20I), (0I, 24I)) + (TokenType.Symbol, (1I, 0I), (1I, 1I)) + (TokenType.Symbol, (1I, 2I), (1I, 3I)) + (TokenType.Keyword, (1I, 3I), (1I, 7I)) + (TokenType.Keyword, (1I, 9I), (1I, 14I)) + (TokenType.Symbol, (1I, 14I), (1I, 15I)) + (TokenType.Symbol, (1I, 16I), (1I, 18I)) + (TokenType.Keyword, (1I, 19I), (1I, 23I)) ] ("match [1L; 2L] with\n| head :: tail -> true" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 5L)) - (TokenType.Symbol, (0L, 6L), (0L, 7L)) - (TokenType.Number, (0L, 7L), (0L, 8L)) - (TokenType.Symbol, (0L, 8L), (0L, 9L)) - (TokenType.Number, (0L, 11L), (0L, 12L)) - (TokenType.Symbol, (0L, 12L), (0L, 13L)) - (TokenType.Symbol, (0L, 13L), (0L, 14L)) - (TokenType.Keyword, (0L, 15L), (0L, 19L)) - (TokenType.Symbol, (1L, 0L), (1L, 1L)) - (TokenType.VariableName, (1L, 2L), (1L, 6L)) - (TokenType.Symbol, (1L, 7L), (1L, 9L)) - (TokenType.VariableName, (1L, 10L), (1L, 14L)) - (TokenType.Symbol, (1L, 15L), (1L, 17L)) - (TokenType.Keyword, (1L, 18L), (1L, 22L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 5I)) + (TokenType.Symbol, (0I, 6I), (0I, 7I)) + (TokenType.Number, (0I, 7I), (0I, 8I)) + (TokenType.Symbol, (0I, 8I), (0I, 9I)) + (TokenType.Number, (0I, 11I), (0I, 12I)) + (TokenType.Symbol, (0I, 12I), (0I, 13I)) + (TokenType.Symbol, (0I, 13I), (0I, 14I)) + (TokenType.Keyword, (0I, 15I), (0I, 19I)) + (TokenType.Symbol, (1I, 0I), (1I, 1I)) + (TokenType.VariableName, (1I, 2I), (1I, 6I)) + (TokenType.Symbol, (1I, 7I), (1I, 9I)) + (TokenType.VariableName, (1I, 10I), (1I, 14I)) + (TokenType.Symbol, (1I, 15I), (1I, 17I)) + (TokenType.Keyword, (1I, 18I), (1I, 22I)) ] ("match (true, false) with\n| (true, false) -> true" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 5L)) - (TokenType.Symbol, (0L, 6L), (0L, 7L)) - (TokenType.Keyword, (0L, 7L), (0L, 11L)) - (TokenType.Symbol, (0L, 11L), (0L, 12L)) - (TokenType.Keyword, (0L, 13L), (0L, 18L)) - (TokenType.Symbol, (0L, 18L), (0L, 19L)) - (TokenType.Keyword, (0L, 20L), (0L, 24L)) - (TokenType.Symbol, (1L, 0L), (1L, 1L)) - (TokenType.Symbol, (1L, 2L), (1L, 3L)) - (TokenType.Keyword, (1L, 3L), (1L, 7L)) - (TokenType.Symbol, (1L, 7L), (1L, 8L)) - (TokenType.Keyword, (1L, 9L), (1L, 14L)) - (TokenType.Symbol, (1L, 14L), (1L, 15L)) - (TokenType.Symbol, (1L, 16L), (1L, 18L)) - (TokenType.Keyword, (1L, 19L), (1L, 23L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 5I)) + (TokenType.Symbol, (0I, 6I), (0I, 7I)) + (TokenType.Keyword, (0I, 7I), (0I, 11I)) + (TokenType.Symbol, (0I, 11I), (0I, 12I)) + (TokenType.Keyword, (0I, 13I), (0I, 18I)) + (TokenType.Symbol, (0I, 18I), (0I, 19I)) + (TokenType.Keyword, (0I, 20I), (0I, 24I)) + (TokenType.Symbol, (1I, 0I), (1I, 1I)) + (TokenType.Symbol, (1I, 2I), (1I, 3I)) + (TokenType.Keyword, (1I, 3I), (1I, 7I)) + (TokenType.Symbol, (1I, 7I), (1I, 8I)) + (TokenType.Keyword, (1I, 9I), (1I, 14I)) + (TokenType.Symbol, (1I, 14I), (1I, 15I)) + (TokenType.Symbol, (1I, 16I), (1I, 18I)) + (TokenType.Keyword, (1I, 19I), (1I, 23I)) ] ("match Stdlib.Result.Result.Ok(5L) with\n| Ok(5L) -> true\n| Error(e) -> false" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 5L)) - (TokenType.ModuleName, (0L, 6L), (0L, 12L)) - (TokenType.ModuleName, (0L, 13L), (0L, 19L)) - (TokenType.TypeName, (0L, 20L), (0L, 26L)) - (TokenType.Symbol, (0L, 26L), (0L, 27L)) - (TokenType.EnumMember, (0L, 27L), (0L, 29L)) - (TokenType.Number, (0L, 30L), (0L, 31L)) - (TokenType.Symbol, (0L, 31L), (0L, 32L)) - (TokenType.Keyword, (0L, 34L), (0L, 38L)) - (TokenType.Symbol, (1L, 0L), (1L, 1L)) - (TokenType.EnumMember, (1L, 2L), (1L, 4L)) - (TokenType.Number, (1L, 5L), (1L, 6L)) - (TokenType.Symbol, (1L, 6L), (1L, 7L)) - (TokenType.Symbol, (1L, 9L), (1L, 11L)) - (TokenType.Keyword, (1L, 12L), (1L, 16L)) - (TokenType.Symbol, (2L, 0L), (2L, 1L)) - (TokenType.EnumMember, (2L, 2L), (2L, 7L)) - (TokenType.VariableName, (2L, 8L), (2L, 9L)) - (TokenType.Symbol, (2L, 11L), (2L, 13L)) - (TokenType.Keyword, (2L, 14L), (2L, 19L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 5I)) + (TokenType.ModuleName, (0I, 6I), (0I, 12I)) + (TokenType.ModuleName, (0I, 13I), (0I, 19I)) + (TokenType.TypeName, (0I, 20I), (0I, 26I)) + (TokenType.Symbol, (0I, 26I), (0I, 27I)) + (TokenType.EnumMember, (0I, 27I), (0I, 29I)) + (TokenType.Number, (0I, 30I), (0I, 31I)) + (TokenType.Symbol, (0I, 31I), (0I, 32I)) + (TokenType.Keyword, (0I, 34I), (0I, 38I)) + (TokenType.Symbol, (1I, 0I), (1I, 1I)) + (TokenType.EnumMember, (1I, 2I), (1I, 4I)) + (TokenType.Number, (1I, 5I), (1I, 6I)) + (TokenType.Symbol, (1I, 6I), (1I, 7I)) + (TokenType.Symbol, (1I, 9I), (1I, 11I)) + (TokenType.Keyword, (1I, 12I), (1I, 16I)) + (TokenType.Symbol, (2I, 0I), (2I, 1I)) + (TokenType.EnumMember, (2I, 2I), (2I, 7I)) + (TokenType.VariableName, (2I, 8I), (2I, 9I)) + (TokenType.Symbol, (2I, 11I), (2I, 13I)) + (TokenType.Keyword, (2I, 14I), (2I, 19I)) ] ("match x with\n| 1L | 2L | 3L -> true \n| _ -> false" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 5L)) - (TokenType.VariableName, (0L, 6L), (0L, 7L)) - (TokenType.Keyword, (0L, 8L), (0L, 12L)) - (TokenType.Symbol, (1L, 0L), (1L, 1L)) - (TokenType.Number, (1L, 2L), (1L, 3L)) - (TokenType.Symbol, (1L, 3L), (1L, 4L)) + [ (TokenType.Keyword, (0I, 0I), (0I, 5I)) + (TokenType.VariableName, (0I, 6I), (0I, 7I)) + (TokenType.Keyword, (0I, 8I), (0I, 12I)) + (TokenType.Symbol, (1I, 0I), (1I, 1I)) + (TokenType.Number, (1I, 2I), (1I, 3I)) + (TokenType.Symbol, (1I, 3I), (1I, 4I)) //TODO missing symbol - (TokenType.Number, (1L, 7L), (1L, 8L)) - (TokenType.Symbol, (1L, 8L), (1L, 9L)) + (TokenType.Number, (1I, 7I), (1I, 8I)) + (TokenType.Symbol, (1I, 8I), (1I, 9I)) //TODO missing symbol - (TokenType.Number, (1L, 12L), (1L, 13L)) - (TokenType.Symbol, (1L, 13L), (1L, 14L)) - (TokenType.Symbol, (1L, 15L), (1L, 17L)) - (TokenType.Keyword, (1L, 18L), (1L, 22L)) - (TokenType.Symbol, (2L, 0L), (2L, 1L)) - (TokenType.VariableName, (2L, 2L), (2L, 3L)) - (TokenType.Symbol, (2L, 4L), (2L, 6L)) - (TokenType.Keyword, (2L, 7L), (2L, 12L)) ] + (TokenType.Number, (1I, 12I), (1I, 13I)) + (TokenType.Symbol, (1I, 13I), (1I, 14I)) + (TokenType.Symbol, (1I, 15I), (1I, 17I)) + (TokenType.Keyword, (1I, 18I), (1I, 22I)) + (TokenType.Symbol, (2I, 0I), (2I, 1I)) + (TokenType.VariableName, (2I, 2I), (2I, 3I)) + (TokenType.Symbol, (2I, 4I), (2I, 6I)) + (TokenType.Keyword, (2I, 7I), (2I, 12I)) ] ("Builtin.printLine \"hey\"\n0L" |> tokenize) = - [ (TokenType.ModuleName, (0L, 0L), (0L, 7L)) - (TokenType.FunctionName, (0L, 8L), (0L, 17L)) - (TokenType.Symbol, (0L, 18L), (0L, 19L)) - (TokenType.String, (0L, 19L), (0L, 22L)) - (TokenType.Symbol, (0L, 22L), (0L, 23L)) - (TokenType.Number, (1L, 0L), (1L, 1L)) - (TokenType.Symbol, (1L, 1L), (1L, 2L)) ] + [ (TokenType.ModuleName, (0I, 0I), (0I, 7I)) + (TokenType.FunctionName, (0I, 8I), (0I, 17I)) + (TokenType.Symbol, (0I, 18I), (0I, 19I)) + (TokenType.String, (0I, 19I), (0I, 22I)) + (TokenType.Symbol, (0I, 22I), (0I, 23I)) + (TokenType.Number, (1I, 0I), (1I, 1I)) + (TokenType.Symbol, (1I, 1I), (1I, 2I)) ] module TokenizeModuleDeclaration = ("module MyModule =\n type ID = Int64" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 6L)) - (TokenType.ModuleName, (0L, 7L), (0L, 15L)) - (TokenType.Keyword, (1L, 2L), (1L, 6L)) - (TokenType.TypeName, (1L, 7L), (1L, 9L)) - (TokenType.Symbol, (1L, 10L), (1L, 11L)) - (TokenType.TypeName, (1L, 12L), (1L, 17L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 6I)) + (TokenType.ModuleName, (0I, 7I), (0I, 15I)) + (TokenType.Keyword, (1I, 2I), (1I, 6I)) + (TokenType.TypeName, (1I, 7I), (1I, 9I)) + (TokenType.Symbol, (1I, 10I), (1I, 11I)) + (TokenType.TypeName, (1I, 12I), (1I, 17I)) ] ("""module MyModule = type ID = Int64 @@ -897,31 +897,31 @@ module TokenizeModuleDeclaration = val x = 100L 1L""" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 6L)) - (TokenType.ModuleName, (0L, 7L), (0L, 15L)) - (TokenType.Keyword, (1L, 2L), (1L, 6L)) - (TokenType.TypeName, (1L, 7L), (1L, 9L)) - (TokenType.Symbol, (1L, 10L), (1L, 11L)) - (TokenType.TypeName, (1L, 12L), (1L, 17L)) - (TokenType.Keyword, (2L, 2L), (2L, 5L)) - (TokenType.FunctionName, (2L, 6L), (2L, 10L)) - (TokenType.Symbol, (2L, 11L), (2L, 12L)) - (TokenType.ParameterName, (2L, 12L), (2L, 13L)) - (TokenType.Symbol, (2L, 13L), (2L, 14L)) - (TokenType.TypeName, (2L, 15L), (2L, 20L)) - (TokenType.Symbol, (2L, 20L), (2L, 21L)) - (TokenType.Symbol, (2L, 21L), (2L, 22L)) - (TokenType.TypeName, (2L, 23L), (2L, 28L)) - (TokenType.Symbol, (2L, 29L), (2L, 30L)) - (TokenType.Number, (2L, 31L), (2L, 32L)) - (TokenType.Symbol, (2L, 32L), (2L, 33L)) - (TokenType.Keyword, (3L, 2L), (3L, 5L)) - (TokenType.VariableName, (3L, 6L), (3L, 7L)) - (TokenType.Symbol, (3L, 8L), (3L, 9L)) - (TokenType.Number, (3L, 10L), (3L, 13L)) - (TokenType.Symbol, (3L, 13L), (3L, 14L)) - (TokenType.Number, (4L, 2L), (4L, 3L)) - (TokenType.Symbol, (4L, 3L), (4L, 4L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 6I)) + (TokenType.ModuleName, (0I, 7I), (0I, 15I)) + (TokenType.Keyword, (1I, 2I), (1I, 6I)) + (TokenType.TypeName, (1I, 7I), (1I, 9I)) + (TokenType.Symbol, (1I, 10I), (1I, 11I)) + (TokenType.TypeName, (1I, 12I), (1I, 17I)) + (TokenType.Keyword, (2I, 2I), (2I, 5I)) + (TokenType.FunctionName, (2I, 6I), (2I, 10I)) + (TokenType.Symbol, (2I, 11I), (2I, 12I)) + (TokenType.ParameterName, (2I, 12I), (2I, 13I)) + (TokenType.Symbol, (2I, 13I), (2I, 14I)) + (TokenType.TypeName, (2I, 15I), (2I, 20I)) + (TokenType.Symbol, (2I, 20I), (2I, 21I)) + (TokenType.Symbol, (2I, 21I), (2I, 22I)) + (TokenType.TypeName, (2I, 23I), (2I, 28I)) + (TokenType.Symbol, (2I, 29I), (2I, 30I)) + (TokenType.Number, (2I, 31I), (2I, 32I)) + (TokenType.Symbol, (2I, 32I), (2I, 33I)) + (TokenType.Keyword, (3I, 2I), (3I, 5I)) + (TokenType.VariableName, (3I, 6I), (3I, 7I)) + (TokenType.Symbol, (3I, 8I), (3I, 9I)) + (TokenType.Number, (3I, 10I), (3I, 13I)) + (TokenType.Symbol, (3I, 13I), (3I, 14I)) + (TokenType.Number, (4I, 2I), (4I, 3I)) + (TokenType.Symbol, (4I, 3I), (4I, 4I)) ] ("""module MyModule1 = @@ -929,11 +929,11 @@ module TokenizeModuleDeclaration = module MyModule3 = 1L""" |> tokenize) = - [ (TokenType.Keyword, (0L, 0L), (0L, 6L)) - (TokenType.ModuleName, (0L, 7L), (0L, 16L)) - (TokenType.Keyword, (1L, 2L), (1L, 8L)) - (TokenType.ModuleName, (1L, 9L), (1L, 18L)) - (TokenType.Keyword, (2L, 4L), (2L, 10L)) - (TokenType.ModuleName, (2L, 11L), (2L, 20L)) - (TokenType.Number, (3L, 6L), (3L, 7L)) - (TokenType.Symbol, (3L, 7L), (3L, 8L)) ] + [ (TokenType.Keyword, (0I, 0I), (0I, 6I)) + (TokenType.ModuleName, (0I, 7I), (0I, 16I)) + (TokenType.Keyword, (1I, 2I), (1I, 8I)) + (TokenType.ModuleName, (1I, 9I), (1I, 18I)) + (TokenType.Keyword, (2I, 4I), (2I, 10I)) + (TokenType.ModuleName, (2I, 11I), (2I, 20I)) + (TokenType.Number, (3I, 6I), (3I, 7I)) + (TokenType.Symbol, (3I, 7I), (3I, 8I)) ] diff --git a/backend/tests/Tests/HttpClient.Tests.fs b/backend/tests/Tests/HttpClient.Tests.fs index c4aa0472f8..0cdb5c700b 100644 --- a/backend/tests/Tests/HttpClient.Tests.fs +++ b/backend/tests/Tests/HttpClient.Tests.fs @@ -95,13 +95,13 @@ module Internal = module Test = type PTTest = - { name : string; lineNumber : int64; actual : PT.Expr; expected : PT.Expr } + { name : string; lineNumber : bigint; actual : PT.Expr; expected : PT.Expr } let fromDT (d : RT.Dval) : PTTest = match d with | RT.DRecord(_, _, _, fields) -> { name = fields |> D.field "name" |> D.string - lineNumber = fields |> D.field "lineNumber" |> D.int64 + lineNumber = fields |> D.field "lineNumber" |> D.darkInt actual = fields |> D.field "actual" |> PT2DT.Expr.fromDT expected = fields |> D.field "expected" |> PT2DT.Expr.fromDT } | _ -> Exception.raiseInternal "Invalid Test" [] diff --git a/packages/darklang/cli/packages/errors.dark b/packages/darklang/cli/packages/errors.dark index 3bf045908d..38d0acba23 100644 --- a/packages/darklang/cli/packages/errors.dark +++ b/packages/darklang/cli/packages/errors.dark @@ -31,8 +31,8 @@ let reportUnresolvedNames notFoundNames |> Stdlib.List.iter (fun (range, originalName, _err) -> - let lineNum = (range.start.row + 1L) |> Stdlib.Int64.toString - let colNum = range.start.column |> Stdlib.Int64.toString + let lineNum = (range.start.row + 1I) |> Stdlib.Int.toString + let colNum = range.start.column |> Stdlib.Int.toString let nameStr = Stdlib.String.join originalName "." Stdlib.printLine @@ -46,8 +46,8 @@ let reportUnresolvedNames invalidNames |> Stdlib.List.iter (fun (range, originalName, _err) -> - let lineNum = (range.start.row + 1L) |> Stdlib.Int64.toString - let colNum = range.start.column |> Stdlib.Int64.toString + let lineNum = (range.start.row + 1I) |> Stdlib.Int.toString + let colNum = range.start.column |> Stdlib.Int.toString let nameStr = Stdlib.String.join originalName "." Stdlib.printLine diff --git a/packages/darklang/cli/packages/fn.dark b/packages/darklang/cli/packages/fn.dark index ab411721e4..f572536a2c 100644 --- a/packages/darklang/cli/packages/fn.dark +++ b/packages/darklang/cli/packages/fn.dark @@ -136,7 +136,7 @@ let createFnInline | Some note -> note | None -> "Make sure your syntax is correct." [ Colors.error "Failed to parse function definition" - $" at line {Stdlib.Int64.toString (r.start.row + 1L)}, column {Stdlib.Int64.toString (r.start.column + 1L)}" + $" at line {Stdlib.Int.toString (r.start.row + 1I)}, column {Stdlib.Int.toString (r.start.column + 1I)}" detail ] |> Stdlib.printLines state diff --git a/packages/darklang/cli/packages/type.dark b/packages/darklang/cli/packages/type.dark index d3bcce59b6..e56b0a7d48 100644 --- a/packages/darklang/cli/packages/type.dark +++ b/packages/darklang/cli/packages/type.dark @@ -31,14 +31,14 @@ let execute (state: Cli.AppState) (args: List) : Cli.AppState = "" "Examples:" " type Status = | Active | Inactive" - " type User = { name: String; age: Int64 }" + " type User = { name: String; age: Int }" " type Result = | Ok of String | Error of String" "" " # Multi-line definition via stdin (run from shell, not the REPL):" " ./scripts/run-cli type User - <<'EOF'" " {" " name: String" - " age: Int64" + " age: Int" " email: String" " }" " EOF" @@ -139,7 +139,7 @@ let createTypeInline | Some note -> note | None -> "Make sure your syntax is correct." [ Colors.error "Failed to parse type definition" - $" at line {Stdlib.Int64.toString (r.start.row + 1L)}, column {Stdlib.Int64.toString (r.start.column + 1L)}" + $" at line {Stdlib.Int.toString (r.start.row + 1I)}, column {Stdlib.Int.toString (r.start.column + 1I)}" detail ] |> Stdlib.printLines state @@ -149,7 +149,7 @@ let createTypeInline "" "Make sure your syntax is correct. Examples:" " type Status = | Active | Inactive" - " type User = { name: String; age: Int64 }" + " type User = { name: String; age: Int }" "" ] |> Stdlib.printLines state @@ -175,7 +175,7 @@ let help (state: Cli.AppState) : Cli.AppState = " type Result = | Ok of String | Error of String" "" " # Record type:" - " type User = { name: String; age: Int64 }" + " type User = { name: String; age: Int }" "" " # Type alias:" " type UserId = Uuid" @@ -184,7 +184,7 @@ let help (state: Cli.AppState) : Cli.AppState = " ./scripts/run-cli type User - <<'EOF'" " {" " name: String" - " age: Int64" + " age: Int" " email: String" " }" " EOF" diff --git a/packages/darklang/cli/packages/value.dark b/packages/darklang/cli/packages/value.dark index 76570f4e9c..4ab392c5eb 100644 --- a/packages/darklang/cli/packages/value.dark +++ b/packages/darklang/cli/packages/value.dark @@ -139,7 +139,7 @@ let createValueInline | Some note -> note | None -> "Make sure your syntax is correct." [ Colors.error "Failed to parse value expression" - $" at line {Stdlib.Int64.toString (r.start.row + 1L)}, column {Stdlib.Int64.toString (r.start.column + 1L)}" + $" at line {Stdlib.Int.toString (r.start.row + 1I)}, column {Stdlib.Int.toString (r.start.column + 1I)}" detail ] |> Stdlib.printLines state diff --git a/packages/darklang/cli/utils/syntaxHighlighting.dark b/packages/darklang/cli/utils/syntaxHighlighting.dark index 48e60450f4..05a0f3ad29 100644 --- a/packages/darklang/cli/utils/syntaxHighlighting.dark +++ b/packages/darklang/cli/utils/syntaxHighlighting.dark @@ -50,11 +50,9 @@ let highlightLine (line: String) (lineTokens: List Stdlib.List.fold line (fun currentLine (pos, colorCode) -> // validate insertion position is within current line bounds - // pos comes from Int64 source-position fields; bridge to Int for String fns - let posInt = Stdlib.Int.fromInt64 pos - if posInt >= 0I && posInt <= Stdlib.String.length currentLine then - let before = Stdlib.String.slice currentLine 0I posInt // everything before the position - let after = Stdlib.String.dropFirst currentLine posInt // everything after the position + if pos >= 0I && pos <= Stdlib.String.length currentLine then + let before = Stdlib.String.slice currentLine 0I pos // everything before the position + let after = Stdlib.String.dropFirst currentLine pos // everything after the position // insert color code at the position before ++ colorCode ++ after else @@ -78,7 +76,7 @@ let applyTokenColors // For the current line, find all tokens that belong to it by filtering tokens where the row matches the current line index let lineTokens = sortedTokens - |> Stdlib.List.filter (fun token -> Stdlib.Int.fromInt64 token.range.start.row == lineIndex) + |> Stdlib.List.filter (fun token -> token.range.start.row == lineIndex) if Stdlib.List.isEmpty lineTokens then line diff --git a/packages/darklang/languageTools/lsp-server/cursorPosition.dark b/packages/darklang/languageTools/lsp-server/cursorPosition.dark index 86d1190aef..2a1744a188 100644 --- a/packages/darklang/languageTools/lsp-server/cursorPosition.dark +++ b/packages/darklang/languageTools/lsp-server/cursorPosition.dark @@ -43,19 +43,19 @@ let wordUnderCursor (text: String) (cursorPosition: LanguageServerProtocol.Position.Position) : String = - let lineNum = cursorPosition.line |> Stdlib.Int64.fromUInt64 - let charPos = cursorPosition.character |> Stdlib.Int64.fromUInt64 + let lineNum = cursorPosition.line |> Stdlib.Int.fromUInt64 + let charPos = cursorPosition.character |> Stdlib.Int.fromUInt64 match (lineNum, charPos) with | (Some line, Some character) -> let currentLine = text |> Stdlib.String.split "\n" - |> Stdlib.List.getAt (Stdlib.Int.fromInt64 line) + |> Stdlib.List.getAt line |> Stdlib.Option.withDefault "" let lineToCursor = - currentLine |> Stdlib.String.slice 0I (Stdlib.Int.fromInt64 character) + currentLine |> Stdlib.String.slice 0I character lineToCursor |> Stdlib.String.split " " @@ -69,8 +69,8 @@ let checkIfPositionWithinRange (position: LanguageServerProtocol.Position.Position) (range: WrittenTypes.Range) : Stdlib.Option.Option = - let line = position.line |> Stdlib.Int64.fromUInt64 - let character = position.character |> Stdlib.Int64.fromUInt64 + let line = position.line |> Stdlib.Int.fromUInt64 + let character = position.character |> Stdlib.Int.fromUInt64 let rangeStartLine = range.start.row let rangeEndLine = range.end_.row @@ -94,7 +94,7 @@ let isLineNumberInRange (position: LanguageServerProtocol.Position.Position) (range: WrittenTypes.Range) : Bool = - match position.line |> Stdlib.Int64.fromUInt64 with + match position.line |> Stdlib.Int.fromUInt64 with | Some line -> let rangeStartLine = range.start.row let rangeEndLine = range.end_.row diff --git a/packages/darklang/languageTools/lsp-server/handleIncomingMessage.dark b/packages/darklang/languageTools/lsp-server/handleIncomingMessage.dark index 17be56b70b..b0a6b11370 100644 --- a/packages/darklang/languageTools/lsp-server/handleIncomingMessage.dark +++ b/packages/darklang/languageTools/lsp-server/handleIncomingMessage.dark @@ -6,22 +6,22 @@ let convertParserRangeToLspRange : LanguageServerProtocol.Range.Range = let lineStart = range.start.row - |> Stdlib.UInt64.fromInt64 + |> Stdlib.Int.toUInt64 |> Stdlib.Option.withDefault 0UL let characterStart = range.start.column - |> Stdlib.UInt64.fromInt64 + |> Stdlib.Int.toUInt64 |> Stdlib.Option.withDefault 0UL let lineEnd = range.end_.row - |> Stdlib.UInt64.fromInt64 + |> Stdlib.Int.toUInt64 |> Stdlib.Option.withDefault 0UL let characterEnd = range.end_.column - |> Stdlib.UInt64.fromInt64 + |> Stdlib.Int.toUInt64 |> Stdlib.Option.withDefault 0UL LanguageServerProtocol.Range.Range diff --git a/packages/darklang/languageTools/lsp-server/hover.dark b/packages/darklang/languageTools/lsp-server/hover.dark index 3d743b270d..ab88b48a12 100644 --- a/packages/darklang/languageTools/lsp-server/hover.dark +++ b/packages/darklang/languageTools/lsp-server/hover.dark @@ -10,12 +10,12 @@ let getTextAtRange let endColumn = range.end_.column let lines = text |> Stdlib.String.split "\n" - let textLines = lines |> Stdlib.List.getAt (Stdlib.Int.fromInt64 startLine) + let textLines = lines |> Stdlib.List.getAt startLine match textLines with | Some line -> line - |> Stdlib.String.slice (Stdlib.Int.fromInt64 startColumn) (Stdlib.Int.fromInt64 endColumn) + |> Stdlib.String.slice startColumn endColumn |> Stdlib.Option.Option.Some | None -> Stdlib.Option.Option.None diff --git a/packages/darklang/languageTools/lsp-server/semanticTokens.dark b/packages/darklang/languageTools/lsp-server/semanticTokens.dark index 0593f7fe64..3282f9706a 100644 --- a/packages/darklang/languageTools/lsp-server/semanticTokens.dark +++ b/packages/darklang/languageTools/lsp-server/semanticTokens.dark @@ -66,13 +66,13 @@ module EncodeSemanticTokens = let aStart = a.range.start let bStart = b.range.start - if Stdlib.Int64.lessThan aStart.row bStart.row then + if Stdlib.Int.lessThan aStart.row bStart.row then -1I - elif Stdlib.Int64.greaterThan aStart.row bStart.row then + elif Stdlib.Int.greaterThan aStart.row bStart.row then 1I - else if Stdlib.Int64.lessThan aStart.column bStart.column then + else if Stdlib.Int.lessThan aStart.column bStart.column then -1I - else if Stdlib.Int64.greaterThan aStart.column bStart.column then + else if Stdlib.Int.greaterThan aStart.column bStart.column then 1I else 0I) @@ -82,7 +82,7 @@ module EncodeSemanticTokens = | Ok sorted -> sorted |> (Stdlib.List.fold - (([], Parser.Point { row = 0L; column = 0L })) + (([], Parser.Point { row = 0I; column = 0I })) (fun acc token -> let (tokensSoFar, startOfLastToken) = acc @@ -91,11 +91,11 @@ module EncodeSemanticTokens = let tokenLength = token.range.end_.column - token.range.start.column let deltaStartValue = - if lineDiff == 0L then columnDiff else token.range.start.column + if lineDiff == 0I then columnDiff else token.range.start.column - let maybeDeltaLine = lineDiff |> Stdlib.UInt64.fromInt64 - let maybeDeltaStart = deltaStartValue |> Stdlib.UInt64.fromInt64 - let maybeLength = tokenLength |> Stdlib.UInt64.fromInt64 + let maybeDeltaLine = lineDiff |> Stdlib.Int.toUInt64 + let maybeDeltaStart = deltaStartValue |> Stdlib.Int.toUInt64 + let maybeLength = tokenLength |> Stdlib.Int.toUInt64 match (maybeDeltaLine, maybeDeltaStart, maybeLength) with | (Some deltaLine, Some deltaStart, Some length) -> diff --git a/packages/darklang/languageTools/parser/cliScript.dark b/packages/darklang/languageTools/parser/cliScript.dark index e4309603da..411cccaf92 100644 --- a/packages/darklang/languageTools/parser/cliScript.dark +++ b/packages/darklang/languageTools/parser/cliScript.dark @@ -4,8 +4,8 @@ module Darklang.LanguageTools.Parser.CliScript /// Location of an unparseable subtree in the source. type Unparseable = { text: String - line: Int64 - column: Int64 + line: Int + column: Int note: Stdlib.Option.Option } @@ -30,7 +30,7 @@ module ParseError = match u.note with | Some n -> $": {n}" | None -> "" - $"Parse error at line {Stdlib.Int64.toString u.line}, column {Stdlib.Int64.toString u.column}: unexpected '{u.text}'{noteText}" + $"Parse error at line {Stdlib.Int.toString u.line}, column {Stdlib.Int.toString u.column}: unexpected '{u.text}'{noteText}" | Other msg -> msg @@ -67,7 +67,7 @@ let parseDecls let u = Unparseable { text = first.source.text - line = Stdlib.Int64.add first.source.range.start.row 1L + line = first.source.range.start.row + 1I column = first.source.range.start.column note = first.note } Stdlib.Result.Result.Error(ParseError.Unparseable u) diff --git a/packages/darklang/languageTools/parser/core.dark b/packages/darklang/languageTools/parser/core.dark index 089b3c9347..04042874a4 100644 --- a/packages/darklang/languageTools/parser/core.dark +++ b/packages/darklang/languageTools/parser/core.dark @@ -4,7 +4,7 @@ module Darklang.LanguageTools.Parser // TODO: these should be UInts of some size // (UInt8 might even be enough - how many lines are over 255chars?) -type Point = { row: Int64; column: Int64 } +type Point = { row: Int; column: Int } type Range = { start: Point; end_: Point } diff --git a/packages/internal/tests.dark b/packages/internal/tests.dark index fc71f86acc..b43df465a9 100644 --- a/packages/internal/tests.dark +++ b/packages/internal/tests.dark @@ -2,13 +2,13 @@ module Darklang.Internal.Test type WTTest = { name: String - lineNumber: Int64 + lineNumber: Int actual: LanguageTools.WrittenTypes.Expr expected: LanguageTools.WrittenTypes.Expr } type PTTest = { name: String - lineNumber: Int64 + lineNumber: Int actual: LanguageTools.ProgramTypes.Expr expected: LanguageTools.ProgramTypes.Expr } From ccfc0c43587f97e35c14ab3252411a36a8cc25cc Mon Sep 17 00:00:00 2001 From: OceanOak Date: Thu, 18 Jun 2026 13:44:05 +0000 Subject: [PATCH 37/61] Migrate CLI exit codes from Int64 to Int --- backend/src/Cli/Cli.fs | 1 + packages/darklang/cli/core.dark | 8 ++++---- packages/darklang/cli/tests/tests.dark | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/backend/src/Cli/Cli.fs b/backend/src/Cli/Cli.fs index c7ef18cc8b..91a8a12fa6 100644 --- a/backend/src/Cli/Cli.fs +++ b/backend/src/Cli/Cli.fs @@ -178,6 +178,7 @@ let main (args : string[]) = 1 | Ok(RT.DInt64 i) -> (int i) + | Ok(RT.DInt i) -> (int (RT.DarkInt.toBigInt i)) | Ok dval -> let state = state cliPackageManager let output = (Exe.dvalToRepr state dval).Result diff --git a/packages/darklang/cli/core.dark b/packages/darklang/cli/core.dark index 68433744ba..b44a128a07 100644 --- a/packages/darklang/cli/core.dark +++ b/packages/darklang/cli/core.dark @@ -700,13 +700,13 @@ module Update = updateAppState state msg -let runInteractiveLoop (state: AppState) : Int64 = +let runInteractiveLoop (state: AppState) : Int = if state.isExiting then // Clear status bar and prompt line before exiting StatusBar.clear () // Move to column 1, clear entire line, then newline for clean shell prompt Stdlib.print (Colors.moveCursorToColumn 1I ++ "\u001b[2K" ++ "\n") - 0L + 0I else let tLoopStart = if state.telemetryEnabled then Telemetry.now () else 0L if state.telemetryEnabled then @@ -866,7 +866,7 @@ let parseBranchFlag (args: List) : (Stdlib.Option.Option * List) : Int64 = +let executeCliCommand (args: List) : Int = let (branchOverride, remainingArgs) = parseBranchFlag args let baseState = initState () let initialState = @@ -901,4 +901,4 @@ let executeCliCommand (args: List) : Int64 = | SubApp _ -> StatusBar.init () runInteractiveLoop resultState - | _ -> 0L + | _ -> 0I diff --git a/packages/darklang/cli/tests/tests.dark b/packages/darklang/cli/tests/tests.dark index 3ea7b833c9..a926e7e906 100644 --- a/packages/darklang/cli/tests/tests.dark +++ b/packages/darklang/cli/tests/tests.dark @@ -187,7 +187,7 @@ type TestSummary = // Sequential test execution - proven to be ~30-50% faster than parallel for CLI tests // due to process startup overhead and resource contention -let runAllTests (): Int64 = +let runAllTests (): Int = let tests = allTests () Stdlib.printLine "" @@ -230,7 +230,7 @@ let runAllTests (): Int64 = if finalSummary.failedTests == 0I then Stdlib.printLine "🎉 All tests passed!" - 0L + 0I else Stdlib.printLine "🚨 Some tests failed!" if Stdlib.Bool.not (Stdlib.List.isEmpty finalSummary.failedTestNames) then @@ -238,4 +238,4 @@ let runAllTests (): Int64 = finalSummary.failedTestNames |> Stdlib.List.iter (fun testName -> Stdlib.printLine $" ✗ {testName}") - 1L + 1I From 41ad060d31e93463fc7d6fead26d11fd3096c619 Mon Sep 17 00:00:00 2001 From: OceanOak Date: Thu, 18 Jun 2026 13:51:55 +0000 Subject: [PATCH 38/61] Migrate telemetry timing from Int64 to Int --- backend/src/Builtins/Builtins.Time/Libs/Time.fs | 4 ++-- packages/darklang/cli/core.dark | 10 +++++----- packages/darklang/cli/telemetry.dark | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/backend/src/Builtins/Builtins.Time/Libs/Time.fs b/backend/src/Builtins/Builtins.Time/Libs/Time.fs index a3123bdc20..5602b24821 100644 --- a/backend/src/Builtins/Builtins.Time/Libs/Time.fs +++ b/backend/src/Builtins/Builtins.Time/Libs/Time.fs @@ -33,7 +33,7 @@ let fns () : List = { name = fn "timeNowMs" 0 typeParams = [] parameters = [ Param.make "unit" TUnit "" ] - returnType = TInt64 + returnType = TInt description = "Returns a monotonic timestamp in milliseconds. Useful for measuring " + "elapsed time between two calls (subtract start from end). The absolute " @@ -43,7 +43,7 @@ let fns () : List = | _, _, _, [ DUnit ] -> let ts = System.Diagnostics.Stopwatch.GetTimestamp() let ms = ts * 1000L / System.Diagnostics.Stopwatch.Frequency - DInt64 ms |> Ply + LibExecution.Dval.int (bigint ms) |> Ply | _ -> incorrectArgs ()) sqlSpec = NotYetImplemented previewable = Impure diff --git a/packages/darklang/cli/core.dark b/packages/darklang/cli/core.dark index b44a128a07..8531ac94bd 100644 --- a/packages/darklang/cli/core.dark +++ b/packages/darklang/cli/core.dark @@ -708,7 +708,7 @@ let runInteractiveLoop (state: AppState) : Int = Stdlib.print (Colors.moveCursorToColumn 1I ++ "\u001b[2K" ++ "\n") 0I else - let tLoopStart = if state.telemetryEnabled then Telemetry.now () else 0L + let tLoopStart = if state.telemetryEnabled then Telemetry.now () else 0I if state.telemetryEnabled then let _ = Builtin.interpreterStatsReset () () @@ -716,7 +716,7 @@ let runInteractiveLoop (state: AppState) : Int = // TODO: handle terminal resize and Unicode display width let location = locationStr state - let tHint = if state.telemetryEnabled then Telemetry.now () else 0L + let tHint = if state.telemetryEnabled then Telemetry.now () else 0I let inputStartColumn = Prompt.Display.calculateInputStartColumn location let hintCached = state.cachedHintInput == state.prompt.text @@ -742,7 +742,7 @@ let runInteractiveLoop (state: AppState) : Int = else (Stdlib.Int.divide (visualLength - 1I) terminalWidth) + 1I // Display current page - let tRender = if state.telemetryEnabled then Telemetry.now () else 0L + let tRender = if state.telemetryEnabled then Telemetry.now () else 0I match state.currentPage with | MainPrompt -> @@ -803,7 +803,7 @@ let runInteractiveLoop (state: AppState) : Int = Telemetry.log "preInput" tLoopStart // Read keystroke input - let tReadKey = if state.telemetryEnabled then Telemetry.now () else 0L + let tReadKey = if state.telemetryEnabled then Telemetry.now () else 0I let keyInput = Stdlib.Cli.Stdin.readKey () // Process the key @@ -816,7 +816,7 @@ let runInteractiveLoop (state: AppState) : Int = Telemetry.logWithContext "update" tUpdate [("char", keyInput.keyChar)] let loopWorkMs = (Telemetry.elapsedMs tLoopStart) - (Telemetry.elapsedMs tReadKey) let interpStats = Builtin.interpreterStatsGet () - Telemetry.logWithContext "loopWork" tLoopStart [("workMs", Stdlib.Int64.toString loopWorkMs); ("interp", interpStats)] + Telemetry.logWithContext "loopWork" tLoopStart [("workMs", Stdlib.Int.toString loopWorkMs); ("interp", interpStats)] runInteractiveLoop { newState with previousRenderedRows = renderedRows; cachedHintInput = state.prompt.text; cachedHintValue = hint; cachedStatusBar = statusBar; cachedStatusBarBranch = state.currentBranchId } diff --git a/packages/darklang/cli/telemetry.dark b/packages/darklang/cli/telemetry.dark index 5f78170760..c0e2019fcd 100644 --- a/packages/darklang/cli/telemetry.dark +++ b/packages/darklang/cli/telemetry.dark @@ -15,17 +15,17 @@ let logFilePath: String = (Builtin.cliGetLogDir ()) ++ "/telemetry.jsonl" /// Returns monotonic millisecond timestamp (only differences are meaningful) -let now () : Int64 = Builtin.timeNowMs () +let now () : Int = Builtin.timeNowMs () /// Compute elapsed ms between a start timestamp and now -let elapsedMs (startMs: Int64) : Int64 = +let elapsedMs (startMs: Int) : Int = (now ()) - startMs /// Write a single telemetry event line to the log file. /// Format: {"event":"