diff --git a/backend/src/Builtins/Builtins.Cli/Libs/Execution.fs b/backend/src/Builtins/Builtins.Cli/Libs/Execution.fs index d58e55dad8..22bfdf15c1 100644 --- a/backend/src/Builtins/Builtins.Cli/Libs/Execution.fs +++ b/backend/src/Builtins/Builtins.Cli/Libs/Execution.fs @@ -73,13 +73,13 @@ let prepareProcessCommand (command : string) : string * string = /// Creates an ExecutionOutcome record let createExecutionOutcome - (exitCode : int64) + (exitCode : int) (stdout : string) (stderr : string) : Dval = let typeName = executionOutcomeTypeName () let fields = - [ "exitCode", DInt64 exitCode + [ "exitCode", Dval.int (bigint exitCode) "stdout", DString stdout "stderr", DString stderr ] DRecord(typeName, typeName, [], Map fields) @@ -223,7 +223,7 @@ let fns () : List = description = "Spawns an interactive process and returns a handle ID" typeParams = [] parameters = [ Param.make "command" TString "The command to execute" ] - returnType = TInt64 + returnType = TInt fn = function | _, _, _, [ DString command ] -> @@ -256,7 +256,7 @@ let fns () : List = ErrorBuffer = "" } processHandles.TryAdd(processId, processInfo) |> ignore - DInt64 processId |> Ply + Dval.int (bigint processId) |> Ply | _ -> incorrectArgs () sqlSpec = NotQueryable previewable = Impure @@ -268,7 +268,7 @@ let fns () : List = description = "Send input to process and read available output (non-blocking)" typeParams = [] parameters = - [ Param.make "processId" TInt64 "The process handle ID" + [ Param.make "processId" TInt "The process handle ID" Param.make "input" TString "The input to send (empty string to just read)" ] returnType = let typeName = @@ -276,7 +276,8 @@ let fns () : List = TCustomType(NR.ok typeName, []) fn = function - | _, _, _, [ DInt64 processId; DString input ] -> + | _, vm, _, [ DInt processIdArg; DString input ] -> + let processId = intToInt64 vm processIdArg match processHandles.TryGetValue processId with | true, processInfo when not processInfo.Process.HasExited -> try @@ -361,9 +362,9 @@ let fns () : List = createExecutionOutcome exitCode (stdout.ToString()) (stderr.ToString()) |> Ply with ex -> - createExecutionOutcome -1L "" $"Process IO error: {ex.Message}" |> Ply + createExecutionOutcome -1 "" $"Process IO error: {ex.Message}" |> Ply | _ -> - createExecutionOutcome -1L "" "Process not found or has exited" |> Ply + createExecutionOutcome -1 "" "Process not found or has exited" |> Ply | _ -> incorrectArgs () sqlSpec = NotQueryable previewable = Impure @@ -374,14 +375,15 @@ let fns () : List = { name = fn "cliTerminateProcess" 0 description = "Terminates a spawned process and returns final output" typeParams = [] - parameters = [ Param.make "processId" TInt64 "The process handle ID" ] + parameters = [ Param.make "processId" TInt "The process handle ID" ] returnType = let typeName = FQTypeName.fqPackage (PackageRefs.Type.Stdlib.Cli.executionOutcome ()) TCustomType(NR.ok typeName, []) fn = function - | _, _, _, [ DInt64 processId ] -> + | _, vm, _, [ DInt processIdArg ] -> + let processId = intToInt64 vm processIdArg match processHandles.TryGetValue processId with | true, processInfo -> try @@ -412,12 +414,9 @@ let fns () : List = createExecutionOutcome exitCode finalStdout finalStderr |> Ply with ex -> processHandles.TryRemove processId |> ignore - createExecutionOutcome - -1L - "" - $"Process termination error: {ex.Message}" + createExecutionOutcome -1 "" $"Process termination error: {ex.Message}" |> Ply - | false, _ -> createExecutionOutcome -1L "" "Process not found" |> Ply + | false, _ -> createExecutionOutcome -1 "" "Process not found" |> Ply | _ -> incorrectArgs () sqlSpec = NotQueryable previewable = Impure diff --git a/backend/src/Builtins/Builtins.Cli/Libs/Posix.fs b/backend/src/Builtins/Builtins.Cli/Libs/Posix.fs index 082775afa3..c89a6cb843 100644 --- a/backend/src/Builtins/Builtins.Cli/Libs/Posix.fs +++ b/backend/src/Builtins/Builtins.Cli/Libs/Posix.fs @@ -477,7 +477,12 @@ let private posixErrorKT () = KTCustomType(posixErrorTypeName (), []) let private dPosixError (errno : int, msg : string) : Dval = let tn = posixErrorTypeName () - DRecord(tn, tn, [], Map [ "errno", DInt64(int64 errno); "message", DString msg ]) + DRecord( + tn, + tn, + [], + Map [ "errno", Dval.int (bigint errno); "message", DString msg ] + ) let fns () : List = [ { name = fn "posixGetcwd" 0 @@ -564,14 +569,14 @@ let fns () : List = typeParams = [] parameters = [ Param.make "path" TString "The directory path to create" - Param.make "mode" TInt64 "Permission bits (e.g. 493 for 0755)" ] + Param.make "mode" TInt "Permission bits (e.g. 493 for 0755)" ] returnType = TypeReference.result TUnit (posixErrorTypeRef ()) description = "Creates a directory via libc mkdir()" fn = (function - | state, _, _, [ DString path; DInt64 mode ] -> + | state, vm, _, [ DString path; DInt mode ] -> LibExecution.CapabilityCheck.requireFileReadWrite state.grantedCaps path - match Libc.mkdir path (int mode) with + match Libc.mkdir path (intToInt32 vm mode) with | Ok() -> Dval.resultOk KTUnit (posixErrorKT ()) DUnit |> Ply | Error e -> Dval.resultError KTUnit (posixErrorKT ()) (dPosixError e) |> Ply @@ -648,14 +653,14 @@ let fns () : List = typeParams = [] parameters = [ Param.make "path" TString "File path" - Param.make "mode" TInt64 "Permission bits (e.g. 493 for 0755)" ] + Param.make "mode" TInt "Permission bits (e.g. 493 for 0755)" ] returnType = TypeReference.result TUnit (posixErrorTypeRef ()) description = "Changes file permissions via libc chmod()" fn = (function - | state, _, _, [ DString path; DInt64 mode ] -> + | state, vm, _, [ DString path; DInt mode ] -> LibExecution.CapabilityCheck.requireFileReadWrite state.grantedCaps path - match Libc.chmod path (int mode) with + match Libc.chmod path (intToInt32 vm mode) with | Ok() -> Dval.resultOk KTUnit (posixErrorKT ()) DUnit |> Ply | Error e -> Dval.resultError KTUnit (posixErrorKT ()) (dPosixError e) |> Ply @@ -737,7 +742,7 @@ let fns () : List = TString "Prefix for the temp file path (e.g. \"/tmp/dark-\")" ] returnType = - TypeReference.result (TTuple(TInt64, TString, [])) (posixErrorTypeRef ()) + TypeReference.result (TTuple(TInt, TString, [])) (posixErrorTypeRef ()) description = "Creates a unique temp file via libc mkstemp(). Returns (fd, path)." fn = @@ -745,12 +750,12 @@ let fns () : List = | state, _, _, [ DString prefix ] -> LibExecution.CapabilityCheck.requireFileReadWrite state.grantedCaps prefix let resultOk = - Dval.resultOk (KTTuple(VT.int64, VT.string, [])) (posixErrorKT ()) + Dval.resultOk (KTTuple(VT.int, VT.string, [])) (posixErrorKT ()) let resultError = - Dval.resultError (KTTuple(VT.int64, VT.string, [])) (posixErrorKT ()) + Dval.resultError (KTTuple(VT.int, VT.string, [])) (posixErrorKT ()) match Libc.mkstemp prefix with | Ok(fd, path) -> - resultOk (DTuple(DInt64(int64 fd), DString path, [])) |> Ply + resultOk (DTuple(Dval.int (bigint fd), DString path, [])) |> Ply | Error e -> resultError (dPosixError e) |> Ply | _ -> incorrectArgs ()) sqlSpec = NotQueryable @@ -836,7 +841,7 @@ let fns () : List = Param.make "args" (TList TString) "Arguments to pass" ] returnType = TypeReference.result - (TTuple(TInt64, TString, [ TString ])) + (TTuple(TInt, TString, [ TString ])) (posixErrorTypeRef ()) description = "Spawns a child process, waits for it to finish, returns (exitCode, stdout, stderr)." @@ -845,11 +850,11 @@ let fns () : List = | state, _, _, [ DString program; DList(_, args) ] -> let resultOk = Dval.resultOk - (KTTuple(VT.int64, VT.string, [ VT.string ])) + (KTTuple(VT.int, VT.string, [ VT.string ])) (posixErrorKT ()) let resultError = Dval.resultError - (KTTuple(VT.int64, VT.string, [ VT.string ])) + (KTTuple(VT.int, VT.string, [ VT.string ])) (posixErrorKT ()) let argStrs = args @@ -862,7 +867,7 @@ let fns () : List = match Libc.spawnAndWait program argStrs with | Ok(exitCode, stdout, stderr) -> resultOk ( - DTuple(DInt64(int64 exitCode), DString stdout, [ DString stderr ]) + DTuple(Dval.int (bigint exitCode), DString stdout, [ DString stderr ]) ) |> Ply | Error e -> resultError (dPosixError e) |> Ply @@ -878,23 +883,23 @@ let fns () : List = parameters = [ Param.make "program" TString "Path to the executable" Param.make "args" (TList TString) "Arguments to pass" - Param.make "timeoutMs" TInt64 "Timeout in milliseconds" ] + Param.make "timeoutMs" TInt "Timeout in milliseconds" ] returnType = TypeReference.result - (TTuple(TInt64, TString, [ TString ])) + (TTuple(TInt, TString, [ TString ])) (posixErrorTypeRef ()) description = "Spawns a child process with a timeout. Returns (exitCode, stdout, stderr) or Error on timeout." fn = (function - | state, _, _, [ DString program; DList(_, args); DInt64 timeoutMs ] -> + | state, vm, _, [ DString program; DList(_, args); DInt timeoutMs ] -> let resultOk = Dval.resultOk - (KTTuple(VT.int64, VT.string, [ VT.string ])) + (KTTuple(VT.int, VT.string, [ VT.string ])) (posixErrorKT ()) let resultError = Dval.resultError - (KTTuple(VT.int64, VT.string, [ VT.string ])) + (KTTuple(VT.int, VT.string, [ VT.string ])) (posixErrorKT ()) let argStrs = args @@ -904,10 +909,12 @@ let fns () : List = | _ -> incorrectArgs ()) // precise check: this exact program + args must be covered (gate only checked exec presence). LibExecution.CapabilityCheck.requireExec state.grantedCaps program argStrs - match Libc.spawnAndWaitWithTimeout program argStrs (int timeoutMs) with + match + Libc.spawnAndWaitWithTimeout program argStrs (intToInt32 vm timeoutMs) + with | Ok(exitCode, stdout, stderr) -> resultOk ( - DTuple(DInt64(int64 exitCode), DString stdout, [ DString stderr ]) + DTuple(Dval.int (bigint exitCode), DString stdout, [ DString stderr ]) ) |> Ply | Error e -> resultError (dPosixError e) |> Ply @@ -921,17 +928,17 @@ let fns () : List = { name = fn "posixKill" 0 typeParams = [] parameters = - [ Param.make "pid" TInt64 "Process ID" + [ Param.make "pid" TInt "Process ID" Param.make "signal" - TInt64 + TInt "Signal number (e.g. 9 for SIGKILL, 15 for SIGTERM)" ] returnType = TypeReference.result TUnit (posixErrorTypeRef ()) description = "Sends a signal to a process." fn = (function - | _, _, _, [ DInt64 pid; DInt64 signal ] -> - match Libc.kill (int pid) (int signal) with + | _, vm, _, [ DInt pid; DInt signal ] -> + match Libc.kill (intToInt32 vm pid) (intToInt32 vm signal) with | Ok() -> Dval.resultOk KTUnit (posixErrorKT ()) DUnit |> Ply | Error e -> Dval.resultError KTUnit (posixErrorKT ()) (dPosixError e) |> Ply @@ -945,17 +952,17 @@ let fns () : List = { name = fn "posixFdRead" 0 typeParams = [] parameters = - [ Param.make "fd" TInt64 "File descriptor to read from" - Param.make "count" TInt64 "Max bytes to read" ] + [ Param.make "fd" TInt "File descriptor to read from" + Param.make "count" TInt "Max bytes to read" ] returnType = TypeReference.result TBlob (posixErrorTypeRef ()) description = "Reads up to count bytes from a file descriptor into an ephemeral Blob." fn = (function - | _, _, _, [ DInt64 fd; DInt64 count ] -> + | _, vm, _, [ DInt fd; DInt count ] -> let resultOk = Dval.resultOk KTBlob (posixErrorKT ()) let resultError = Dval.resultError KTBlob (posixErrorKT ()) - match Libc.fdRead (int fd) (int count) with + match Libc.fdRead (intToInt32 vm fd) (intToInt32 vm count) with | Ok bytes -> resultOk (Blob.newEphemeral bytes) |> Ply | Error e -> resultError (dPosixError e) |> Ply | _ -> incorrectArgs ()) @@ -968,20 +975,20 @@ let fns () : List = { name = fn "posixFdWrite" 0 typeParams = [] parameters = - [ Param.make "fd" TInt64 "File descriptor to write to" + [ Param.make "fd" TInt "File descriptor to write to" Param.make "blob" TBlob "Bytes to write" ] - returnType = TypeReference.result TInt64 (posixErrorTypeRef ()) + returnType = TypeReference.result TInt (posixErrorTypeRef ()) description = "Writes bytes to a file descriptor. Returns bytes written." fn = (function - | state, _, _, [ DInt64 fd; DBlob ref ] -> + | state, vm, _, [ DInt fd; DBlob ref ] -> uply { let! bytes = Blob.readBytes state ref - match Libc.fdWrite (int fd) bytes with + match Libc.fdWrite (intToInt32 vm fd) bytes with | Ok n -> - return Dval.resultOk KTInt64 (posixErrorKT ()) (DInt64(int64 n)) + return Dval.resultOk KTInt (posixErrorKT ()) (Dval.int (bigint n)) | Error e -> - return Dval.resultError KTInt64 (posixErrorKT ()) (dPosixError e) + return Dval.resultError KTInt (posixErrorKT ()) (dPosixError e) } | _ -> incorrectArgs ()) sqlSpec = NotQueryable @@ -992,13 +999,13 @@ let fns () : List = { name = fn "posixFdClose" 0 typeParams = [] - parameters = [ Param.make "fd" TInt64 "File descriptor to close" ] + parameters = [ Param.make "fd" TInt "File descriptor to close" ] returnType = TypeReference.result TUnit (posixErrorTypeRef ()) description = "Closes a file descriptor." fn = (function - | _, _, _, [ DInt64 fd ] -> - match Libc.fdClose (int fd) with + | _, vm, _, [ DInt fd ] -> + match Libc.fdClose (intToInt32 vm fd) with | Ok() -> Dval.resultOk KTUnit (posixErrorKT ()) DUnit |> Ply | Error e -> Dval.resultError KTUnit (posixErrorKT ()) (dPosixError e) |> Ply @@ -1013,22 +1020,19 @@ let fns () : List = typeParams = [] parameters = [ Param.make "path" TString "File path to open" - Param.make "flags" TInt64 "Open flags (e.g. O_RDONLY, O_WRONLY | O_CREAT)" - Param.make - "mode" - TInt64 - "Permission bits for new files (e.g. 420 for 0644)" ] - returnType = TypeReference.result TInt64 (posixErrorTypeRef ()) + Param.make "flags" TInt "Open flags (e.g. O_RDONLY, O_WRONLY | O_CREAT)" + Param.make "mode" TInt "Permission bits for new files (e.g. 420 for 0644)" ] + returnType = TypeReference.result TInt (posixErrorTypeRef ()) description = "Opens a file via libc open(). Returns a file descriptor." fn = (function - | state, _, _, [ DString path; DInt64 flags; DInt64 mode ] -> + | state, vm, _, [ DString path; DInt flags; DInt mode ] -> LibExecution.CapabilityCheck.requireFileReadWrite state.grantedCaps path - match Libc.openFile path (int flags) (int mode) with + match Libc.openFile path (intToInt32 vm flags) (intToInt32 vm mode) with | Ok fd -> - Dval.resultOk KTInt64 (posixErrorKT ()) (DInt64(int64 fd)) |> Ply + Dval.resultOk KTInt (posixErrorKT ()) (Dval.int (bigint fd)) |> Ply | Error e -> - Dval.resultError KTInt64 (posixErrorKT ()) (dPosixError e) |> Ply + Dval.resultError KTInt (posixErrorKT ()) (dPosixError e) |> Ply | _ -> incorrectArgs ()) sqlSpec = NotQueryable previewable = Impure @@ -1039,11 +1043,11 @@ let fns () : List = { name = fn "posixFlagRdonly" 0 typeParams = [] parameters = [ Param.make "unit" TUnit "" ] - returnType = TInt64 + returnType = TInt description = "Returns the O_RDONLY flag for open()" fn = (function - | _, _, _, [ DUnit ] -> DInt64(int64 Libc.O_RDONLY) |> Ply + | _, _, _, [ DUnit ] -> Dval.int (bigint Libc.O_RDONLY) |> Ply | _ -> incorrectArgs ()) sqlSpec = NotQueryable previewable = Pure @@ -1054,11 +1058,11 @@ let fns () : List = { name = fn "posixFlagWronly" 0 typeParams = [] parameters = [ Param.make "unit" TUnit "" ] - returnType = TInt64 + returnType = TInt description = "Returns the O_WRONLY flag for open()" fn = (function - | _, _, _, [ DUnit ] -> DInt64(int64 Libc.O_WRONLY) |> Ply + | _, _, _, [ DUnit ] -> Dval.int (bigint Libc.O_WRONLY) |> Ply | _ -> incorrectArgs ()) sqlSpec = NotQueryable previewable = Pure @@ -1069,11 +1073,11 @@ let fns () : List = { name = fn "posixFlagRdwr" 0 typeParams = [] parameters = [ Param.make "unit" TUnit "" ] - returnType = TInt64 + returnType = TInt description = "Returns the O_RDWR flag for open()" fn = (function - | _, _, _, [ DUnit ] -> DInt64(int64 Libc.O_RDWR) |> Ply + | _, _, _, [ DUnit ] -> Dval.int (bigint Libc.O_RDWR) |> Ply | _ -> incorrectArgs ()) sqlSpec = NotQueryable previewable = Pure @@ -1084,11 +1088,11 @@ let fns () : List = { name = fn "posixFlagCreat" 0 typeParams = [] parameters = [ Param.make "unit" TUnit "" ] - returnType = TInt64 + returnType = TInt description = "Returns the O_CREAT flag for open() (platform-aware)" fn = (function - | _, _, _, [ DUnit ] -> DInt64(int64 Libc.O_CREAT) |> Ply + | _, _, _, [ DUnit ] -> Dval.int (bigint Libc.O_CREAT) |> Ply | _ -> incorrectArgs ()) sqlSpec = NotQueryable previewable = Pure @@ -1099,11 +1103,11 @@ let fns () : List = { name = fn "posixFlagTrunc" 0 typeParams = [] parameters = [ Param.make "unit" TUnit "" ] - returnType = TInt64 + returnType = TInt description = "Returns the O_TRUNC flag for open() (platform-aware)" fn = (function - | _, _, _, [ DUnit ] -> DInt64(int64 Libc.O_TRUNC) |> Ply + | _, _, _, [ DUnit ] -> Dval.int (bigint Libc.O_TRUNC) |> Ply | _ -> incorrectArgs ()) sqlSpec = NotQueryable previewable = Pure @@ -1114,11 +1118,11 @@ let fns () : List = { name = fn "posixFlagAppend" 0 typeParams = [] parameters = [ Param.make "unit" TUnit "" ] - returnType = TInt64 + returnType = TInt description = "Returns the O_APPEND flag for open() (platform-aware)" fn = (function - | _, _, _, [ DUnit ] -> DInt64(int64 Libc.O_APPEND) |> Ply + | _, _, _, [ DUnit ] -> Dval.int (bigint Libc.O_APPEND) |> Ply | _ -> incorrectArgs ()) sqlSpec = NotQueryable previewable = Pure @@ -1130,25 +1134,25 @@ let fns () : List = typeParams = [] parameters = [ Param.make "path" TString "File path to stat" ] returnType = - TypeReference.result - (TTuple(TInt64, TInt64, [ TInt64 ])) - (posixErrorTypeRef ()) + TypeReference.result (TTuple(TInt, TInt, [ TInt ])) (posixErrorTypeRef ()) description = "Stats a file via libc stat(). Returns (mode, size, mtimeSec)." fn = (function | state, _, _, [ DString path ] -> LibExecution.CapabilityCheck.requireFileReadWrite state.grantedCaps path let resultOk = - Dval.resultOk - (KTTuple(VT.int64, VT.int64, [ VT.int64 ])) - (posixErrorKT ()) + Dval.resultOk (KTTuple(VT.int, VT.int, [ VT.int ])) (posixErrorKT ()) let resultError = - Dval.resultError - (KTTuple(VT.int64, VT.int64, [ VT.int64 ])) - (posixErrorKT ()) + Dval.resultError (KTTuple(VT.int, VT.int, [ VT.int ])) (posixErrorKT ()) match Libc.stat path with | Ok(mode, size, mtimeSec) -> - resultOk (DTuple(DInt64(int64 mode), DInt64 size, [ DInt64 mtimeSec ])) + resultOk ( + DTuple( + Dval.int (bigint mode), + Dval.int (bigint size), + [ Dval.int (bigint mtimeSec) ] + ) + ) |> Ply | Error e -> resultError (dPosixError e) |> Ply | _ -> incorrectArgs ()) @@ -1192,11 +1196,11 @@ let fns () : List = { name = fn "posixGetpid" 0 typeParams = [] parameters = [ Param.make "unit" TUnit "" ] - returnType = TInt64 + returnType = TInt description = "Returns the current process ID via libc getpid()" fn = (function - | _, _, _, [ DUnit ] -> DInt64(int64 (Libc.getpid ())) |> Ply + | _, _, _, [ DUnit ] -> Dval.int (bigint (Libc.getpid ())) |> Ply | _ -> incorrectArgs ()) sqlSpec = NotQueryable previewable = Impure @@ -1207,11 +1211,11 @@ let fns () : List = { name = fn "posixGetuid" 0 typeParams = [] parameters = [ Param.make "unit" TUnit "" ] - returnType = TInt64 + returnType = TInt description = "Returns the current user ID via libc getuid()" fn = (function - | _, _, _, [ DUnit ] -> DInt64(int64 (Libc.getuid ())) |> Ply + | _, _, _, [ DUnit ] -> Dval.int (bigint (Libc.getuid ())) |> Ply | _ -> incorrectArgs ()) sqlSpec = NotQueryable previewable = Impure @@ -1242,11 +1246,11 @@ let fns () : List = { name = fn "posixCpuCount" 0 typeParams = [] parameters = [ Param.make "unit" TUnit "" ] - returnType = TInt64 + returnType = TInt description = "Returns the number of online CPUs via sysconf()" fn = (function - | _, _, _, [ DUnit ] -> DInt64(Libc.cpuCount ()) |> Ply + | _, _, _, [ DUnit ] -> Dval.int (bigint (Libc.cpuCount ())) |> Ply | _ -> incorrectArgs ()) sqlSpec = NotQueryable previewable = Impure @@ -1296,15 +1300,15 @@ let fns () : List = { name = fn "posixFlock" 0 typeParams = [] parameters = - [ Param.make "fd" TInt64 "File descriptor" + [ Param.make "fd" TInt "File descriptor" Param.make "exclusive" TBool "True for exclusive lock, false to unlock" ] returnType = TypeReference.result TUnit (posixErrorTypeRef ()) description = "Locks or unlocks a file via libc flock()" fn = (function - | _, _, _, [ DInt64 fd; DBool exclusive ] -> + | _, vm, _, [ DInt fd; DBool exclusive ] -> let op = if exclusive then Libc.LOCK_EX else Libc.LOCK_UN - match Libc.flock (int fd) op with + match Libc.flock (intToInt32 vm fd) op with | Ok() -> Dval.resultOk KTUnit (posixErrorKT ()) DUnit |> Ply | Error e -> Dval.resultError KTUnit (posixErrorKT ()) (dPosixError e) |> Ply diff --git a/backend/src/Builtins/Builtins.Cli/Libs/Stdin.fs b/backend/src/Builtins/Builtins.Cli/Libs/Stdin.fs index 3ddde2fe3f..ed280dfa87 100644 --- a/backend/src/Builtins/Builtins.Cli/Libs/Stdin.fs +++ b/backend/src/Builtins/Builtins.Cli/Libs/Stdin.fs @@ -274,17 +274,20 @@ let fns () : List = { name = fn "stdinReadExactly" 0 typeParams = [] - parameters = [ Param.make "length" TInt64 "The number of characters to read." ] + parameters = [ Param.make "length" TInt "The number of characters to read." ] returnType = TString description = "Reads a specified number of characters from the standard input." fn = (function - | _, _, _, [ DInt64 length ] -> + | _, vm, _, [ DInt lengthArg ] -> + // length must fit a native int and be non-negative; both bounds are + // "out of range" for this parameter, surfaced as a Dark error. + let length = intToInt32 vm lengthArg if length < 0 then - Exception.raiseInternal "Length must be non-negative" [] + RuntimeError.Ints.OutOfRange |> RuntimeError.Int |> raiseRTE vm.threadID else - let buffer = Array.zeroCreate (int length) - let bytesRead = System.Console.In.Read(buffer, 0, (int length)) + let buffer = Array.zeroCreate length + let bytesRead = System.Console.In.Read(buffer, 0, length) let input = System.String(buffer, 0, bytesRead) Ply(DString input) | _ -> incorrectArgs ()) 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/backend/src/Builtins/Builtins.CliHost/Libs/Cli.fs b/backend/src/Builtins/Builtins.CliHost/Libs/Cli.fs index 9768bd299e..6b1ff7e05c 100644 --- a/backend/src/Builtins/Builtins.CliHost/Libs/Cli.fs +++ b/backend/src/Builtins/Builtins.CliHost/Libs/Cli.fs @@ -308,13 +308,13 @@ let fns () : List = "sandbox" TBool "Run the script body with NO capabilities (a deny-all sandbox for untrusted scripts), instead of the host's configured grant" ] - returnType = TypeReference.result TInt64 (ExecutionError.typeRef ()) + returnType = TypeReference.result TInt (ExecutionError.typeRef ()) description = "Parses Dark code as a script, and and executes it, returning an exit code" fn = let errType = KTCustomType(ExecutionError.fqTypeName (), []) - let resultOk = Dval.resultOk KTInt64 errType - let resultError = Dval.resultError KTInt64 errType + let resultOk = Dval.resultOk KTInt errType + let resultError = Dval.resultError KTInt errType (function | exeState, _, @@ -371,8 +371,9 @@ let fns () : List = dbs (RunScript(filename, code)) with - | Ok(DInt64 i) -> return resultOk (DInt64 i) - | Ok DUnit -> return resultOk (DInt64 0L) + | Ok(DInt i) -> return resultOk (DInt i) + | Ok(DInt64 i) -> return resultOk (Dval.int (bigint i)) + | Ok DUnit -> return resultOk (Dval.int (bigint 0)) | Ok result -> let rte = RuntimeError.CLIs.NonIntReturned result |> RuntimeError.CLI 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..2b792fb7d8 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" @@ -349,15 +349,33 @@ let fns () : List = fn = (function | exeState, + vm, _, - _, - [ DInt64 port + [ DInt portArg DApplicable handler - DInt64 maxBodyBytes + DInt maxBodyBytesArg DBool injectStandardHeaders DBool canonicalizeFromForwardedProto DBool logRequests ] -> uply { + // maxBodyBytes is a comparison threshold; a negative limit would + // reject every request (treated as over-limit), so reject it. 0 is + // valid (allow no body). + let maxBodyBytes = intToInt64 vm maxBodyBytesArg + if maxBodyBytes < 0L then + RuntimeError.Ints.OutOfRange + |> RuntimeError.Int + |> raiseRTE vm.threadID + // A TCP port must be in [0, 65535]. intToInt64 alone would let + // larger-but-int64-sized values reach HttpListener.Start and throw a + // host exception, so validate the real port range up front. + let port = intToInt64 vm portArg + if + port < int64 IPEndPoint.MinPort || port > int64 IPEndPoint.MaxPort + then + RuntimeError.Ints.OutOfRange + |> RuntimeError.Int + |> raiseRTE vm.threadID use _serveSpan = Telemetry.span "httpserver.serve" [ "port", string port ] 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/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/Builtins/Builtins.Matter/Libs/PM/PackageOps.fs b/backend/src/Builtins/Builtins.Matter/Libs/PM/PackageOps.fs index de04b008c1..6afd32fa08 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,13 +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 ] -> + | _, vm, _, [ DInt limitArg ] -> uply { + let limit = intToInt64 vm limitArg let! ops = LibDB.Queries.getRecentOps limit return Dval.list (packageOpKT ()) (ops |> List.map PT2DT.PackageOp.toDT) } @@ -117,7 +118,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 +127,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 +175,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 +194,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 +302,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 +328,14 @@ 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 ] -> + | _, vm, _, [ DUuid branchId; DInt limit ] -> uply { - let! commits = LibDB.Queries.getCommits branchId limit + let! commits = LibDB.Queries.getCommits branchId (intToInt64 vm limit) return Dval.list (PT2DT.Commit.knownType ()) @@ -351,15 +352,16 @@ 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 ] -> + | _, vm, _, [ DUuid branchId; DInt limit ] -> uply { - let! commits = LibDB.Queries.getCommitsForBranchChain branchId limit + let! commits = + LibDB.Queries.getCommitsForBranchChain branchId (intToInt64 vm limit) return Dval.list (PT2DT.Commit.knownType ()) 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/backend/src/Builtins/Builtins.Matter/Libs/Traces.fs b/backend/src/Builtins/Builtins.Matter/Libs/Traces.fs index cf9cd6eed1..b1ac376a28 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 ] -> + | _, vm, _, [ DInt limitArg ] -> + let limit = intToInt64 vm 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 ] -> + | _, vm, _, [ DString fnName; DInt limitArg ] -> + let limit = intToInt64 vm limitArg uply { // Both builtins and package fns store their display name in // fn_hash (resolved at write time), so one LIKE matches either. @@ -275,16 +277,14 @@ let fns () : List = { name = fn "tracesStatsByHandler" 0 typeParams = [] parameters = - [ Param.make - "traceLimit" - TInt64 - "Aggregate over the last N traces (e.g. 100)" ] - returnType = TList(TTuple(TString, TInt64, [ TInt64; TInt64 ])) + [ 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`." fn = (function - | _, _, _, [ DInt64 traceLimit ] -> + | _, vm, _, [ DInt traceLimitArg ] -> + let traceLimit = intToInt64 vm 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 +314,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 @@ -329,16 +329,14 @@ let fns () : List = { name = fn "tracesHotspots" 0 typeParams = [] parameters = - [ Param.make - "traceLimit" - TInt64 - "Aggregate over the last N traces (e.g. 100)" ] - returnType = TList(TTuple(TString, TInt64, [ TInt64; TInt64 ])) + [ 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." fn = (function - | _, _, _, [ DInt64 traceLimit ] -> + | _, vm, _, [ DInt traceLimitArg ] -> + let traceLimit = intToInt64 vm traceLimitArg uply { // Subquery: the last N trace IDs by recency. // Outer GROUP BY rolls duration up per fn_hash. @@ -369,10 +367,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 +390,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, vm, _, [ DString pattern; DInt limitArg ] -> + let limit = intToInt64 vm limitArg uply { let typeName = traceSummaryTypeName () @@ -597,7 +596,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 +627,7 @@ let fns () : List = ("DELETE FROM traces WHERE timestamp < @cutoff", p) ] () - return DInt64 count + return Dval.int (bigint count) } | _ -> incorrectArgs ()) sqlSpec = NotQueryable @@ -640,7 +639,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 +654,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 +666,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 +678,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 +688,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 @@ -700,14 +699,14 @@ let fns () : List = { name = fn "tracesPruneKeep" 0 typeParams = [] - parameters = - [ Param.make "keepN" TInt64 "Number of most-recent traces to keep" ] - returnType = TInt64 + 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." fn = (function - | _, _, _, [ DInt64 keepN ] -> + | _, vm, _, [ DInt keepNArg ] -> + let keepN = intToInt64 vm 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 +746,7 @@ let fns () : List = p) ] () - return DInt64 count + return Dval.int (bigint count) } | _ -> incorrectArgs ()) sqlSpec = NotQueryable 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/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/src/Builtins/Builtins.Pure/Libs/DateTime.fs b/backend/src/Builtins/Builtins.Pure/Libs/DateTime.fs index defc177e5b..fed255366a 100644 --- a/backend/src/Builtins/Builtins.Pure/Libs/DateTime.fs +++ b/backend/src/Builtins/Builtins.Pure/Libs/DateTime.fs @@ -30,6 +30,18 @@ let ISO8601DateParser (s : string) : Result = | _ -> Error() +/// NodaTime rejects instants/periods outside its supported range by throwing +/// host exceptions, even for values that fit int64. Run `f` and turn those into +/// a Dark `OutOfRange` error rather than letting them escape. +let private inDateRange (vm : VMState) (f : unit -> Dval) : Ply = + try + f () |> Ply + with + | :? System.ArgumentOutOfRangeException + | :? System.OverflowException -> + RuntimeError.Ints.OutOfRange |> RuntimeError.Int |> raiseRTE vm.threadID + + let fns () : List = [ { name = fn "dateTimeParse" 0 typeParams = [] @@ -119,16 +131,18 @@ let fns () : List = { name = fn "dateTimeAddSeconds" 0 typeParams = [] - parameters = [ Param.make "d" TDateTime ""; Param.make "seconds" TInt64 "" ] + parameters = [ Param.make "d" TDateTime ""; Param.make "seconds" TInt "" ] returnType = TDateTime description = "Returns a seconds after " fn = (function - | _, _, _, [ DDateTime d; DInt64 s ] -> - d + (NodaTime.Period.FromSeconds s) |> DDateTime |> Ply + | _, vm, _, [ DDateTime d; DInt s ] -> + inDateRange vm (fun () -> + d + (NodaTime.Period.FromSeconds(intToInt64 vm s)) |> DDateTime) | _ -> incorrectArgs ()) - sqlSpec = SqlBinOp "+" + // `seconds` is an `Int`, not queryable in DB.query yet; restore SqlBinOp "+" once it is + sqlSpec = NotQueryable previewable = Pure capabilities = LibExecution.Capabilities.noCaps deprecated = NotDeprecated } @@ -141,16 +155,18 @@ let fns () : List = // should include the name of the relevant unit in the fn name. { name = fn "dateTimeSubtractSeconds" 0 typeParams = [] - parameters = [ Param.make "d" TDateTime ""; Param.make "seconds" TInt64 "" ] + parameters = [ Param.make "d" TDateTime ""; Param.make "seconds" TInt "" ] returnType = TDateTime description = "Returns a seconds before " fn = (function - | _, _, _, [ DDateTime d; DInt64 s ] -> - d - (NodaTime.Period.FromSeconds s) |> DDateTime |> Ply + | _, vm, _, [ DDateTime d; DInt s ] -> + inDateRange vm (fun () -> + d - (NodaTime.Period.FromSeconds(intToInt64 vm s)) |> DDateTime) | _ -> incorrectArgs ()) - sqlSpec = SqlBinOp "-" + // `seconds` is an `Int`, not queryable in DB.query yet; restore SqlBinOp "-" once it is + sqlSpec = NotQueryable previewable = Pure capabilities = LibExecution.Capabilities.noCaps deprecated = NotDeprecated } @@ -219,13 +235,13 @@ let fns () : List = { name = fn "dateTimeToSeconds" 0 typeParams = [] parameters = [ Param.make "date" TDateTime "" ] - returnType = TInt64 + returnType = TInt description = - "Converts to an representing seconds since the Unix epoch" + "Converts to an representing seconds since the Unix epoch" fn = (function | _, _, _, [ DDateTime d ] -> - (DarkDateTime.toInstant d).ToUnixTimeSeconds() |> DInt64 |> Ply + (DarkDateTime.toInstant d).ToUnixTimeSeconds() |> bigint |> Dval.int |> Ply | _ -> incorrectArgs ()) sqlSpec = NotQueryable previewable = Pure @@ -235,18 +251,18 @@ let fns () : List = { name = fn "dateTimeFromSeconds" 0 typeParams = [] - parameters = [ Param.make "seconds" TInt64 "" ] + parameters = [ Param.make "seconds" TInt "" ] returnType = TDateTime description = - "Converts an representing seconds since the Unix epoch into a " + "Converts an representing seconds since the Unix epoch into a " fn = (function - | _, _, _, [ DInt64 s ] -> - s - |> Instant.FromUnixTimeSeconds - |> DarkDateTime.fromInstant - |> DDateTime - |> Ply + | _, vm, _, [ DInt s ] -> + inDateRange vm (fun () -> + intToInt64 vm s + |> Instant.FromUnixTimeSeconds + |> DarkDateTime.fromInstant + |> DDateTime) | _ -> incorrectArgs ()) sqlSpec = NotQueryable previewable = Pure @@ -257,13 +273,14 @@ let fns () : List = { name = fn "dateTimeYear" 0 typeParams = [] parameters = [ Param.make "date" TDateTime "" ] - returnType = TInt64 - description = "Returns the year portion of as an " + returnType = TInt + description = "Returns the year portion of as an " fn = (function - | _, _, _, [ DDateTime d ] -> d.Year |> int64 |> Dval.int64 |> Ply + | _, _, _, [ DDateTime d ] -> d.Year |> bigint |> Dval.int |> Ply | _ -> incorrectArgs ()) - sqlSpec = SqlFunctionWithPrefixArgs("date_part", [ "'year'" ]) + // `Int` isn't queryable yet; restore date_part('year') sqlSpec once it is + sqlSpec = NotQueryable previewable = Pure capabilities = LibExecution.Capabilities.noCaps deprecated = NotDeprecated } @@ -272,14 +289,15 @@ let fns () : List = { name = fn "dateTimeMonth" 0 typeParams = [] parameters = [ Param.make "date" TDateTime "" ] - returnType = TInt64 + returnType = TInt description = - "Returns the month portion of as an between {{1}} and {{12}}" + "Returns the month portion of as an between {{1}} and {{12}}" fn = (function - | _, _, _, [ DDateTime d ] -> d.Month |> int64 |> Dval.int64 |> Ply + | _, _, _, [ DDateTime d ] -> d.Month |> bigint |> Dval.int |> Ply | _ -> incorrectArgs ()) - sqlSpec = SqlFunctionWithPrefixArgs("date_part", [ "'month'" ]) + // `Int` isn't queryable yet; restore date_part('month') sqlSpec once it is + sqlSpec = NotQueryable previewable = Pure capabilities = LibExecution.Capabilities.noCaps deprecated = NotDeprecated } @@ -288,13 +306,14 @@ let fns () : List = { name = fn "dateTimeDay" 0 typeParams = [] parameters = [ Param.make "date" TDateTime "" ] - returnType = TInt64 - description = "Returns the day portion of as an " + returnType = TInt + description = "Returns the day portion of as an " fn = (function - | _, _, _, [ DDateTime d ] -> d.Day |> int64 |> Dval.int64 |> Ply + | _, _, _, [ DDateTime d ] -> d.Day |> bigint |> Dval.int |> Ply | _ -> incorrectArgs ()) - sqlSpec = SqlFunctionWithPrefixArgs("date_part", [ "'day'" ]) + // `Int` isn't queryable yet; restore date_part('day') sqlSpec once it is + sqlSpec = NotQueryable previewable = Pure capabilities = LibExecution.Capabilities.noCaps deprecated = NotDeprecated } @@ -303,13 +322,14 @@ let fns () : List = { name = fn "dateTimeWeekday" 0 typeParams = [] parameters = [ Param.make "date" TDateTime "" ] - returnType = TInt64 + returnType = TInt description = - "Returns the weekday of as an . + "Returns the weekday of as an . Monday = {{1}}, Tuesday = {{2}}, ... Sunday = {{7}} (in accordance with ISO 8601)" fn = (function - | _, _, _, [ DDateTime d ] -> d.DayOfWeek |> int64 |> DInt64 |> Ply + | _, _, _, [ DDateTime d ] -> + d.DayOfWeek |> int64 |> bigint |> Dval.int |> Ply | _ -> incorrectArgs ()) sqlSpec = NotQueryable previewable = Pure @@ -320,13 +340,14 @@ let fns () : List = { name = fn "dateTimeHour" 0 typeParams = [] parameters = [ Param.make "date" TDateTime "" ] - returnType = TInt64 - description = "Returns the hour portion of as an " + returnType = TInt + description = "Returns the hour portion of as an " fn = (function - | _, _, _, [ DDateTime d ] -> Ply(Dval.int64 d.Hour) + | _, _, _, [ DDateTime d ] -> Ply(Dval.int (bigint d.Hour)) | _ -> incorrectArgs ()) - sqlSpec = SqlFunctionWithPrefixArgs("date_part", [ "'hour'" ]) + // `Int` isn't queryable yet; restore date_part('hour') sqlSpec once it is + sqlSpec = NotQueryable previewable = Pure capabilities = LibExecution.Capabilities.noCaps deprecated = NotDeprecated } @@ -335,13 +356,14 @@ let fns () : List = { name = fn "dateTimeMinute" 0 typeParams = [] parameters = [ Param.make "date" TDateTime "" ] - returnType = TInt64 - description = "Returns the minute portion of as an " + returnType = TInt + description = "Returns the minute portion of as an " fn = (function - | _, _, _, [ DDateTime d ] -> Ply(Dval.int64 d.Minute) + | _, _, _, [ DDateTime d ] -> Ply(Dval.int (bigint d.Minute)) | _ -> incorrectArgs ()) - sqlSpec = SqlFunctionWithPrefixArgs("date_part", [ "'minute'" ]) + // `Int` isn't queryable yet; restore date_part('minute') sqlSpec once it is + sqlSpec = NotQueryable previewable = Pure capabilities = LibExecution.Capabilities.noCaps deprecated = NotDeprecated } @@ -350,13 +372,14 @@ let fns () : List = { name = fn "dateTimeSecond" 0 typeParams = [] parameters = [ Param.make "date" TDateTime "" ] - returnType = TInt64 - description = "Returns the second portion of as an " + returnType = TInt + description = "Returns the second portion of as an " fn = (function - | _, _, _, [ DDateTime d ] -> Ply(Dval.int64 d.Second) + | _, _, _, [ DDateTime d ] -> Ply(Dval.int (bigint d.Second)) | _ -> incorrectArgs ()) - sqlSpec = SqlFunctionWithPrefixArgs("date_part", [ "'second'" ]) + // `Int` isn't queryable yet; restore date_part('second') sqlSpec once it is + sqlSpec = NotQueryable previewable = Pure capabilities = LibExecution.Capabilities.noCaps deprecated = NotDeprecated } @@ -386,14 +409,19 @@ let fns () : List = { name = fn "dateTimeSubtract" 0 typeParams = [] parameters = [ Param.make "end" TDateTime ""; Param.make "start" TDateTime "" ] - returnType = TInt64 + returnType = TInt description = "Returns the difference of the two dates, in seconds" fn = (function | _, _, _, [ DDateTime endDate; DDateTime startDate ] -> let diff = (DarkDateTime.toInstant endDate) - (DarkDateTime.toInstant startDate) - diff.TotalSeconds |> System.Math.Round |> int64 |> DInt64 |> Ply + diff.TotalSeconds + |> System.Math.Round + |> int64 + |> bigint + |> Dval.int + |> Ply | _ -> incorrectArgs ()) sqlSpec = NotYetImplemented previewable = Pure @@ -404,13 +432,16 @@ let fns () : List = { name = fn "dateTimeToMilliseconds" 0 typeParams = [] parameters = [ Param.make "date" TDateTime "" ] - returnType = TInt64 + returnType = TInt description = - "Converts to an representing milliseconds since the Unix epoch" + "Converts to an representing milliseconds since the Unix epoch" fn = (function | _, _, _, [ DDateTime d ] -> - (DarkDateTime.toInstant d).ToUnixTimeMilliseconds() |> DInt64 |> Ply + (DarkDateTime.toInstant d).ToUnixTimeMilliseconds() + |> bigint + |> Dval.int + |> Ply | _ -> incorrectArgs ()) sqlSpec = NotQueryable previewable = Pure @@ -420,18 +451,18 @@ let fns () : List = { name = fn "dateTimeFromMilliseconds" 0 typeParams = [] - parameters = [ Param.make "milliseconds" TInt64 "" ] + parameters = [ Param.make "milliseconds" TInt "" ] returnType = TDateTime description = - "Converts an representing milliseconds since the Unix epoch into a " + "Converts an representing milliseconds since the Unix epoch into a " fn = (function - | _, _, _, [ DInt64 ms ] -> - ms - |> Instant.FromUnixTimeMilliseconds - |> DarkDateTime.fromInstant - |> DDateTime - |> Ply + | _, vm, _, [ DInt ms ] -> + inDateRange vm (fun () -> + intToInt64 vm ms + |> Instant.FromUnixTimeMilliseconds + |> DarkDateTime.fromInstant + |> DDateTime) | _ -> incorrectArgs ()) sqlSpec = NotQueryable previewable = Pure @@ -441,15 +472,15 @@ let fns () : List = { name = fn "dateTimeAddMilliseconds" 0 typeParams = [] - parameters = - [ Param.make "d" TDateTime ""; Param.make "milliseconds" TInt64 "" ] + parameters = [ Param.make "d" TDateTime ""; Param.make "milliseconds" TInt "" ] returnType = TDateTime description = "Returns a milliseconds after " fn = (function - | _, _, _, [ DDateTime d; DInt64 ms ] -> - d + (NodaTime.Period.FromMilliseconds ms) |> DDateTime |> Ply + | _, vm, _, [ DDateTime d; DInt ms ] -> + inDateRange vm (fun () -> + d + (NodaTime.Period.FromMilliseconds(intToInt64 vm ms)) |> DDateTime) | _ -> incorrectArgs ()) sqlSpec = NotQueryable previewable = Pure @@ -459,15 +490,15 @@ let fns () : List = { name = fn "dateTimeSubtractMilliseconds" 0 typeParams = [] - parameters = - [ Param.make "d" TDateTime ""; Param.make "milliseconds" TInt64 "" ] + parameters = [ Param.make "d" TDateTime ""; Param.make "milliseconds" TInt "" ] returnType = TDateTime description = "Returns a milliseconds before " fn = (function - | _, _, _, [ DDateTime d; DInt64 ms ] -> - d - (NodaTime.Period.FromMilliseconds ms) |> DDateTime |> Ply + | _, vm, _, [ DDateTime d; DInt ms ] -> + inDateRange vm (fun () -> + d - (NodaTime.Period.FromMilliseconds(intToInt64 vm ms)) |> DDateTime) | _ -> incorrectArgs ()) sqlSpec = NotQueryable previewable = Pure @@ -478,12 +509,12 @@ let fns () : List = { name = fn "dateTimeMillisecond" 0 typeParams = [] parameters = [ Param.make "date" TDateTime "" ] - returnType = TInt64 + returnType = TInt description = - "Returns the millisecond portion of as an between {{0}} and {{999}}" + "Returns the millisecond portion of as an between {{0}} and {{999}}" fn = (function - | _, _, _, [ DDateTime d ] -> d.Millisecond |> int64 |> Dval.int64 |> Ply + | _, _, _, [ DDateTime d ] -> d.Millisecond |> bigint |> Dval.int |> Ply | _ -> incorrectArgs ()) sqlSpec = NotQueryable previewable = Pure @@ -494,7 +525,7 @@ let fns () : List = { name = fn "dateTimeSubtractMs" 0 typeParams = [] parameters = [ Param.make "end" TDateTime ""; Param.make "start" TDateTime "" ] - returnType = TInt64 + returnType = TInt description = "Returns the difference of the two dates, in milliseconds" fn = (function @@ -502,7 +533,12 @@ let fns () : List = let diff = (DarkDateTime.toInstant endDate) - (DarkDateTime.toInstant startDate) - diff.TotalMilliseconds |> System.Math.Round |> int64 |> DInt64 |> Ply + diff.TotalMilliseconds + |> System.Math.Round + |> int64 + |> bigint + |> Dval.int + |> Ply | _ -> incorrectArgs ()) sqlSpec = NotQueryable previewable = Pure 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/src/Builtins/Builtins.Pure/Libs/Float.fs b/backend/src/Builtins/Builtins.Pure/Libs/Float.fs index 143d271dd0..955f29c9cd 100644 --- a/backend/src/Builtins/Builtins.Pure/Libs/Float.fs +++ b/backend/src/Builtins/Builtins.Pure/Libs/Float.fs @@ -21,15 +21,25 @@ module ParseError = DEnum(typeName, typeName, [], caseName, fields) +/// Convert an already-rounded float to an `Int`. NaN/Infinity have no Int +/// representation; `bigint` would throw a host exception, so surface a Dark +/// `OutOfRange` error instead. +let private roundedToInt (vm : VMState) (rounded : float) : Ply = + if System.Double.IsNaN rounded || System.Double.IsInfinity rounded then + RuntimeError.Ints.OutOfRange |> RuntimeError.Int |> raiseRTE vm.threadID + else + rounded |> bigint |> Dval.int |> Ply + + 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 + | _, vm, _, [ DFloat a ] -> a |> System.Math.Ceiling |> roundedToInt vm | _ -> incorrectArgs ()) sqlSpec = NotYetImplemented previewable = Pure @@ -40,11 +50,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 + | _, vm, _, [ DFloat a ] -> a |> System.Math.Ceiling |> roundedToInt vm | _ -> incorrectArgs ()) sqlSpec = NotYetImplemented previewable = Pure @@ -55,7 +65,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 +74,7 @@ let fns () : List = but {{Float.truncate -1.9 == -1.0}}" fn = (function - | _, _, _, [ DFloat a ] -> a |> System.Math.Floor |> int64 |> DInt64 |> Ply + | _, vm, _, [ DFloat a ] -> a |> System.Math.Floor |> roundedToInt vm | _ -> incorrectArgs ()) sqlSpec = NotYetImplemented previewable = Pure @@ -75,7 +85,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 +95,7 @@ let fns () : List = fn = (function - | _, _, _, [ DFloat a ] -> a |> System.Math.Floor |> int64 |> DInt64 |> Ply + | _, vm, _, [ DFloat a ] -> a |> System.Math.Floor |> roundedToInt vm | _ -> incorrectArgs ()) sqlSpec = NotYetImplemented previewable = Pure @@ -96,11 +106,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 + | _, vm, _, [ DFloat a ] -> a |> System.Math.Round |> roundedToInt vm | _ -> incorrectArgs ()) sqlSpec = NotYetImplemented previewable = Pure @@ -111,13 +121,12 @@ 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 + | _, vm, _, [ DFloat a ] -> a |> System.Math.Truncate |> roundedToInt vm | _ -> incorrectArgs ()) sqlSpec = NotYetImplemented previewable = Pure @@ -278,13 +287,12 @@ 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 + | _, vm, _, [ DFloat a ] -> a |> System.Math.Truncate |> roundedToInt vm | _ -> 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..e18e8b29ef 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 @@ -100,7 +114,9 @@ let fns () : List = | _, _, _, [ DInt value; DInt divisor ] -> let d = DarkInt.toBigInt divisor if d = bigZero then - DString "`divisor` must be non-zero" |> resultError |> Ply + // The return type is a `Result`, so surface this as an `Error` + // rather than raising a runtime error. + DString "Cannot divide by 0" |> resultError |> Ply else DarkInt.toBigInt value % d |> Dval.int |> resultOk |> Ply | _ -> incorrectArgs ()) @@ -317,21 +333,50 @@ 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 + | _, vm, _, [ DFloat f ] -> + // NaN/Infinity have no Int representation; `bigint f` would throw a + // host exception, so surface a Dark error instead. + if System.Double.IsNaN f || System.Double.IsInfinity f then + outOfRange vm + else + 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 "" ] - 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 @@ -719,6 +764,105 @@ let fns () : List = sqlSpec = NotQueryable previewable = Pure capabilities = LibExecution.Capabilities.noCaps + deprecated = NotDeprecated } + + + { name = fn "intBitwiseAnd" 0 + typeParams = [] + parameters = [ Param.make "a" TInt ""; Param.make "b" TInt "" ] + returnType = TInt + description = "Bitwise AND on two values" + fn = + (function + | _, _, _, [ DInt a; DInt b ] -> + Ply(Dval.int (DarkInt.toBigInt a &&& DarkInt.toBigInt b)) + | _ -> incorrectArgs ()) + sqlSpec = NotQueryable + previewable = Pure + capabilities = LibExecution.Capabilities.noCaps + deprecated = NotDeprecated } + + + { name = fn "intBitwiseOr" 0 + typeParams = [] + parameters = [ Param.make "a" TInt ""; Param.make "b" TInt "" ] + returnType = TInt + description = "Bitwise OR on two values" + fn = + (function + | _, _, _, [ DInt a; DInt b ] -> + Ply(Dval.int (DarkInt.toBigInt a ||| DarkInt.toBigInt b)) + | _ -> incorrectArgs ()) + sqlSpec = NotQueryable + previewable = Pure + capabilities = LibExecution.Capabilities.noCaps + deprecated = NotDeprecated } + + + { name = fn "intBitwiseXor" 0 + typeParams = [] + parameters = [ Param.make "a" TInt ""; Param.make "b" TInt "" ] + returnType = TInt + description = "Bitwise XOR on two values" + fn = + (function + | _, _, _, [ DInt a; DInt b ] -> + Ply(Dval.int (DarkInt.toBigInt a ^^^ DarkInt.toBigInt b)) + | _ -> incorrectArgs ()) + sqlSpec = NotQueryable + previewable = Pure + capabilities = LibExecution.Capabilities.noCaps + deprecated = NotDeprecated } + + + { name = fn "intBitwiseNot" 0 + typeParams = [] + parameters = [ Param.make "a" TInt "" ] + returnType = TInt + description = "Bitwise NOT on an value" + fn = + (function + | _, _, _, [ DInt a ] -> Ply(Dval.int (-(DarkInt.toBigInt a) - bigint 1)) + | _ -> incorrectArgs ()) + sqlSpec = NotQueryable + previewable = Pure + capabilities = LibExecution.Capabilities.noCaps + deprecated = NotDeprecated } + + + { name = fn "intShiftLeft" 0 + typeParams = [] + parameters = [ Param.make "a" TInt ""; Param.make "b" TInt "" ] + returnType = TInt + description = "Bitwise left shift of an value" + fn = + (function + | _, vm, _, [ DInt a; DInt b ] -> + // `<<<` needs a native Int32 shift count; reject anything that + // wouldn't fit rather than letting the cast overflow. + Ply(Dval.int (DarkInt.toBigInt a <<< intToInt32 vm b)) + | _ -> incorrectArgs ()) + sqlSpec = NotQueryable + previewable = Pure + capabilities = LibExecution.Capabilities.noCaps + deprecated = NotDeprecated } + + + { name = fn "intShiftRight" 0 + typeParams = [] + parameters = [ Param.make "a" TInt ""; Param.make "b" TInt "" ] + returnType = TInt + description = "Bitwise right shift of an value" + fn = + (function + | _, vm, _, [ DInt a; DInt b ] -> + // `>>>` needs a native Int32 shift count; reject anything that + // wouldn't fit rather than letting the cast overflow. + Ply(Dval.int (DarkInt.toBigInt a >>> intToInt32 vm b)) + | _ -> incorrectArgs ()) + sqlSpec = NotQueryable + previewable = Pure + capabilities = LibExecution.Capabilities.noCaps deprecated = NotDeprecated } ] diff --git a/backend/src/Builtins/Builtins.Pure/Libs/Json.fs b/backend/src/Builtins/Builtins.Pure/Libs/Json.fs index 8cf3bb6b3d..d777f81f45 100644 --- a/backend/src/Builtins/Builtins.Pure/Libs/Json.fs +++ b/backend/src/Builtins/Builtins.Pure/Libs/Json.fs @@ -72,7 +72,7 @@ module JsonPath = let (caseName, fields) = match part with | Root -> "Root", [] - | Index i -> "Index", [ DInt64(int64 i) ] + | Index i -> "Index", [ Dval.int (bigint i) ] | Field s -> "Field", [ DString s ] DEnum(typeName, typeName, [], caseName, fields) @@ -198,7 +198,7 @@ module ParseError = | EnumMissingField(typ, fieldCount, errorPath) -> "EnumMissingField", [ RT2DT.TypeReference.toDT typ - DInt64(int64 fieldCount) + Dval.int (bigint fieldCount) JsonPath.toDT errorPath ] | EnumInvalidCasename(typ, caseName, errorPath) -> 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/src/Builtins/Builtins.Pure/Libs/Stream.fs b/backend/src/Builtins/Builtins.Pure/Libs/Stream.fs index 6a4e2d1e99..0c1662f954 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,15 @@ let fns () : List = Terminates early without pulling the source past the limit." fn = (function - | _, _, _, [ DStream(src, _, _); DInt64 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 + | _, _, _, [ DStream(src, _, _); DInt n ] -> + // Clamp on the arbitrary-precision value before narrowing: a negative n + // (however large) becomes an empty stream, and an n past Int64 just + // takes everything. pullStreamImpl treats remaining<=0 as done. + let n = DarkInt.toBigInt n + let clamped = + if n < bigint 0 then 0L + elif n > bigint System.Int64.MaxValue then System.Int64.MaxValue + else int64 n Stream.wrapImpl (Take(src, clamped, ref clamped)) |> Ply | _ -> incorrectArgs ()) sqlSpec = NotYetImplemented diff --git a/backend/src/Builtins/Builtins.Pure/Libs/String.fs b/backend/src/Builtins/Builtins.Pure/Libs/String.fs index 337623239f..95ecf04cc4 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 ] -> + | _, vm, _, [ 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 = intToInt32 vm firstD + let last = intToInt32 vm 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,9 +507,14 @@ let fns () : List = (function | _, _, _, [ DString str; DString search ] -> let index = str.IndexOf(search) - Ply(DInt64 index) + Ply(Dval.int (bigint index)) | _ -> incorrectArgs ()) - sqlSpec = SqlCallback2(fun str search -> $"(INSTR({str}, {search}) - 1)") + // `Int` isn't queryable in DB.query yet, and the compiler treats any spec as + // active — so mark NotQueryable rather than advertise a spec that fails on the + // comparison literal. (String.contains has its own queryable Bool builtin, so + // it's unaffected.) Restore once Int is queryable: + // SqlCallback2(fun str search -> $"(INSTR({str}, {search}) - 1)") + sqlSpec = NotQueryable previewable = Pure capabilities = LibExecution.Capabilities.noCaps deprecated = NotDeprecated } @@ -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/src/Builtins/Builtins.Random/Libs/Random.fs b/backend/src/Builtins/Builtins.Random/Libs/Random.fs index c0ddd3227f..9da7c11d96 100644 --- a/backend/src/Builtins/Builtins.Random/Libs/Random.fs +++ b/backend/src/Builtins/Builtins.Random/Libs/Random.fs @@ -168,6 +168,35 @@ let fns () : List = deprecated = NotDeprecated } + { name = fn "intRandom" 0 + typeParams = [] + parameters = [ Param.make "start" TInt ""; Param.make "end" TInt "" ] + returnType = TInt + description = + "Returns a random integer between and (inclusive)" + fn = + (function + | _, _, _, [ DInt a; DInt b ] -> + let a = DarkInt.toBigInt a + let b = DarkInt.toBigInt b + let lower, upper = if a > b then (b, a) else (a, b) + let range = upper - lower + bigint 1 + // Draw a uniform value in [0, range). Generate extra bytes so the + // modulo bias is negligible (< 2^-64); the top byte stays 0 so the + // BigInteger is read as non-negative. + let numBytes = range.GetByteCount(true) + 8 + let buf = Array.zeroCreate (numBytes + 1) + randomSeeded().NextBytes(buf) + buf[numBytes] <- 0uy + let r = System.Numerics.BigInteger(buf) % range + Dval.int (lower + r) |> Ply + | _ -> incorrectArgs ()) + sqlSpec = NotQueryable + previewable = Impure + capabilities = LibExecution.Capabilities.Needs.random + deprecated = NotDeprecated } + + { name = fn "uint64Random" 0 typeParams = [] parameters = [ Param.make "start" TUInt64 ""; Param.make "end" TUInt64 "" ] 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/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/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/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/src/LibExecution/Builtin.fs b/backend/src/LibExecution/Builtin.fs index 0829385fec..f4b5424700 100644 --- a/backend/src/LibExecution/Builtin.fs +++ b/backend/src/LibExecution/Builtin.fs @@ -65,4 +65,20 @@ module Shortcuts = let value = FQValueName.builtin let incorrectArgs = RuntimeTypes.incorrectArgs + /// Narrow an arbitrary-precision `Int` to a native `int64`, raising a Dark + /// `OutOfRange` error (rather than letting a host overflow escape) when the + /// value doesn't fit. Use at builtins that hand the value to int64-typed APIs. + let intToInt64 (vm : VMState) (i : DarkInt) : int64 = + match DarkInt.toInt64 i with + | Some v -> v + | None -> + RuntimeError.Ints.OutOfRange |> RuntimeError.Int |> raiseRTE vm.threadID + + /// Like `intToInt64`, but narrows to a native `int` (Int32). + let intToInt32 (vm : VMState) (i : DarkInt) : int = + match DarkInt.toInt32 i with + | Some v -> v + | None -> + RuntimeError.Ints.OutOfRange |> RuntimeError.Int |> raiseRTE vm.threadID + type Param = BuiltInParam diff --git a/backend/src/LibExecution/CapabilitiesToDarkTypes.fs b/backend/src/LibExecution/CapabilitiesToDarkTypes.fs index 6e5fdb510a..f06237e74c 100644 --- a/backend/src/LibExecution/CapabilitiesToDarkTypes.fs +++ b/backend/src/LibExecution/CapabilitiesToDarkTypes.fs @@ -16,7 +16,7 @@ module Scope = let typeName () = FQTypeName.fqPackage (PackageRefs.Type.LanguageTools.Capabilities.scope ()) - /// Generic over the element's value-type + converter, so it serves `Scope` and `Scope`. + /// Generic over the element's value-type + converter, so it serves `Scope` and `Scope`. let toDT (elemVT : ValueType) (elemToDT : 'a -> Dval) (s : Cap.Scope<'a>) : Dval = let typeArgs = [ elemVT ] match s with @@ -40,8 +40,10 @@ module Scope = // the two concrete element kinds the model uses let strToDT (s : Cap.Scope) : Dval = toDT VT.string DString s let strFromDT (d : Dval) : Cap.Scope = fromDT D.string d - let portToDT (s : Cap.Scope) : Dval = toDT VT.int64 (fun n -> DInt64 n) s - let portFromDT (d : Dval) : Cap.Scope = fromDT D.int64 d + let portToDT (s : Cap.Scope) : Dval = + toDT VT.int (fun (n : int64) -> DInt(DarkInt.ofBigInt (bigint n))) s + let portFromDT (d : Dval) : Cap.Scope = + fromDT (fun dv -> int64 (D.darkInt dv)) d module HostMatch = 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/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/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..eebc98d1b4 100644 --- a/backend/src/LibExecution/ProgramTypesToDarkTypes.fs +++ b/backend/src/LibExecution/ProgramTypesToDarkTypes.fs @@ -833,7 +833,7 @@ module Expr = | PT.EVariable(id, varName) -> "EVariable", [ DInt64(int64 id); DString varName ] - | PT.EArg(id, index) -> "EArg", [ DInt64(int64 id); DInt64(int64 index) ] + | PT.EArg(id, index) -> "EArg", [ DInt64(int64 id); Dval.int (bigint index) ] // control flow | PT.EIf(id, cond, thenExpr, elseExpr) -> @@ -1028,8 +1028,8 @@ module Expr = | DEnum(_, _, [], "EVariable", [ DInt64 id; DString varName ]) -> PT.EVariable(uint64 id, varName) - | DEnum(_, _, [], "EArg", [ DInt64 id; DInt64 index ]) -> - PT.EArg(uint64 id, int index) + | DEnum(_, _, [], "EArg", [ DInt64 id; DInt index ]) -> + PT.EArg(uint64 id, int (DarkInt.toBigInt index)) // control flow | DEnum(_, _, [], "EIf", [ DInt64 id; cond; thenExpr; elseExpr ]) -> @@ -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/backend/src/LibExecution/RuntimeTypes.fs b/backend/src/LibExecution/RuntimeTypes.fs index a538dbfb3a..4c8e42c1fe 100644 --- a/backend/src/LibExecution/RuntimeTypes.fs +++ b/backend/src/LibExecution/RuntimeTypes.fs @@ -240,6 +240,23 @@ module DarkInt = | DarkInt.Finite i -> bigint i | DarkInt.Infinite b -> b + /// Checked narrowing to Int64: `Some` only when the value fits. An `Infinite` + /// is by invariant always outside Int64 range, so it is always `None`. + let toInt64 (di : DarkInt) : int64 option = + match di with + | DarkInt.Finite i -> Some i + | DarkInt.Infinite _ -> None + + /// Checked narrowing to a native `int` (Int32): `Some` only when the value + /// fits `[Int32.MinValue, Int32.MaxValue]`. + let toInt32 (di : DarkInt) : int option = + match di with + | DarkInt.Finite i when + i >= int64 System.Int32.MinValue && i <= int64 System.Int32.MaxValue + -> + Some(int i) + | _ -> None + let isZero (di : DarkInt) : bool = match di with | DarkInt.Finite i -> i = 0L @@ -1033,8 +1050,8 @@ module RuntimeError = | ConstructionWrongNumberOfFields of typeName : FQTypeName.FQTypeName * caseName : string * - expectedFieldCount : int64 * - actualFieldCount : int64 + expectedFieldCount : int * + actualFieldCount : int | ConstructionCaseNotFound of typeName : FQTypeName.FQTypeName * @@ -1042,7 +1059,7 @@ module RuntimeError = | ConstructionFieldOfWrongType of caseName : string * - fieldIndex : int64 * + fieldIndex : int * expectedType : ValueType * actualType : ValueType * actualValue : Dval @@ -1091,19 +1108,16 @@ module RuntimeError = // specific to fns | WrongNumberOfTypeArgsForFn of fn : FQFnName.FQFnName * - expected : int64 * - actual : int64 + expected : int * + actual : int | CannotApplyTypeArgsMoreThanOnce - | TooManyArgsForFn of - fn : FQFnName.FQFnName * - expected : int64 * - actual : int64 + | TooManyArgsForFn of fn : FQFnName.FQFnName * expected : int * actual : int | FnParameterNotExpectedType of fnName : FQFnName.FQFnName * - paramIndex : int64 * + paramIndex : int * paramName : string * expectedType : ValueType * actualType : ValueType * @@ -1117,7 +1131,7 @@ module RuntimeError = // specific to lambdas | CannotApplyTypeArgsToLambda - | TooManyArgsForLambda of lambdaExprId : id * expected : int64 * actual : int64 + | TooManyArgsForLambda of lambdaExprId : id * expected : int * actual : int module Statements = type Error = @@ -1185,8 +1199,8 @@ module RuntimeError = | WrongNumberOfTypeArgsForType of fn : FQTypeName.FQTypeName * - expected : int64 * - actual : int64 + expected : int * + actual : int | Enum of Enums.Error | Record of Records.Error diff --git a/backend/src/LibExecution/RuntimeTypesToDarkTypes.fs b/backend/src/LibExecution/RuntimeTypesToDarkTypes.fs index 124072a10a..d99b7c89b7 100644 --- a/backend/src/LibExecution/RuntimeTypesToDarkTypes.fs +++ b/backend/src/LibExecution/RuntimeTypesToDarkTypes.fs @@ -731,7 +731,7 @@ module Dval = // cannot be read. | DBlob(Ephemeral eph) -> mk "DBlobEphemeral" [ DUuid eph.id ] | DBlob(Persistent(hash, length)) -> - mk "DBlobPersistent" [ DString hash; DInt64 length ] + mk "DBlobPersistent" [ DString hash; DInt(DarkInt.ofBigInt (bigint length)) ] // Streams render as a stub tag for LSP/reflection only — they // can't round-trip (no live pull fn on the other side). @@ -815,8 +815,8 @@ module Dval = Exception.raiseInternal "Cannot rebuild an ephemeral blob from its reflected form; it contains only the blob id, not the bytes. Values that need to round-trip through DT must be promoted to Persistent first." [] - | DEnum(_, _, [], "DBlobPersistent", [ DString hash; DInt64 length ]) -> - DBlob(Persistent(hash, length)) + | DEnum(_, _, [], "DBlobPersistent", [ DString hash; DInt length ]) -> + DBlob(Persistent(hash, int64 (DarkInt.toBigInt length))) | DEnum(_, _, [], "DStreamStub", [ _elemType ]) -> Exception.raiseInternal @@ -1160,8 +1160,8 @@ module RuntimeError = "ConstructionWrongNumberOfFields", [ FQTypeName.toDT typeName DString caseName - DInt64 expectedFieldCount - DInt64 actualFieldCount ] + DInt(DarkInt.ofBigInt (bigint expectedFieldCount)) + DInt(DarkInt.ofBigInt (bigint actualFieldCount)) ] | RuntimeError.Enums.ConstructionCaseNotFound(typeName, caseName) -> "ConstructionCaseNotFound", [ FQTypeName.toDT typeName; DString caseName ] | RuntimeError.Enums.ConstructionFieldOfWrongType(caseName, @@ -1171,7 +1171,7 @@ module RuntimeError = actualValue) -> "ConstructionFieldOfWrongType", [ DString caseName - DInt64 fieldIndex + DInt(DarkInt.ofBigInt (bigint fieldIndex)) ValueType.toDT expectedType ValueType.toDT actualType Dval.toDT actualValue ] @@ -1188,8 +1188,8 @@ module RuntimeError = RuntimeError.Enums.ConstructionWrongNumberOfFields( FQTypeName.fromDT typeName, D.string caseName, - D.int64 expectedFieldCount, - D.int64 actualFieldCount + int (D.darkInt expectedFieldCount), + int (D.darkInt actualFieldCount) ) | DEnum(_, _, [], "ConstructionCaseNotFound", [ typeName; caseName ]) -> RuntimeError.Enums.ConstructionCaseNotFound( @@ -1203,7 +1203,7 @@ module RuntimeError = [ caseName; fieldIndex; expectedType; actualType; actualValue ]) -> RuntimeError.Enums.ConstructionFieldOfWrongType( D.string caseName, - D.int64 fieldIndex, + int (D.darkInt fieldIndex), ValueType.fromDT expectedType, ValueType.fromDT actualType, Dval.fromDT actualValue @@ -1225,11 +1225,16 @@ module RuntimeError = | RuntimeError.Applications.WrongNumberOfTypeArgsForFn(fn, expected, actual) -> "WrongNumberOfTypeArgsForFn", - [ FQFnName.toDT fn; DInt64 expected; DInt64 actual ] + [ FQFnName.toDT fn + DInt(DarkInt.ofBigInt (bigint expected)) + DInt(DarkInt.ofBigInt (bigint actual)) ] | RuntimeError.Applications.CannotApplyTypeArgsMoreThanOnce -> "CannotApplyTypeArgsMoreThanOnce", [] | RuntimeError.Applications.TooManyArgsForFn(fn, expected, actual) -> - "TooManyArgsForFn", [ FQFnName.toDT fn; DInt64 expected; DInt64 actual ] + "TooManyArgsForFn", + [ FQFnName.toDT fn + DInt(DarkInt.ofBigInt (bigint expected)) + DInt(DarkInt.ofBigInt (bigint actual)) ] | RuntimeError.Applications.FnParameterNotExpectedType(fnName, paramIndex, paramName, @@ -1238,7 +1243,7 @@ module RuntimeError = actualValue) -> "FnParameterNotExpectedType", [ FQFnName.toDT fnName - DInt64 paramIndex + DInt(DarkInt.ofBigInt (bigint paramIndex)) DString paramName ValueType.toDT expectedType ValueType.toDT actualType @@ -1260,7 +1265,9 @@ module RuntimeError = expected, actual) -> "TooManyArgsForLambda", - [ DUInt64 lambdaExprId; DInt64 expected; DInt64 actual ] + [ DUInt64 lambdaExprId + DInt(DarkInt.ofBigInt (bigint expected)) + DInt(DarkInt.ofBigInt (bigint actual)) ] DEnum(typeName, typeName, [], caseName, fields) @@ -1276,16 +1283,16 @@ module RuntimeError = | DEnum(_, _, [], "WrongNumberOfTypeArgsForFn", [ fn; expected; actual ]) -> RuntimeError.Applications.WrongNumberOfTypeArgsForFn( FQFnName.fromDT fn, - D.int64 expected, - D.int64 actual + int (D.darkInt expected), + int (D.darkInt actual) ) | DEnum(_, _, [], "CannotApplyTypeArgsMoreThanOnce", []) -> RuntimeError.Applications.CannotApplyTypeArgsMoreThanOnce | DEnum(_, _, [], "TooManyArgsForFn", [ fn; expected; actual ]) -> RuntimeError.Applications.TooManyArgsForFn( FQFnName.fromDT fn, - D.int64 expected, - D.int64 actual + int (D.darkInt expected), + int (D.darkInt actual) ) | DEnum(_, _, @@ -1294,7 +1301,7 @@ module RuntimeError = [ fnName; paramIndex; paramName; expectedType; actualType; actualValue ]) -> RuntimeError.Applications.FnParameterNotExpectedType( FQFnName.fromDT fnName, - D.int64 paramIndex, + int (D.darkInt paramIndex), D.string paramName, ValueType.fromDT expectedType, ValueType.fromDT actualType, @@ -1318,8 +1325,8 @@ module RuntimeError = | DEnum(_, _, [], "TooManyArgsForLambda", [ lambdaExprId; expected; actual ]) -> RuntimeError.Applications.TooManyArgsForLambda( D.uInt64 lambdaExprId, - D.int64 expected, - D.int64 actual + int (D.darkInt expected), + int (D.darkInt actual) ) | _ -> Exception.raiseInternal "Invalid Applications.Error" [] @@ -1473,7 +1480,9 @@ module RuntimeError = "DeprecatedItemHalted", [ Hash.toDT target ] | RuntimeError.WrongNumberOfTypeArgsForType(fn, expected, actual) -> "WrongNumberOfTypeArgsForType", - [ FQTypeName.toDT fn; DInt64 expected; DInt64 actual ] + [ FQTypeName.toDT fn + DInt(DarkInt.ofBigInt (bigint expected)) + DInt(DarkInt.ofBigInt (bigint actual)) ] | RuntimeError.Record e -> "Record", [ Records.toDT e ] | RuntimeError.Enum e -> "Enum", [ Enums.toDT e ] | RuntimeError.Apply e -> "Apply", [ Applications.toDT e ] @@ -1542,8 +1551,8 @@ module RuntimeError = | DEnum(_, _, [], "WrongNumberOfTypeArgsForType", [ fn; expected; actual ]) -> RuntimeError.WrongNumberOfTypeArgsForType( FQTypeName.fromDT fn, - D.int64 expected, - D.int64 actual + int (D.darkInt expected), + int (D.darkInt actual) ) | DEnum(_, _, [], "Record", [ e ]) -> RuntimeError.Record(Records.fromDT e) | DEnum(_, _, [], "Enum", [ e ]) -> RuntimeError.Enum(Enums.fromDT e) 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/backend/testfiles/execution/cloud/db.dark b/backend/testfiles/execution/cloud/db.dark index 945349ac20..3c966adfb9 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 @@ -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 @@ -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")) = [] @@ -904,7 +904,7 @@ module CompiledFunctions = (friends (fun p -> Stdlib.DateTime.lessThanOrEqualTo p.dob - (Stdlib.DateTime.addSeconds (Stdlib.DateTime.now ()) 1L))) = [ " Chandler " + (Stdlib.DateTime.addSeconds (Stdlib.DateTime.now ()) 1I))) = [ " Chandler " "GrumpyCat" "Rachel" "Ross" ] @@ -912,7 +912,7 @@ module CompiledFunctions = (friends (fun p -> Stdlib.DateTime.lessThanOrEqualTo p.dob - (Stdlib.DateTime.subtractSeconds (Stdlib.DateTime.now ()) 1L))) = [ " Chandler " + (Stdlib.DateTime.subtractSeconds (Stdlib.DateTime.now ()) 1I))) = [ " Chandler " "GrumpyCat" "Rachel" "Ross" ] @@ -947,10 +947,10 @@ module CompiledFunctions = (friends (fun p -> Stdlib.Int64.greaterThanOrEqualTo p.height - Darklang.Test.Values.intValue)) = [ " Chandler " - "GrumpyCat" - "Rachel" - "Ross" ] + Darklang.Test.Values.int64Value)) = [ " Chandler " + "GrumpyCat" + "Rachel" + "Ross" ] // String (friends (fun p -> @@ -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 -> @@ -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 +((Stdlib.DB.generateKey ()) |> Stdlib.String.length) = 36I diff --git a/backend/testfiles/execution/language/big.dark b/backend/testfiles/execution/language/big.dark index a102414b0f..695b79b6b1 100644 --- a/backend/testfiles/execution/language/big.dark +++ b/backend/testfiles/execution/language/big.dark @@ -29,9 +29,9 @@ module BigTestCase = |> (++) "\nhex64Encode: " |> (++) hexEncode |> (++) "\nstring length: " - |> (++) (Stdlib.Int64.toString_v0 sl) + |> (++) (Stdlib.Int.toString 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/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/custom-data/values.dark b/backend/testfiles/execution/language/custom-data/values.dark index 960f4ae8c5..78c10dd8b2 100644 --- a/backend/testfiles/execution/language/custom-data/values.dark +++ b/backend/testfiles/execution/language/custom-data/values.dark @@ -4,9 +4,13 @@ module UserDefined = "test" = stringValue UserDefined.stringValue = "test" - let intValue = 5L - intValue = 5L - UserDefined.intValue = 5L + let int64Value = 5L + int64Value = 5L + UserDefined.int64Value = 5L + + let intValue = 5I + intValue = 5I + UserDefined.intValue = 5I let uint64Value = 5UL uint64Value = 5UL @@ -79,8 +83,11 @@ module Package = Darklang.Test.Values.uint128Value = 5Z Darklang.Test.Values.uint128Value = 5Z - Darklang.Test.Values.intValue = 5L - Darklang.Test.Values.intValue = 5L + Darklang.Test.Values.int64Value = 5L + Darklang.Test.Values.int64Value = 5L + + Darklang.Test.Values.intValue = 5I + Darklang.Test.Values.intValue = 5I Darklang.Test.Values.uint64Value = 5UL Darklang.Test.Values.uint64Value = 5UL diff --git a/backend/testfiles/execution/language/flow-control/ematch.dark b/backend/testfiles/execution/language/flow-control/ematch.dark index a15fe12b87..b0a2524c60 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" @@ -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/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/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/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/backend/testfiles/execution/stdlib/date.dark b/backend/testfiles/execution/stdlib/date.dark index aaef4b56ea..8403de9c54 100644 --- a/backend/testfiles/execution/stdlib/date.dark +++ b/backend/testfiles/execution/stdlib/date.dark @@ -150,56 +150,56 @@ module GreaterThanOrEquals = Stdlib.DateTime.greaterThanOrEqualTo (d "2020-11-26T04:37:46Z") (d "2020-11-26T04:37:46Z") = true module Fields = - Stdlib.DateTime.year_v0 (d "2019-07-28T22:42:36Z") = 2019L - Stdlib.DateTime.month_v0 (d "2019-07-28T22:42:36Z") = 7L - Stdlib.DateTime.day_v0 (d "2019-07-28T22:42:36Z") = 28L - Stdlib.DateTime.hour (d "2019-12-27T03:27:36Z") = 3L // Leif's test case - Stdlib.DateTime.minute (d "2019-07-28T22:42:36Z") = 42L - Stdlib.DateTime.weekday_v0 (d "2019-07-22T22:42:36Z") = 1L // Monday - Stdlib.DateTime.weekday_v0 (d "2019-07-23T22:42:36Z") = 2L - Stdlib.DateTime.weekday_v0 (d "2019-07-24T22:42:36Z") = 3L - Stdlib.DateTime.weekday_v0 (d "2019-07-25T22:42:36Z") = 4L - Stdlib.DateTime.weekday_v0 (d "2019-07-26T22:42:36Z") = 5L - Stdlib.DateTime.weekday_v0 (d "2019-07-27T22:42:36Z") = 6L - Stdlib.DateTime.weekday_v0 (d "2019-07-28T22:42:36Z") = 7L + Stdlib.DateTime.year_v0 (d "2019-07-28T22:42:36Z") = 2019I + Stdlib.DateTime.month_v0 (d "2019-07-28T22:42:36Z") = 7I + Stdlib.DateTime.day_v0 (d "2019-07-28T22:42:36Z") = 28I + Stdlib.DateTime.hour (d "2019-12-27T03:27:36Z") = 3I // Leif's test case + Stdlib.DateTime.minute (d "2019-07-28T22:42:36Z") = 42I + Stdlib.DateTime.weekday_v0 (d "2019-07-22T22:42:36Z") = 1I // Monday + Stdlib.DateTime.weekday_v0 (d "2019-07-23T22:42:36Z") = 2I + Stdlib.DateTime.weekday_v0 (d "2019-07-24T22:42:36Z") = 3I + Stdlib.DateTime.weekday_v0 (d "2019-07-25T22:42:36Z") = 4I + Stdlib.DateTime.weekday_v0 (d "2019-07-26T22:42:36Z") = 5I + Stdlib.DateTime.weekday_v0 (d "2019-07-27T22:42:36Z") = 6I + Stdlib.DateTime.weekday_v0 (d "2019-07-28T22:42:36Z") = 7I module Epoch1919 = - Stdlib.DateTime.year_v0 (d "1919-07-28T22:42:36Z") = 1919L - Stdlib.DateTime.month_v0 (d "1919-07-28T22:42:36Z") = 7L - Stdlib.DateTime.day_v0 (d "1919-07-28T22:42:36Z") = 28L - Stdlib.DateTime.weekday_v0 (d "1919-07-28T22:42:36Z") = 1L - Stdlib.DateTime.hour (d "1919-12-27T03:27:36Z") = 3L - Stdlib.DateTime.minute (d "1919-07-28T22:42:36Z") = 42L - Stdlib.DateTime.second (d "1919-07-28T22:42:36Z") = 36L + Stdlib.DateTime.year_v0 (d "1919-07-28T22:42:36Z") = 1919I + Stdlib.DateTime.month_v0 (d "1919-07-28T22:42:36Z") = 7I + Stdlib.DateTime.day_v0 (d "1919-07-28T22:42:36Z") = 28I + Stdlib.DateTime.weekday_v0 (d "1919-07-28T22:42:36Z") = 1I + Stdlib.DateTime.hour (d "1919-12-27T03:27:36Z") = 3I + Stdlib.DateTime.minute (d "1919-07-28T22:42:36Z") = 42I + Stdlib.DateTime.second (d "1919-07-28T22:42:36Z") = 36I module Epoch1969 = - Stdlib.DateTime.year_v0 (d "1969-07-28T22:42:36Z") = 1969L - Stdlib.DateTime.month_v0 (d "1969-07-28T22:42:36Z") = 7L - Stdlib.DateTime.day_v0 (d "1969-07-28T22:42:36Z") = 28L - Stdlib.DateTime.weekday_v0 (d "1969-07-28T22:42:36Z") = 1L - Stdlib.DateTime.hour (d "1969-12-27T03:27:36Z") = 3L - Stdlib.DateTime.minute (d "1969-07-28T22:42:36Z") = 42L - Stdlib.DateTime.second (d "1969-07-28T22:42:36Z") = 36L + Stdlib.DateTime.year_v0 (d "1969-07-28T22:42:36Z") = 1969I + Stdlib.DateTime.month_v0 (d "1969-07-28T22:42:36Z") = 7I + Stdlib.DateTime.day_v0 (d "1969-07-28T22:42:36Z") = 28I + Stdlib.DateTime.weekday_v0 (d "1969-07-28T22:42:36Z") = 1I + Stdlib.DateTime.hour (d "1969-12-27T03:27:36Z") = 3I + Stdlib.DateTime.minute (d "1969-07-28T22:42:36Z") = 42I + Stdlib.DateTime.second (d "1969-07-28T22:42:36Z") = 36I module Epoch1970 = - Stdlib.DateTime.year_v0 (d "1970-07-28T22:42:36Z") = 1970L - Stdlib.DateTime.month_v0 (d "1970-07-28T22:42:36Z") = 7L - Stdlib.DateTime.day_v0 (d "1970-07-28T22:42:36Z") = 28L - Stdlib.DateTime.weekday_v0 (d "1970-07-28T22:42:36Z") = 2L - Stdlib.DateTime.hour (d "1970-12-27T03:27:36Z") = 3L - Stdlib.DateTime.minute (d "1970-07-28T22:42:36Z") = 42L - Stdlib.DateTime.minute (d "1970-07-28T22:42:36Z") = 42L - Stdlib.DateTime.second (d "1970-07-28T22:42:36Z") = 36L - Stdlib.DateTime.second (d "1970-07-28T22:42:36Z") = 36L + Stdlib.DateTime.year_v0 (d "1970-07-28T22:42:36Z") = 1970I + Stdlib.DateTime.month_v0 (d "1970-07-28T22:42:36Z") = 7I + Stdlib.DateTime.day_v0 (d "1970-07-28T22:42:36Z") = 28I + Stdlib.DateTime.weekday_v0 (d "1970-07-28T22:42:36Z") = 2I + Stdlib.DateTime.hour (d "1970-12-27T03:27:36Z") = 3I + Stdlib.DateTime.minute (d "1970-07-28T22:42:36Z") = 42I + Stdlib.DateTime.minute (d "1970-07-28T22:42:36Z") = 42I + Stdlib.DateTime.second (d "1970-07-28T22:42:36Z") = 36I + Stdlib.DateTime.second (d "1970-07-28T22:42:36Z") = 36I module Conversion = Stdlib.DateTime.toString_v0 (d "2019-07-28T22:42:36Z") = "2019-07-28T22:42:36Z" Stdlib.DateTime.atStartOfDay_v0 (d "2019-07-28T22:42:36Z") = (d "2019-07-28T00:00:00Z") - Stdlib.DateTime.toSeconds_v0 (d "2019-07-28T22:42:36Z") = 1564353756L - Stdlib.DateTime.toSeconds_v0 (d "2075-11-14T11:01:35Z") = 3340954895L + Stdlib.DateTime.toSeconds_v0 (d "2019-07-28T22:42:36Z") = 1564353756I + Stdlib.DateTime.toSeconds_v0 (d "2075-11-14T11:01:35Z") = 3340954895I Stdlib.DateTime.toStringISO8601BasicDateTime_v0 (d "2019-07-28T22:42:36Z") = "20190728T224236Z" Stdlib.DateTime.toStringISO8601BasicDateTime_v0 (d "1919-07-28T22:42:36Z") = "19190728T224236Z" @@ -207,7 +207,18 @@ module Conversion = Stdlib.DateTime.toStringISO8601BasicDate_v0 (d "2019-07-28T22:42:36Z") = "20190728" Stdlib.DateTime.toStringISO8601BasicDate_v0 (d "1069-07-28T22:42:36Z") = "10690728" - 1095379198L |> Stdlib.DateTime.fromSeconds_v0 |> Stdlib.DateTime.toSeconds_v0 = 1095379198L + 1095379198I |> Stdlib.DateTime.fromSeconds_v0 |> Stdlib.DateTime.toSeconds_v0 = 1095379198I + + // seconds past Int64 range can't be represented; surface a Dark error + (2I ^ 63I) |> Stdlib.DateTime.fromSeconds_v0 = + error="Encountered out-of-range value for type of Int" + + // Int64.MaxValue fits int64 but is past NodaTime's instant range; the host + // exception is turned into a Dark error rather than escaping + 9223372036854775807I |> Stdlib.DateTime.fromSeconds_v0 = + error="Encountered out-of-range value for type of Int" + Stdlib.DateTime.addSeconds_v0 (Stdlib.DateTime.fromSeconds_v0 0I) 9223372036854775807I = + error="Encountered out-of-range value for type of Int" (d "2019-07-28T22:42:36Z") |> Stdlib.DateTime.toSeconds_v0 @@ -216,39 +227,39 @@ module Conversion = // Stdlib.DateTime.today_v0 |> Stdlib.DateTime.toString_v0 = "2020-10-17T00:00:00Z" // todo, how can we test this module AddingSeconds = - let a (d1: String) (s: Int64) : DateTime = + let a (d1: String) (s: Int) : DateTime = Stdlib.DateTime.addSeconds_v0 (d d1) s - a "2020-11-26T04:37:46Z" 0L = (d "2020-11-26T04:37:46Z") - a "2020-11-26T04:37:46Z" 1L = (d "2020-11-26T04:37:47Z") - a "2020-11-26T04:37:46Z" 10L = (d "2020-11-26T04:37:56Z") - a "2020-11-26T04:37:46Z" 1000000L = (d "2020-12-07T18:24:26Z") - a "2020-11-26T04:37:46Z" -10L = (d "2020-11-26T04:37:36Z") + a "2020-11-26T04:37:46Z" 0I = (d "2020-11-26T04:37:46Z") + a "2020-11-26T04:37:46Z" 1I = (d "2020-11-26T04:37:47Z") + a "2020-11-26T04:37:46Z" 10I = (d "2020-11-26T04:37:56Z") + a "2020-11-26T04:37:46Z" 1000000I = (d "2020-12-07T18:24:26Z") + a "2020-11-26T04:37:46Z" -10I = (d "2020-11-26T04:37:36Z") module SubtractingSeconds = - let sub (d1: String) (s: Int64) : DateTime = + let sub (d1: String) (s: Int) : DateTime = Stdlib.DateTime.subtractSeconds (d d1) s - sub "2020-11-26T04:37:46Z" 0L = (d "2020-11-26T04:37:46Z") - sub "2020-11-26T04:37:46Z" 1L = (d "2020-11-26T04:37:45Z") - sub "2020-11-26T04:37:46Z" 10L = (d "2020-11-26T04:37:36Z") - sub "2020-11-26T04:37:46Z" 1000000L = (d "2020-11-14T14:51:06Z") - sub "2020-11-26T04:37:46Z" -10L = (d "2020-11-26T04:37:56Z") + sub "2020-11-26T04:37:46Z" 0I = (d "2020-11-26T04:37:46Z") + sub "2020-11-26T04:37:46Z" 1I = (d "2020-11-26T04:37:45Z") + sub "2020-11-26T04:37:46Z" 10I = (d "2020-11-26T04:37:36Z") + sub "2020-11-26T04:37:46Z" 1000000I = (d "2020-11-14T14:51:06Z") + sub "2020-11-26T04:37:46Z" -10I = (d "2020-11-26T04:37:56Z") module Difference = - let s (d1: String) (d2: String) : Int64 = + let s (d1: String) (d2: String) : Int = Stdlib.DateTime.subtract (d d1) (d d2) - s "2020-11-26T04:37:46Z" "2020-11-26T04:37:46Z" = 0L - s "2020-11-26T04:37:46Z" "2020-11-26T04:37:45Z" = 1L - s "2020-11-26T04:37:46Z" "2020-11-26T04:37:36Z" = 10L - s "2020-11-26T04:37:46Z" "2020-11-26T04:37:56Z" = -10L - s "2020-11-26T04:37:46Z" "2020-11-14T14:51:06Z" = 1000000L - s "2020-11-14T14:51:06Z" "2020-11-26T04:37:46Z" = -1000000L - s "1921-01-01T12:00:00Z" "2021-01-01T12:00:00Z" = -3155760000L - s "2021-01-01T12:00:00Z" "1921-01-01T12:00:00Z" = 3155760000L + s "2020-11-26T04:37:46Z" "2020-11-26T04:37:46Z" = 0I + s "2020-11-26T04:37:46Z" "2020-11-26T04:37:45Z" = 1I + s "2020-11-26T04:37:46Z" "2020-11-26T04:37:36Z" = 10I + s "2020-11-26T04:37:46Z" "2020-11-26T04:37:56Z" = -10I + s "2020-11-26T04:37:46Z" "2020-11-14T14:51:06Z" = 1000000I + s "2020-11-14T14:51:06Z" "2020-11-26T04:37:46Z" = -1000000I + s "1921-01-01T12:00:00Z" "2021-01-01T12:00:00Z" = -3155760000I + s "2021-01-01T12:00:00Z" "1921-01-01T12:00:00Z" = 3155760000I module MillisecondParsing = @@ -268,63 +279,63 @@ module MillisecondParsing = module MillisecondConversion = - Stdlib.DateTime.toMilliseconds (d "2019-07-28T22:42:36Z") = 1564353756000L - Stdlib.DateTime.toMilliseconds (d "1970-01-01T00:00:00Z") = 0L + Stdlib.DateTime.toMilliseconds (d "2019-07-28T22:42:36Z") = 1564353756000I + Stdlib.DateTime.toMilliseconds (d "1970-01-01T00:00:00Z") = 0I - 1564353756000L + 1564353756000I |> Stdlib.DateTime.fromMilliseconds - |> Stdlib.DateTime.toMilliseconds = 1564353756000L + |> Stdlib.DateTime.toMilliseconds = 1564353756000I - 1564353756123L + 1564353756123I |> Stdlib.DateTime.fromMilliseconds - |> Stdlib.DateTime.toMilliseconds = 1564353756123L + |> Stdlib.DateTime.toMilliseconds = 1564353756123I - 1564353756123L + 1564353756123I |> Stdlib.DateTime.fromMilliseconds |> Stdlib.DateTime.toString_v0 = "2019-07-28T22:42:36.123Z" // Round-trip: ms -> DateTime -> ms - 0L |> Stdlib.DateTime.fromMilliseconds |> Stdlib.DateTime.toMilliseconds = 0L - -1000L |> Stdlib.DateTime.fromMilliseconds |> Stdlib.DateTime.toMilliseconds = -1000L + 0I |> Stdlib.DateTime.fromMilliseconds |> Stdlib.DateTime.toMilliseconds = 0I + -1000I |> Stdlib.DateTime.fromMilliseconds |> Stdlib.DateTime.toMilliseconds = -1000I module MillisecondField = let dMs (datestr: String) : DateTime = (Stdlib.DateTime.parse datestr) |> Builtin.unwrap - Stdlib.DateTime.millisecond (dMs "2019-07-28T22:42:36.456Z") = 456L - Stdlib.DateTime.millisecond (dMs "2019-07-28T22:42:36.000Z") = 0L - Stdlib.DateTime.millisecond (d "2019-07-28T22:42:36Z") = 0L - Stdlib.DateTime.millisecond (dMs "2019-07-28T22:42:36.001Z") = 1L - Stdlib.DateTime.millisecond (dMs "2019-07-28T22:42:36.999Z") = 999L + Stdlib.DateTime.millisecond (dMs "2019-07-28T22:42:36.456Z") = 456I + Stdlib.DateTime.millisecond (dMs "2019-07-28T22:42:36.000Z") = 0I + Stdlib.DateTime.millisecond (d "2019-07-28T22:42:36Z") = 0I + Stdlib.DateTime.millisecond (dMs "2019-07-28T22:42:36.001Z") = 1I + Stdlib.DateTime.millisecond (dMs "2019-07-28T22:42:36.999Z") = 999I module AddMilliseconds = - let ams (d1: String) (ms: Int64) : DateTime = + let ams (d1: String) (ms: Int) : DateTime = Stdlib.DateTime.addMilliseconds (d d1) ms - ams "2020-11-26T04:37:46Z" 0L = (d "2020-11-26T04:37:46Z") - (ams "2020-11-26T04:37:46Z" 500L) |> Stdlib.DateTime.millisecond = 500L - ams "2020-11-26T04:37:46Z" 1000L = (d "2020-11-26T04:37:47Z") - (ams "2020-11-26T04:37:46Z" 1500L) |> Stdlib.DateTime.toString_v0 = "2020-11-26T04:37:47.500Z" - (ams "2020-11-26T04:37:46Z" -500L) |> Stdlib.DateTime.toString_v0 = "2020-11-26T04:37:45.500Z" + ams "2020-11-26T04:37:46Z" 0I = (d "2020-11-26T04:37:46Z") + (ams "2020-11-26T04:37:46Z" 500I) |> Stdlib.DateTime.millisecond = 500I + ams "2020-11-26T04:37:46Z" 1000I = (d "2020-11-26T04:37:47Z") + (ams "2020-11-26T04:37:46Z" 1500I) |> Stdlib.DateTime.toString_v0 = "2020-11-26T04:37:47.500Z" + (ams "2020-11-26T04:37:46Z" -500I) |> Stdlib.DateTime.toString_v0 = "2020-11-26T04:37:45.500Z" module SubtractMilliseconds = - let sms (d1: String) (ms: Int64) : DateTime = + let sms (d1: String) (ms: Int) : DateTime = Stdlib.DateTime.subtractMilliseconds (d d1) ms - sms "2020-11-26T04:37:46Z" 0L = (d "2020-11-26T04:37:46Z") - (sms "2020-11-26T04:37:46Z" 500L) |> Stdlib.DateTime.millisecond = 500L - sms "2020-11-26T04:37:46Z" 1000L = (d "2020-11-26T04:37:45Z") - (sms "2020-11-26T04:37:46Z" -500L) |> Stdlib.DateTime.toString_v0 = "2020-11-26T04:37:46.500Z" + sms "2020-11-26T04:37:46Z" 0I = (d "2020-11-26T04:37:46Z") + (sms "2020-11-26T04:37:46Z" 500I) |> Stdlib.DateTime.millisecond = 500I + sms "2020-11-26T04:37:46Z" 1000I = (d "2020-11-26T04:37:45Z") + (sms "2020-11-26T04:37:46Z" -500I) |> Stdlib.DateTime.toString_v0 = "2020-11-26T04:37:46.500Z" module DifferenceMs = - let sMs (d1: String) (d2: String) : Int64 = + let sMs (d1: String) (d2: String) : Int = Stdlib.DateTime.subtractMs (d d1) (d d2) - sMs "2020-11-26T04:37:46Z" "2020-11-26T04:37:46Z" = 0L - sMs "2020-11-26T04:37:46Z" "2020-11-26T04:37:45Z" = 1000L - sMs "2020-11-26T04:37:46Z" "2020-11-26T04:37:56Z" = -10000L - sMs "2021-01-01T00:00:00Z" "2020-01-01T00:00:00Z" = 31622400000L \ No newline at end of file + sMs "2020-11-26T04:37:46Z" "2020-11-26T04:37:46Z" = 0I + sMs "2020-11-26T04:37:46Z" "2020-11-26T04:37:45Z" = 1000I + sMs "2020-11-26T04:37:46Z" "2020-11-26T04:37:56Z" = -10000I + sMs "2021-01-01T00:00:00Z" "2020-01-01T00:00:00Z" = 31622400000I \ No newline at end of file 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/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/backend/testfiles/execution/stdlib/earg.dark b/backend/testfiles/execution/stdlib/earg.dark index 7c660834a0..386e50a7d5 100644 --- a/backend/testfiles/execution/stdlib/earg.dark +++ b/backend/testfiles/execution/stdlib/earg.dark @@ -1,72 +1,72 @@ module Test = - let addTwo (earg1: Int64) (earg2: Int64): Int64 = - Stdlib.Int64.add earg1 earg2 + let addTwo (earg1: Int) (earg2: Int): Int = + Stdlib.Int.add earg1 earg2 - let shadowTest (shadowedEarg: Int64): Int64 = - let shadowedEarg = 42L + let shadowTest (shadowedEarg: Int): Int = + let shadowedEarg = 42I shadowedEarg // This should be EVariable, not EArg after shadowing - let argAndLocalVar (mixedEarg: Int64): Int64 = - let localVarNotEarg = 10L - Stdlib.Int64.add mixedEarg localVarNotEarg // mixedEarg=EArg(0), localVarNotEarg=EVariable("localVarNotEarg") + let argAndLocalVar (mixedEarg: Int): Int = + let localVarNotEarg = 10I + Stdlib.Int.add mixedEarg localVarNotEarg // mixedEarg=EArg(0), localVarNotEarg=EVariable("localVarNotEarg") - let nestedShadowing (eargOne: Int64) (eargTwo: Int64): Int64 = + let nestedShadowing (eargOne: Int) (eargTwo: Int): Int = let a = - let eargOne = 100L - Stdlib.Int64.add eargOne eargTwo - Stdlib.Int64.add a eargOne + let eargOne = 100I + Stdlib.Int.add eargOne eargTwo + Stdlib.Int.add a eargOne - let lambdaTest (eargX: Int64) : Int64 = - let addX = (fun eargX -> Stdlib.Int64.add eargX 1L) + let lambdaTest (eargX: Int) : Int = + let addX = (fun eargX -> Stdlib.Int.add eargX 1I) let result = eargX + (addX eargX) result - let matchArgName (value: Int64) : Int64 = + let matchArgName (value: Int) : Int = match value with - | 0L -> 100L - | value -> value * 2L + | 0I -> 100I + | value -> value * 2I - let matchWithNestedShadowing (x: Int64) (y: Int64) : Int64 = + let matchWithNestedShadowing (x: Int) (y: Int) : Int = match x with - | 0L -> y + | 0I -> y | x -> // This 'x' shadows the parameter - let y = x * 3L // This 'y' shadows the second parameter + let y = x * 3I // This 'y' shadows the second parameter match y with - | 6L -> 600L - | y -> y + 10L // This 'y' shadows both parameter and let binding + | 6I -> 600I + | y -> y + 10I // This 'y' shadows both parameter and let binding - let matchWithNestedShadowing2 (x: Int64) (y: Int64) : Int64 = + let matchWithNestedShadowing2 (x: Int) (y: Int) : Int = match y with - | 0L -> y - | x -> x * 3L // This 'x' shadows the first parameter + | 0I -> y + | x -> x * 3I // This 'x' shadows the first parameter - let tupleMatchWithArgShadowing (data: (Int64 * String)) : String = + let tupleMatchWithArgShadowing (data: (Int * String)) : String = match data with - | (0L, result) -> result - | (1L, data) -> data ++ "_modified" // 'data' shadows the parameter - | (data, text) -> Stdlib.Int64.toString data ++ "_" ++ text // 'data' shadows parameter + | (0I, result) -> result + | (1I, data) -> data ++ "_modified" // 'data' shadows the parameter + | (data, text) -> Stdlib.Int.toString data ++ "_" ++ text // 'data' shadows parameter -Test.addTwo 3L 4L = 7L +Test.addTwo 3I 4I = 7I -Test.shadowTest 999L = 42L +Test.shadowTest 999I = 42I -Test.argAndLocalVar 5L = 15L +Test.argAndLocalVar 5I = 15I -Test.nestedShadowing 1L 2L = 103L +Test.nestedShadowing 1I 2I = 103I -Test.lambdaTest 10L = 21L +Test.lambdaTest 10I = 21I -Test.matchArgName 0L = 100L -Test.matchArgName 5L = 10L +Test.matchArgName 0I = 100I +Test.matchArgName 5I = 10I -Test.matchWithNestedShadowing 0L 42L = 42L -Test.matchWithNestedShadowing 2L 99L = 600L -Test.matchWithNestedShadowing 3L 99L = 19L -Test.matchWithNestedShadowing2 5L 0L = 0L -Test.matchWithNestedShadowing2 5L 4L = 12L +Test.matchWithNestedShadowing 0I 42I = 42I +Test.matchWithNestedShadowing 2I 99I = 600I +Test.matchWithNestedShadowing 3I 99I = 19I +Test.matchWithNestedShadowing2 5I 0I = 0I +Test.matchWithNestedShadowing2 5I 4I = 12I -Test.tupleMatchWithArgShadowing (0L, "hello") = "hello" -Test.tupleMatchWithArgShadowing (1L, "test") = "test_modified" -Test.tupleMatchWithArgShadowing (5L, "world") = "5_world" +Test.tupleMatchWithArgShadowing (0I, "hello") = "hello" +Test.tupleMatchWithArgShadowing (1I, "test") = "test_modified" +Test.tupleMatchWithArgShadowing (5I, "world") = "5_world" diff --git a/backend/testfiles/execution/stdlib/eself.dark b/backend/testfiles/execution/stdlib/eself.dark index 5bc8c0c0c5..632fb90296 100644 --- a/backend/testfiles/execution/stdlib/eself.dark +++ b/backend/testfiles/execution/stdlib/eself.dark @@ -1,167 +1,167 @@ // Tests for ESelf (recursive function calls) module ESelfTests = - let factorial (n: Int64): Int64 = - if Stdlib.Int64.lessThanOrEqualTo n 1L then - 1L + let factorial (n: Int): Int = + if Stdlib.Int.lessThanOrEqualTo n 1I then + 1I else - Stdlib.Int64.multiply n (factorial (Stdlib.Int64.subtract n 1L)) + Stdlib.Int.multiply n (factorial (Stdlib.Int.subtract n 1I)) - let fibonacci (n: Int64): Int64 = - if Stdlib.Int64.lessThanOrEqualTo n 1L then + let fibonacci (n: Int): Int = + if Stdlib.Int.lessThanOrEqualTo n 1I then n else - Stdlib.Int64.add - (ESelfTests.fibonacci (Stdlib.Int64.subtract n 1L)) - (ESelfTests.fibonacci (Stdlib.Int64.subtract n 2L)) + Stdlib.Int.add + (ESelfTests.fibonacci (Stdlib.Int.subtract n 1I)) + (ESelfTests.fibonacci (Stdlib.Int.subtract n 2I)) - let sumUpTo (n: Int64): Int64 = - if Stdlib.Int64.lessThanOrEqualTo n 0L then - 0L + let sumUpTo (n: Int): Int = + if Stdlib.Int.lessThanOrEqualTo n 0I then + 0I else - Stdlib.Int64.add n (ESelfTests.sumUpTo (Stdlib.Int64.subtract n 1L)) + Stdlib.Int.add n (ESelfTests.sumUpTo (Stdlib.Int.subtract n 1I)) module ShadowingTest = - let factorialWithShadowing (n: Int64): (String * Int64) = - if Stdlib.Int64.lessThanOrEqualTo n 1L then - ("base_case", 1L) + let factorialWithShadowing (n: Int): (String * Int) = + if Stdlib.Int.lessThanOrEqualTo n 1I then + ("base_case", 1I) else let factorialWithShadowing = "shadowed" - let result = Stdlib.Int64.multiply n ((ShadowingTest.factorialWithShadowing (Stdlib.Int64.subtract n 1L)) |> Stdlib.Tuple2.second) + let result = Stdlib.Int.multiply n ((ShadowingTest.factorialWithShadowing (Stdlib.Int.subtract n 1I)) |> Stdlib.Tuple2.second) (factorialWithShadowing , result) - let factorialWithShadowingError (n: Int64): (String * Int64) = - if Stdlib.Int64.lessThanOrEqualTo n 1L then - ("base_case", 1L) + let factorialWithShadowingError (n: Int): (String * Int) = + if Stdlib.Int.lessThanOrEqualTo n 1I then + ("base_case", 1I) else let factorialWithShadowingError = "shadowed" - let result = Stdlib.Int64.multiply n ((factorialWithShadowingError (Stdlib.Int64.subtract n 1L)) |> Stdlib.Tuple2.second) + let result = Stdlib.Int.multiply n ((factorialWithShadowingError (Stdlib.Int.subtract n 1I)) |> Stdlib.Tuple2.second) (factorialWithShadowingError , result) - let incrementWithShadowing (y: Int64) (z: Int64): Int64 = - if Stdlib.Int64.lessThanOrEqualTo z 0L then + let incrementWithShadowing (y: Int) (z: Int): Int = + if Stdlib.Int.lessThanOrEqualTo z 0I then y else - let result = incrementWithShadowing y (Stdlib.Int64.subtract z 1L) - let incrementWithShadowing = (fun x -> Stdlib.Int64.add x 2L) + let result = incrementWithShadowing y (Stdlib.Int.subtract z 1I) + let incrementWithShadowing = (fun x -> Stdlib.Int.add x 2I) let lambdaResult = incrementWithShadowing z - Stdlib.Int64.add result lambdaResult + Stdlib.Int.add result lambdaResult - let matchWithShadowing (x: Int64) : Int64 = + let matchWithShadowing (x: Int) : Int = match x with - | 0L -> 0L - | 1L -> matchWithShadowing 0L - | 2L -> - let matchWithShadowing = (fun v -> v * 4L) - matchWithShadowing 2L - | matchWithShadowing -> matchWithShadowing + 1L + | 0I -> 0I + | 1I -> matchWithShadowing 0I + | 2I -> + let matchWithShadowing = (fun v -> v * 4I) + matchWithShadowing 2I + | matchWithShadowing -> matchWithShadowing + 1I - let tupleMatchWithShadowing (x: Int64 * Int64) : Int64 = + let tupleMatchWithShadowing (x: Int * Int) : Int = match x with - | (0L, _) -> 0L - | (1L, n) -> tupleMatchWithShadowing (0L, n) - | (2L, v) -> - let tupleMatchWithShadowing = (fun x -> x * 10L) + | (0I, _) -> 0I + | (1I, n) -> tupleMatchWithShadowing (0I, n) + | (2I, v) -> + let tupleMatchWithShadowing = (fun x -> x * 10I) tupleMatchWithShadowing v | (a, tupleMatchWithShadowing) -> a + tupleMatchWithShadowing - let letBindingShadowing (x: Int64) : List = - let letBindingShadowing = (fun v -> v * 3L) - let letBindingShadowing = [ 10L; letBindingShadowing x ] + let letBindingShadowing (x: Int) : List = + let letBindingShadowing = (fun v -> v * 3I) + let letBindingShadowing = [ 10I; letBindingShadowing x ] let letBindingShadowing = Stdlib.List.reverse letBindingShadowing letBindingShadowing - let conditionalShadowing (x: Int64) : Int64 = - if x <= 0L then - 0L - elif x < 3L then - let conditionalShadowing = (fun v w -> v * 5L + w) - conditionalShadowing x 2L - elif x < 5L then - let conditionalShadowing = (fun v -> v * 3L) + let conditionalShadowing (x: Int) : Int = + if x <= 0I then + 0I + elif x < 3I then + let conditionalShadowing = (fun v w -> v * 5I + w) + conditionalShadowing x 2I + elif x < 5I then + let conditionalShadowing = (fun v -> v * 3I) conditionalShadowing x else - x + conditionalShadowing (x - 1L) + x + conditionalShadowing (x - 1I) - let pipeWithShadowing (x: Int64) : Int64 = + let pipeWithShadowing (x: Int) : Int = match x with - | 0L -> 0L - | 1L -> 0L |> pipeWithShadowing - | 2L -> - let pipeWithShadowing = (fun v -> v * 6L) + | 0I -> 0I + | 1I -> 0I |> pipeWithShadowing + | 2I -> + let pipeWithShadowing = (fun v -> v * 6I) x |> pipeWithShadowing - | pipeWithShadowing -> x |> Stdlib.Int64.add pipeWithShadowing + | pipeWithShadowing -> x |> Stdlib.Int.add pipeWithShadowing - let valueShadowing = 120L - let valueShadowing (x: Int64) : Int64 = - if x <= 0L then - 10L - else if x == 1L then - (valueShadowing 0L) + 1L + let valueShadowing = 120I + let valueShadowing (x: Int) : Int = + if x <= 0I then + 10I + else if x == 1I then + (valueShadowing 0I) + 1I else - let result = valueShadowing + 1L - (valueShadowing (x - 1L)) + result + let result = valueShadowing + 1I + (valueShadowing (x - 1I)) + result -ESelfTests.factorial 0L = 1L -ESelfTests.factorial 1L = 1L -ESelfTests.factorial 5L = 120L -ESelfTests.factorial 10L = 3628800L +ESelfTests.factorial 0I = 1I +ESelfTests.factorial 1I = 1I +ESelfTests.factorial 5I = 120I +ESelfTests.factorial 10I = 3628800I -ESelfTests.fibonacci 0L = 0L -ESelfTests.fibonacci 1L = 1L -ESelfTests.fibonacci 5L = 5L -ESelfTests.fibonacci 10L = 55L +ESelfTests.fibonacci 0I = 0I +ESelfTests.fibonacci 1I = 1I +ESelfTests.fibonacci 5I = 5I +ESelfTests.fibonacci 10I = 55I -ESelfTests.sumUpTo 0L = 0L -ESelfTests.sumUpTo 1L = 1L -ESelfTests.sumUpTo 5L = 15L -ESelfTests.sumUpTo 10L = 55L +ESelfTests.sumUpTo 0I = 0I +ESelfTests.sumUpTo 1I = 1I +ESelfTests.sumUpTo 5I = 15I +ESelfTests.sumUpTo 10I = 55I -ShadowingTest.factorialWithShadowing 5L = ("shadowed", 120L) -ShadowingTest.factorialWithShadowingError 5L = error="""Expected something we could apply to, such as a lambda or function, but got a String ("shadowed")""" -ShadowingTest.incrementWithShadowing 3L 1L = 6L +ShadowingTest.factorialWithShadowing 5I = ("shadowed", 120I) +ShadowingTest.factorialWithShadowingError 5I = error="""Expected something we could apply to, such as a lambda or function, but got a String ("shadowed")""" +ShadowingTest.incrementWithShadowing 3I 1I = 6I -ShadowingTest.matchWithShadowing 0L = 0L -ShadowingTest.matchWithShadowing 1L = 0L -ShadowingTest.matchWithShadowing 2L = 8L -ShadowingTest.matchWithShadowing 5L = 6L +ShadowingTest.matchWithShadowing 0I = 0I +ShadowingTest.matchWithShadowing 1I = 0I +ShadowingTest.matchWithShadowing 2I = 8I +ShadowingTest.matchWithShadowing 5I = 6I -ShadowingTest.tupleMatchWithShadowing (0L, 10L) = 0L -ShadowingTest.tupleMatchWithShadowing (1L, 20L) = 0L -ShadowingTest.tupleMatchWithShadowing (2L, 3L) = 30L -ShadowingTest.tupleMatchWithShadowing (4L, 5L) = 9L +ShadowingTest.tupleMatchWithShadowing (0I, 10I) = 0I +ShadowingTest.tupleMatchWithShadowing (1I, 20I) = 0I +ShadowingTest.tupleMatchWithShadowing (2I, 3I) = 30I +ShadowingTest.tupleMatchWithShadowing (4I, 5I) = 9I -ShadowingTest.letBindingShadowing 4L = [12L; 10L] -ShadowingTest.letBindingShadowing 5L = [15L; 10L] +ShadowingTest.letBindingShadowing 4I = [12I; 10I] +ShadowingTest.letBindingShadowing 5I = [15I; 10I] -ShadowingTest.conditionalShadowing 0L = 0L -ShadowingTest.conditionalShadowing 1L = 7L -ShadowingTest.conditionalShadowing 2L = 12L -ShadowingTest.conditionalShadowing 3L = 9L -ShadowingTest.conditionalShadowing 4L = 12L -ShadowingTest.conditionalShadowing 5L = 17L -ShadowingTest.conditionalShadowing 6L = 23L +ShadowingTest.conditionalShadowing 0I = 0I +ShadowingTest.conditionalShadowing 1I = 7I +ShadowingTest.conditionalShadowing 2I = 12I +ShadowingTest.conditionalShadowing 3I = 9I +ShadowingTest.conditionalShadowing 4I = 12I +ShadowingTest.conditionalShadowing 5I = 17I +ShadowingTest.conditionalShadowing 6I = 23I -ShadowingTest.pipeWithShadowing 0L = 0L -ShadowingTest.pipeWithShadowing 1L = 0L -ShadowingTest.pipeWithShadowing 2L = 12L -ShadowingTest.pipeWithShadowing 5L = 10L +ShadowingTest.pipeWithShadowing 0I = 0I +ShadowingTest.pipeWithShadowing 1I = 0I +ShadowingTest.pipeWithShadowing 2I = 12I +ShadowingTest.pipeWithShadowing 5I = 10I -ShadowingTest.valueShadowing 0L = 10L -ShadowingTest.valueShadowing 1L = 11L -ShadowingTest.valueShadowing 5L = 495L +ShadowingTest.valueShadowing 0I = 10I +ShadowingTest.valueShadowing 1I = 11I +ShadowingTest.valueShadowing 5I = 495I diff --git a/backend/testfiles/execution/stdlib/float.dark b/backend/testfiles/execution/stdlib/float.dark index dac14ce2b0..faa4edaf22 100644 --- a/backend/testfiles/execution/stdlib/float.dark +++ b/backend/testfiles/execution/stdlib/float.dark @@ -1,43 +1,59 @@ 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 + +// NaN / Infinity have no Int representation -> Dark error, not a host crash +Stdlib.Float.ceiling_v0 Builtin.testNan_v0 = + error="Encountered out-of-range value for type of Int" +Stdlib.Float.roundUp_v0 Builtin.testInfinity_v0 = + error="Encountered out-of-range value for type of Int" +Stdlib.Float.floor_v0 Builtin.testNegativeInfinity_v0 = + error="Encountered out-of-range value for type of Int" +Stdlib.Float.roundDown_v0 Builtin.testNan_v0 = + error="Encountered out-of-range value for type of Int" +Stdlib.Float.round_v0 Builtin.testInfinity_v0 = + error="Encountered out-of-range value for type of Int" +Stdlib.Float.truncate_v0 Builtin.testNan_v0 = + error="Encountered out-of-range value for type of Int" +Stdlib.Float.roundTowardsZero Builtin.testNegativeInfinity_v0 = + error="Encountered out-of-range value for type of Int" Stdlib.Float.absoluteValue_v0 Builtin.testNegativeInfinity_v0 = Builtin.testInfinity_v0 Stdlib.Float.absoluteValue_v0 Builtin.testNan_v0 = Builtin.testNan_v0 @@ -165,11 +181,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/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/execution/stdlib/ints/int.dark b/backend/testfiles/execution/stdlib/ints/int.dark index 4566568bb1..60c7eceebd 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 @@ -64,3 +65,48 @@ 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 + +// --- fromFloat: truncates toward zero; NaN/Infinity have no Int, so OutOfRange --- +Stdlib.Int.fromFloat 3.9 = 3I +Stdlib.Int.fromFloat -3.9 = -3I +Stdlib.Int.fromFloat (0.0 / 0.0) = + error="Encountered out-of-range value for type of Int" +Stdlib.Int.fromFloat (1.0 / 0.0) = + error="Encountered out-of-range value for type of Int" +Stdlib.Int.fromFloat (-1.0 / 0.0) = + error="Encountered out-of-range value for type of Int" + + +// --- 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 = Stdlib.Result.Result.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" + +// --- shiftLeft / shiftRight: count must fit Int32, else OutOfRange --- +Stdlib.Int.shiftLeft 1I 4I = 16I +Stdlib.Int.shiftLeft 1I 64I = 18446744073709551616I +Stdlib.Int.shiftRight 256I 4I = 16I +Stdlib.Int.shiftLeft 1I (2I ^ 40I) = + error="Encountered out-of-range value for type of Int" +Stdlib.Int.shiftRight 1I (2I ^ 40I) = + error="Encountered out-of-range value for type of Int" 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..95abdfe1ff 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" @@ -787,11 +838,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 = @@ -1447,45 +1498,4 @@ 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 +// 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/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/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/testfiles/execution/stdlib/list.dark b/backend/testfiles/execution/stdlib/list.dark index 707a68eb7b..1317d21cd6 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)" @@ -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" ]) ] @@ -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..d4ab835ef6 100644 --- a/backend/testfiles/execution/stdlib/stream.dark +++ b/backend/testfiles/execution/stdlib/stream.dark @@ -53,17 +53,22 @@ // 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) = [] + +// a negative n of any magnitude (even past Int64) clamps to 0 -> empty +(let s = Stdlib.Stream.fromList [ 1L; 2L ] + let none = Stdlib.Stream.take s -9223372036854775809I Stdlib.Stream.toList none) = [] // concat drains streams in list order @@ -88,7 +93,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 +107,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 +127,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 +142,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 @@ -145,4 +150,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..c6827d8be7 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) = 10I + Stdlib.String.length ((Stdlib.String.random 5I) |> Builtin.unwrap) = 5I + Stdlib.String.length ((Stdlib.String.random 0I) |> Builtin.unwrap) = 0I - 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 = @@ -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/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/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 08560c5d12..85c48bf57f 100644 --- a/backend/testfiles/http-server/bad-response-just-int.test +++ b/backend/testfiles/http-server/bad-response-just-int.test @@ -18,12 +18,12 @@ 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: 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 cc6feeefdc..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.Int64.toString |> Darklang.Stdlib.String.toBlob) -Darklang.Stdlib.Http.response body 200L) +(let body = (request.body |> Darklang.Stdlib.Blob.length |> Darklang.Stdlib.Int.toString |> Darklang.Stdlib.String.toBlob) +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 a0e158a5a9..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.Int64.toString |> Darklang.Stdlib.String.toBlob) -Darklang.Stdlib.Http.response body 500L) +(let body = (request.body |> Darklang.Stdlib.Blob.length |> Darklang.Stdlib.Int.toString |> Darklang.Stdlib.String.toBlob) +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 d5f898df23..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.Int64.toString |> Darklang.Stdlib.String.toBlob) -Darklang.Stdlib.Http.response body 200L) +(let body = (request.body |> Darklang.Stdlib.Blob.length |> Darklang.Stdlib.Int.toString |> Darklang.Stdlib.String.toBlob) +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 98fa0990bd..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.Int64.toString |> Darklang.Stdlib.String.toBlob) - Darklang.Stdlib.Http.response body 200L) +(let body = (request.body |> Darklang.Stdlib.Blob.length |> Darklang.Stdlib.Int.toString |> Darklang.Stdlib.String.toBlob) + 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/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/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/ai/agent.dark b/packages/darklang/cli/ai/agent.dark index 05a0eb9695..9a0cfb33eb 100644 --- a/packages/darklang/cli/ai/agent.dark +++ b/packages/darklang/cli/ai/agent.dark @@ -100,8 +100,9 @@ let systemPrompt : String = ## Critical Syntax - Whitespace-sensitive (like Python) -- No nested function definitions -- Lists use semicolons: [1L; 2L; 3L] +- Nested function definitions need typed params and a return type: + `let helper (x: Int) : Int = ...`; no mutual recursion +- Lists use semicolons: [1; 2; 3] - String concat: ++ (not +) - Pipe needs parens for complex LHS: (expr) |> fn @@ -196,17 +197,17 @@ let runCliCommand let result = Stdlib.Cli.execute fullCmd match result.exitCode with - | 0L -> + | 0I -> let output = if result.stdout == "" then "(no output)" else result.stdout 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 -> let details = if result.stderr != "" then result.stderr else if result.stdout != "" then result.stdout else "no output" - let errorMsg = "CLI command failed (exit " ++ (Stdlib.Int64.toString exitCode) ++ "): " ++ (Stdlib.String.trim details) + let errorMsg = "CLI command failed (exit " ++ (Stdlib.Int.toString exitCode) ++ "): " ++ (Stdlib.String.trim details) Stdlib.printLine (Colors.error (" -> " ++ errorMsg)) Stdlib.Result.Result.Error errorMsg | None -> Stdlib.Result.Result.Error "Could not find CLI executable" @@ -238,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) @@ -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 f6685e8277..a773055158 100644 --- a/packages/darklang/cli/apps/command.dark +++ b/packages/darklang/cli/apps/command.dark @@ -8,11 +8,9 @@ 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 25L) + (Stdlib.Cli.Daemon.tailLog slug 25I) |> Stdlib.List.filter (fun l -> Stdlib.String.contains l "localhost:") match Stdlib.List.last portLines with @@ -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,11 +28,11 @@ 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}" + $"running (pid {Stdlib.Int.toString pid}){portStr}" else - $"stale (pid {Stdlib.Int64.toString pid})" + $"stale (pid {Stdlib.Int.toString pid})" | None -> "stopped" /// One list row: pretty label · (slug) · [kind] · description — daemons append their live state. @@ -76,7 +74,7 @@ let startDaemon (state: Cli.AppState) (slug: String) : Cli.AppState = match Stdlib.Cli.Daemon.start slug expr with | Ok pid -> - Stdlib.printLine (Colors.success $"✓ {app.name} started (pid {Stdlib.Int64.toString pid})") + Stdlib.printLine (Colors.success $"✓ {app.name} started (pid {Stdlib.Int.toString pid})") | Error e -> Stdlib.printLine (Colors.error e) | Foreground _ -> Stdlib.printLine (Colors.dimText $"'{slug}' is a foreground app — run it with `apps run {slug}`") @@ -97,7 +95,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 +201,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?)") @@ -264,7 +262,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 f8e04ec968..787145e3c6 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 @@ -27,14 +27,14 @@ let selectedApp (state: State) : Stdlib.Option.Option = // ── 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 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 0L (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 (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 " " 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 + 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 @@ -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 @@ -206,7 +206,7 @@ let toggleDaemon (state: State) (app: Model.App) (entrypoint: String) : State = let q = "\"" let expr = entrypoint ++ " " ++ q ++ app.slug ++ q match Stdlib.Cli.Daemon.start app.slug expr with - | Ok pid -> { state with message = Colors.success $"started {app.name} (pid {Stdlib.Int64.toString pid})" } + | Ok pid -> { state with message = Colors.success $"started {app.name} (pid {Stdlib.Int.toString pid})" } | Error e -> { state with message = Colors.error e } /// enter — the primary action: run a foreground app (hand it the screen) / toggle a daemon. @@ -229,11 +229,11 @@ let handleKey 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/examples.dark b/packages/darklang/cli/apps/examples.dark index c88b4a3666..79a647dc5e 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.printLine $"{name}: beat (pid {Stdlib.Int.toString pid})" + 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.Int.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/apps/views/ai-chats.dark b/packages/darklang/cli/apps/views/ai-chats.dark index ff285d2b2b..1f1ebefd6e 100644 --- a/packages/darklang/cli/apps/views/ai-chats.dark +++ b/packages/darklang/cli/apps/views/ai-chats.dark @@ -2,7 +2,7 @@ module Darklang.Cli.Apps.Views.AiChats /// Demo data: an AI coding thread type Thread = - { id: Int64 + { id: Int status: String topic: String branch: String @@ -13,7 +13,7 @@ type Thread = let demoThreads () : List = [ Thread - { id = 1L + { id = 1I status = "running" topic = "Add binary serialization for sync" branch = "ai/sync" @@ -22,7 +22,7 @@ let demoThreads () : List = time = "12m" detail = "Currently editing packages/darklang/sync/serialize.dark • 14 files changed" } Thread - { id = 2L + { id = 2I status = "review" topic = "Refactor HTTP handler error paths" branch = "ai/errs" @@ -31,7 +31,7 @@ let demoThreads () : List = time = "8m" detail = "⚠ Awaiting your review: 3 questions about error propagation strategy" } Thread - { id = 3L + { id = 3I status = "running" topic = "Write tests for package manager" branch = "ai/test" @@ -40,7 +40,7 @@ let demoThreads () : List = time = "5m" detail = "Running test suite (pass: 12, fail: 2, pending: 6) • 4 files changed" } Thread - { id = 4L + { id = 4I status = "review" topic = "Design new DB migration system" branch = "ai/db" @@ -49,7 +49,7 @@ let demoThreads () : List = time = "22m" detail = "⚠ Awaiting your review: proposed 2 migration approaches, needs decision" } Thread - { id = 5L + { id = 5I status = "running" topic = "Fix canvas rendering perf regression" branch = "ai/perf" @@ -58,7 +58,7 @@ let demoThreads () : List = time = "3m" detail = "Profiling render loop, found bottleneck in tree diff • 1 file changed" } Thread - { id = 6L + { id = 6I status = "done" topic = "Update stdlib List docs" branch = "ai/docs" @@ -86,30 +86,30 @@ let thinHr () : String = let cols = Darklang.Cli.Terminal.getWidth () Darklang.Cli.Colors.dimText (Stdlib.String.repeat "╌" cols) -let padRight (s: String) (width: Int64) : String = +let padRight (s: String) (width: Int) : String = let len = Stdlib.String.length s if len >= width then - Stdlib.String.slice s 0L width + Stdlib.String.slice s 0I width else 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 idStr = Darklang.Cli.Colors.colorize (Darklang.Cli.Colors.bold ++ Darklang.Cli.Colors.cyan) ("#" ++ Stdlib.Int.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) @@ -141,26 +141,26 @@ 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 ()) // 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 cc259db1eb..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 @@ -20,7 +20,7 @@ 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) ++ "\n\n" @@ -63,7 +63,7 @@ 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) @@ -103,11 +103,11 @@ let handleKey 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 fb8b193007..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 padRight (s: String) (width: Int) : String = let len = Stdlib.String.length s if len >= width then - Stdlib.String.slice s 0L width + Stdlib.String.slice s 0I (width) else - s ++ (Stdlib.String.repeat " " (width - len)) + s ++ (Stdlib.String.repeat " " ((width - len))) -let padLeft (s: String) (width: Int64) : String = +let padLeft (s: String) (width: Int) : String = let len = Stdlib.String.length s if len >= width then - Stdlib.String.slice s 0L width + Stdlib.String.slice s 0I (width) else - (Stdlib.String.repeat " " (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 "█" barLen - let empty = Stdlib.String.repeat "░" (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 "" @@ -55,19 +55,19 @@ 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 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 "" @@ -78,15 +78,15 @@ let render () : Unit = 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 @@ -95,22 +95,22 @@ let render () : Unit = 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)) 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..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 indexOfAccess (a: String) : Int = let indexed = Stdlib.List.indexedMap accesses (fun i x -> (i, x)) - Stdlib.List.fold indexed 0L (fun acc pair -> + Stdlib.List.fold indexed 0I (fun acc pair -> let (i, x) = pair if x == a then i else acc) @@ -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 = 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/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/httpRuleEditor.dark b/packages/darklang/cli/caps/httpRuleEditor.dark index b03356fb65..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 indexOfMethod (m: String) : Int = let indexed = Stdlib.List.indexedMap methods (fun i x -> (i, x)) - Stdlib.List.fold indexed 0L (fun acc pair -> + Stdlib.List.fold indexed 0I (fun acc pair -> let (i, x) = pair if x == m then i else acc) @@ -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 = 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 39a75015bd..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 = 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 0L state.cursor + 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 } + 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 0L (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 - 1L } + 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 < 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 0L state.cursor + let before = Stdlib.String.slice state.text 0I 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 < (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 < Stdlib.String.length state.text then - Stdlib.String.dropFirst state.text (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 9e36449ca4..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 = 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,11 +137,11 @@ 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) state.cursor with @@ -152,12 +152,12 @@ let handleBrowsing | 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) state.cursor with | Some(RuleRow spec) -> KeyResult.Continue (clampCursor (removeSpec state spec)) @@ -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 @@ -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,7 +258,7 @@ 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 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) @@ -269,7 +269,7 @@ 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 -> (i, x)) 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/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/cli/core.dark b/packages/darklang/cli/core.dark index 5e941fb4f5..8531ac94bd 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 = @@ -188,7 +188,7 @@ module StatusBar = let paddingLen = terminalWidth - leftLen let padding = - if paddingLen > 0L then + 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) @@ -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 @@ -700,15 +700,15 @@ 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 1L ++ "\u001b[2K" ++ "\n") - 0L + 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) : Int64 = // 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 @@ -726,23 +726,23 @@ 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 // 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) + (Stdlib.String.length state.prompt.text) + (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 + let tRender = if state.telemetryEnabled then Telemetry.now () else 0I match state.currentPage with | MainPrompt -> @@ -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 @@ -803,7 +803,7 @@ let runInteractiveLoop (state: AppState) : Int64 = 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) : Int64 = 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 } @@ -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) @@ -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/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/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/cli/docs/enums.dark b/packages/darklang/cli/docs/enums.dark index 90adab7461..d78f61002d 100644 --- a/packages/darklang/cli/docs/enums.dark +++ b/packages/darklang/cli/docs/enums.dark @@ -4,12 +4,12 @@ let content () : String = """# Enums ## Define - type Status = | Pending | Done of Int64 + type Status = | Pending | Done of Int ## Construct (need type prefix) Status.Pending - Status.Done 42L - Option.Some 5L + Status.Done 42 + Option.Some 5 Result.Ok "yes" ## Match (no type prefix) diff --git a/packages/darklang/cli/docs/errors.dark b/packages/darklang/cli/docs/errors.dark index d3ede2b1ff..afa4d490da 100644 --- a/packages/darklang/cli/docs/errors.dark +++ b/packages/darklang/cli/docs/errors.dark @@ -11,7 +11,7 @@ let content () : String = - { left of type name in record ## Type mismatch - - Wrong literal suffix (5L vs 5.0) + - Wrong literal suffix (5 vs 5.0) - Param order wrong - Missing Option.Some wrapper - Missing list wrapper [x] diff --git a/packages/darklang/cli/docs/for-ai-internal.dark b/packages/darklang/cli/docs/for-ai-internal.dark index 780ff41f67..75fd5bd281 100644 --- a/packages/darklang/cli/docs/for-ai-internal.dark +++ b/packages/darklang/cli/docs/for-ai-internal.dark @@ -140,13 +140,13 @@ 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: - let helper (x: Int64) : Int64 = ... + let helper (x: Int) : Int = ... This desugars to a local lambda. It can close over outer bindings and can call itself by name, but mutual recursion between nested functions is not supported. Forms such as `let helper x = ...` are not supported; use typed, parenthesized diff --git a/packages/darklang/cli/docs/for-ai.dark b/packages/darklang/cli/docs/for-ai.dark index 3fb5d3dc40..5dad98c4f2 100644 --- a/packages/darklang/cli/docs/for-ai.dark +++ b/packages/darklang/cli/docs/for-ai.dark @@ -47,14 +47,14 @@ their operation: `search %` -> `mod`, `search ++` -> concat, `search /` -> val # create value Names need full paths (owner.module.name), e.g.: - fn Darklang.Testing.fib (n: Int64): Int64 = ... + fn Darklang.Testing.fib (n: Int): Int = ... Inside the body, use short names (e.g., `fib` for recursion). For multi-line bodies, use `-` and pipe via stdin (heredoc form): ./scripts/run-cli fn Darklang.Foo.bar - <<'EOF' - (n: Int64): Int64 = - let x = n + 1L - x * 2L + (n: Int): Int = + let x = n + 1 + x * 2 EOF ## Running/Testing @@ -138,25 +138,37 @@ Rules: ## Critical Syntax - Whitespace-sensitive (like Python) - Nested function definitions are supported only in the fully annotated form: - `let helper (x: Int64) : Int64 = ...`. The parser desugars this to a local + `let helper (x: Int) : Int = ...`. The parser desugars this to a local lambda, so use it for task-local helpers; mutual recursion is not supported. - NO binding modules to variables (`let c = Darklang.Cli.Colors` is invalid — modules are not first-class values. Use the full path each time.) -- Pipe needs parens: (complex expr) |> fn -- Lists: [1L; 2L; 3L] (semicolons) +- Pipe |> feeds the left value as the FIRST argument of the right fn; any + args written after the fn come after it: `[1; 2] |> Stdlib.List.map toString`, + `n |> Stdlib.Int.add 1`. Wrap a complex left side in parens: (complex expr) |> fn +- Lists: [1; 2; 3] (semicolons) +- Char literals use single quotes: 'a', '\n', '\t', 'A' (a String uses + double quotes; "a" is not 'a') +- Tuples destructure inline in `let` and in lambda params: + `let (a, b) = pair`, `fun (name, done) -> ...` - String concat: ++ (not @) -- String interpolation: $"x = {expr}; total = {a ++ b}" +- String interpolation: $"x = {expr}; total = {a ++ b}" — does NOT auto-coerce + non-strings; wrap with Stdlib.Int.toString / Stdlib.Float.toString - Numeric operators (+ - * / % ^ < > <= >= and unary -) are polymorphic over numeric types; operands must match (`1 + 2`, `1.0 + 2.0`). `/` is integer - division on ints; integer overflow raises a runtime error. + division on ints; float division on floats. A bare `1` is an arbitrary- + precision `Int` and never overflows. ## Records - MyRecord { a = 1L; b = 2L } + MyRecord { a = 1; b = 2 } # { must not be left of type name ## Enums - Option.Some 5L # construct: TypeName.Case - | Some x -> ... # match: just Case + Option.Some 5 # construct: TypeName.Case + | Some x -> ... # match: just Case (bare form OK at top level of an arm) + # NESTED in a tuple or another constructor, parenthesize with NO space: + | (Ok(x), Ok(y)) -> ... # tuple of constructors (bare `Ok x` fails here) + | Some(Ok(v)) -> ... # constructor of a constructor + | Some((a, b)) -> ... # constructor wrapping a tuple ## Troubleshooting If commands hang or fail silently, check logs: diff --git a/packages/darklang/cli/docs/functions.dark b/packages/darklang/cli/docs/functions.dark index 0f9bc223d3..2d940c024d 100644 --- a/packages/darklang/cli/docs/functions.dark +++ b/packages/darklang/cli/docs/functions.dark @@ -4,7 +4,7 @@ let content () : String = """# Functions ## Define (module-level only) - let add (a: Int64) (b: Int64) : Int64 = a + b + let add (a: Int) (b: Int) : Int = a + b let greet (name: String) : String = $"Hi {name}" ## No params @@ -12,22 +12,22 @@ let content () : String = ## NO NESTED FUNCTIONS # WRONG: - let outer () = let inner () = 5L; inner () + let outer () = let inner () = 5; inner () # RIGHT: - let inner () = 5L + let inner () = 5 let outer () = inner () ## Call - add 1L 2L + add 1 2 Stdlib.String.length "hi" ## Lambda - fun x -> x + 1L + fun x -> x + 1 fun (a, b) -> a + b ## Partial application - let addFive = Stdlib.Int64.add 5L - addFive 3L # 8L + let addFive = Stdlib.Int.add 5 + addFive 3 # 8 ## Unit return let log (msg: String) : Unit = Stdlib.printLine msg""" diff --git a/packages/darklang/cli/docs/http-server.dark b/packages/darklang/cli/docs/http-server.dark index 0d3e8ec13a..15ba882cf2 100644 --- a/packages/darklang/cli/docs/http-server.dark +++ b/packages/darklang/cli/docs/http-server.dark @@ -9,9 +9,9 @@ let content () : String = ## Router function let router (req: Stdlib.HttpServer.Request) : Stdlib.HttpServer.Response = match (req.method, req.path) with - | ("GET", "/") -> Stdlib.HttpServer.response 200L "Hello" - | ("GET", "/api") -> Stdlib.HttpServer.jsonResponse 200L data - | _ -> Stdlib.HttpServer.response 404L "Not Found" + | ("GET", "/") -> Stdlib.HttpServer.response 200 "Hello" + | ("GET", "/api") -> Stdlib.HttpServer.jsonResponse 200 data + | _ -> Stdlib.HttpServer.response 404 "Not Found" ## Request fields method path headers query body diff --git a/packages/darklang/cli/docs/pattern-matching.dark b/packages/darklang/cli/docs/pattern-matching.dark index 4439b4bb49..614b0ed83d 100644 --- a/packages/darklang/cli/docs/pattern-matching.dark +++ b/packages/darklang/cli/docs/pattern-matching.dark @@ -5,7 +5,7 @@ let content () : String = ## Basic match x with - | 0L -> "zero" + | 0 -> "zero" | n -> $"other: {n}" ## Enums (no type prefix) @@ -17,6 +17,15 @@ let content () : String = ## Tuples | (a, b) -> a + b +## Constructor patterns: bare vs parenthesized +A bare `Ok x` works only as a top-level arm. When a constructor pattern is +NESTED — inside a tuple, or as another constructor's argument — use the +immediate-paren form `Ctor(x)` with NO space before the `(`. The bare form +collides with the surrounding commas/arguments and fails to parse. + | (Ok(x), Ok(y)) -> x + y # tuple of constructors — parenthesize each + | (Some(n), None) -> n # bare/no-arg cases are fine alongside + # NOT: | (Ok x, Ok y) -> # fails to parse + ## Lists | [] -> "empty" | [x] -> "one" @@ -30,7 +39,8 @@ let content () : String = | _ -> default ## Nested - | Some (Ok v) -> v + | Some(Ok(v)) -> v # no space; parenthesize each constructor -## Gotcha: Some + tuple - | Some ((a, b)) -> ... # double parens""" +## Constructor wrapping a tuple + | Some((a, b)) -> a + b # Ctor((tuple)) — no space before the paren + # NOT: | Some ((a, b)) -> # the space makes it fail to parse""" diff --git a/packages/darklang/cli/docs/records.dark b/packages/darklang/cli/docs/records.dark index 35db0c7514..a2c5dc317c 100644 --- a/packages/darklang/cli/docs/records.dark +++ b/packages/darklang/cli/docs/records.dark @@ -4,13 +4,13 @@ let content () : String = """# Records ## Define - type Person = { name: String; age: Int64 } + type Person = { name: String; age: Int } ## Construct (alignment matters!) - Person { name = "Jo"; age = 30L } # OK + Person { name = "Jo"; age = 30 } # OK Person # OK { name = "Jo" - age = 30L } + age = 30 } Person { name = "Jo" } # WRONG - { left of type @@ -18,7 +18,7 @@ let content () : String = person.name ## Update - { person with age = 31L } + { person with age = 31 } ## No pattern matching Records can't be destructured in match. Use a variable and access fields: diff --git a/packages/darklang/cli/docs/scm.dark b/packages/darklang/cli/docs/scm.dark index 3e2b9524ca..3f6663fd45 100644 --- a/packages/darklang/cli/docs/scm.dark +++ b/packages/darklang/cli/docs/scm.dark @@ -57,7 +57,7 @@ Workflow: create branch → make changes → commit → rebase → merge ## Example Session (interactive) branch create feature # create + switch to feature branch fn fib # create fibonacci function - run fib 10L # test it + run fib 10 # test it status # see "fib" as uncommitted on feature commit "Add fibonacci" # save it rebase # pick up any new commits from parent @@ -66,7 +66,7 @@ Workflow: create branch → make changes → commit → rebase → merge ## Example Session (non-interactive / AI agent) dark branch create feature dark --branch feature fn "Darklang.Math.fib ..." - dark --branch feature run fib 10L + dark --branch feature run fib 10 dark --branch feature status dark --branch feature commit "Add fibonacci" dark --branch feature rebase diff --git a/packages/darklang/cli/docs/stdlib.dark b/packages/darklang/cli/docs/stdlib.dark index fee9673add..718d702b50 100644 --- a/packages/darklang/cli/docs/stdlib.dark +++ b/packages/darklang/cli/docs/stdlib.dark @@ -13,7 +13,7 @@ string handling, JSON, HTTP, and other utilities — all written in Dark. ## Key modules Stdlib.List Stdlib.String Stdlib.Option - Stdlib.Result Stdlib.Dict Stdlib.Int64 + Stdlib.Result Stdlib.Dict Stdlib.Int Stdlib.Json Stdlib.Http Stdlib.Uuid ## Shortcut diff --git a/packages/darklang/cli/docs/syntax.dark b/packages/darklang/cli/docs/syntax.dark index 48ee10c5a3..71f689b7c1 100644 --- a/packages/darklang/cli/docs/syntax.dark +++ b/packages/darklang/cli/docs/syntax.dark @@ -4,8 +4,8 @@ let content () : String = """# Syntax ## Basics - let x = 5L - let add (a: Int64) (b: Int64) : Int64 = a + b + let x = 5 + let add (a: Int) (b: Int) : Int = a + b if cond then a else b // comment @@ -15,20 +15,20 @@ let content () : String = ## Match match x with | Some v -> v - | None -> 0L + | None -> 0 ## 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] + [1; 2; 3] ## Strings "hello" ++ " world" # concat $"value: {x}" # interpolation ## Lambda - fun x -> x + 1L + fun x -> x + 1 fun (a, b) -> a + b ## Unit diff --git a/packages/darklang/cli/docs/types.dark b/packages/darklang/cli/docs/types.dark index c773ef03ac..dff611c5ee 100644 --- a/packages/darklang/cli/docs/types.dark +++ b/packages/darklang/cli/docs/types.dark @@ -4,14 +4,14 @@ let content () : String = """# Types ## Primitives - Int64 5L, -42L + Int 5, -42 Float 3.14, -0.5 String "hello" Bool true, false Char 'a' ## Option - Option.Some 5L + Option.Some 5 Option.None ## Result @@ -19,13 +19,13 @@ let content () : String = Result.Error msg ## Collections - List [1L; 2L] + List [1; 2] Dict Dict { key = "value" } (a, b) tuple ## Records - type Person = { name: String; age: Int64 } - Person { name = "Jo"; age = 30L } + type Person = { name: String; age: Int } + Person { name = "Jo"; age = 30 } ## Enums type Status = | Active | Inactive of String diff --git a/packages/darklang/cli/execution/eval.dark b/packages/darklang/cli/execution/eval.dark index 725f34f6af..37b4aed14d 100644 --- a/packages/darklang/cli/execution/eval.dark +++ b/packages/darklang/cli/execution/eval.dark @@ -47,14 +47,14 @@ let help (_state: AppState) : Unit = "Evaluate a Dark expression and display the result." "" "Examples:" - " eval 1L + 2L - Arithmetic operations" + " eval 1 + 2 - Arithmetic operations" " eval \"hello\" ++ \"world\" - String concatenation" - " eval [1L; 2L; 3L] |> List.length - List operations" + " eval [1; 2; 3] |> List.length - List operations" " eval Stdlib.String.length \"test\" - Function calls" "" " # Multi-line expression via stdin (run from shell, not the REPL):" " ./scripts/run-cli eval - <<'EOF'" - " let xs = [1L; 2L; 3L]" + " let xs = [1; 2; 3]" " Stdlib.List.length xs" " EOF" ] |> Stdlib.printLines \ No newline at end of file diff --git a/packages/darklang/cli/execution/run.dark b/packages/darklang/cli/execution/run.dark index b5f5e7bcc6..9f37eec713 100644 --- a/packages/darklang/cli/execution/run.dark +++ b/packages/darklang/cli/execution/run.dark @@ -52,10 +52,10 @@ let executeScript match result with | Ok exitCode -> - if exitCode == 0L then + if exitCode == 0I then state else - Stdlib.printLine $"Script exited with code {Stdlib.Int64.toString exitCode}" + Stdlib.printLine $"Script exited with code {Stdlib.Int.toString exitCode}" state | Error e -> let pretty = ExecutionError.toString state.currentBranchId e @@ -100,5 +100,5 @@ let help (state: AppState) : Unit = " --allow-harmful - Opt out of Harmful-deprecation halting." "" "To call a package function, use 'eval' instead:" - " eval Stdlib.Int64.add 5L 3L" ] + " eval Stdlib.Int.add 5 3" ] |> Stdlib.printLines 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/cli/installation/config.dark b/packages/darklang/cli/installation/config.dark index 7abaee783c..78660c116d 100644 --- a/packages/darklang/cli/installation/config.dark +++ b/packages/darklang/cli/installation/config.dark @@ -25,7 +25,7 @@ let updateVersion let currentTimestamp = (Stdlib.DateTime.now ()) |> Stdlib.DateTime.toSeconds - |> Stdlib.Int64.toString + |> Stdlib.Int.toString let config = match read configPath with 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/old_notes/_model.dark b/packages/darklang/cli/old_notes/_model.dark index 06dabc5614..40ec299ac0 100644 --- a/packages/darklang/cli/old_notes/_model.dark +++ b/packages/darklang/cli/old_notes/_model.dark @@ -69,7 +69,7 @@ type Page = { /// Current completion suggestions suggestions: List /// Index of currently selected suggestion (-1 = no selection) - selectedIndex: Int64 + selectedIndex: Int /// The original text that was being completed originalText: String /// The prefix that matched to generate these suggestions @@ -87,11 +87,11 @@ type Page = type EntityDefinition = { name: String lines: List // content split into lines for scrolling - scrollPosition: Int64 } + scrollPosition: Int } /// Content types type ViewContent = - | ModuleView of EntityCategory * List * Int64 // category, items, selectedIndex + | ModuleView of EntityCategory * List * Int // category, items, selectedIndex | EntityDefinitionView of EntityDefinition /// Viewing mode state @@ -99,13 +99,13 @@ type Page = { moduleContent: LanguageTools.ProgramTypes.Search.SearchResults entityName: String selectedCategory: EntityCategory - selectedItemIndex: Int64 + selectedItemIndex: Int expandedCategories: List entityDefinition: Stdlib.Option.Option /// Cache for entity definitions to avoid re-computing them entityCache: List<(String * EntityDefinition)> /// Viewport scroll position for the module view (how many lines scrolled from top) - viewportScrollPosition: Int64 } + viewportScrollPosition: Int } type State = { /// The current page/view the user is on @@ -118,13 +118,13 @@ type Page = mainPrompt: String /// Position of the cursor within the prompt - cursorPosition: Int64 + cursorPosition: Int /// Command history commandHistory: List /// Current position in command history (-1 = typing (not navigating), 0 = most recent, 1 = second most recent, etc.) - historyPosition: Int64 + historyPosition: Int /// What we were typing before we started navigating history draftPrompt: String diff --git a/packages/darklang/cli/outliner/core.dark b/packages/darklang/cli/outliner/core.dark index 24d1a68db8..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,11 +125,11 @@ 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 i) |> Stdlib.Option.withDefault 0L + (Stdlib.List.getAt ids i) |> Stdlib.Option.withDefault 0I let jVal = - (Stdlib.List.getAt ids j) |> Stdlib.Option.withDefault 0L + (Stdlib.List.getAt ids j) |> Stdlib.Option.withDefault 0I ids |> Stdlib.List.indexedMap (fun idx id -> if idx == i then jVal @@ -139,7 +139,7 @@ let swapAt (ids: List) (i: Int64) (j: Int64) : List = // --- 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 = 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/list-picker.dark b/packages/darklang/cli/outliner/list-picker.dark index 2c1d64c4d0..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,13 +24,13 @@ 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 = 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 -> @@ -42,14 +42,15 @@ 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) + (selectedIdx - region.rows + 1I) itemCount region.rows else - 0L + 0I state.items |> Stdlib.List.indexedMap (fun idx item -> (idx, item)) |> Stdlib.List.drop scrollOffset @@ -57,7 +58,7 @@ let renderInRegion (state: State<'item>) (region: Darklang.Cli.UI.Layout.Region) |> 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 e19cd4a97e..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,13 +46,13 @@ 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 <= 1L then + if docCount <= 1I then state else let remaining = Stdlib.List.filter state.documents (fun d -> d.id != docId) @@ -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 }) @@ -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") @@ -210,7 +210,7 @@ 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 = Stdlib.String.length helpText @@ -218,7 +218,7 @@ let renderHelpBar (helpText: String) (region: Darklang.Cli.UI.Layout.Region) : U 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" @@ -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 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 --- @@ -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 @@ -360,48 +360,48 @@ 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] 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 - 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 8fd58d5bf5..ebfa6c1bbf 100644 --- a/packages/darklang/cli/outliner/markdown.dark +++ b/packages/darklang/cli/outliner/markdown.dark @@ -1,6 +1,6 @@ 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 @@ -8,12 +8,12 @@ let exportHelper (outline: Outline) (ids: List) (depth: Int64) : List if Stdlib.String.startsWith first "# " then - Stdlib.String.dropFirst first 2L + Stdlib.String.dropFirst first 2I else "Imported" | None -> "Imported" @@ -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 -> [] @@ -40,17 +40,17 @@ 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 = 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 = @@ -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 78c0e2e9f9..9aa5680759 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,7 +11,7 @@ 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 --- @@ -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: Int64) : Int64 = +let findCursorIndex (outline: Outline) (nodeId: Int) (fallback: Int) : Int = let flat = flattenVisible outline flat |> Stdlib.List.findFirstIndex (fun vn -> vn.id == nodeId) @@ -45,10 +45,10 @@ 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 = 0L + cursor = 0I editing = Stdlib.Option.Option.Some (TextEditor.empty) } | Some vn -> let o1 = addNode outline id "" @@ -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 @@ -78,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 ((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 @@ -95,10 +95,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) @@ -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 @@ -140,10 +140,10 @@ 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 swapped = swapAt siblings (i - 1I) i let o1 = setChildren outline parentId swapped { state with outline = o1; cursor = findCursorIndex o1 vn.id state.cursor } @@ -158,24 +158,24 @@ 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 swapped = swapAt siblings i (i + 1I) let o1 = setChildren outline parentId swapped { 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 = (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 @@ -259,15 +259,15 @@ 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) + (state.cursor - region.rows + 1I) totalItems region.rows else - 0L + 0I let visibleItems = flat @@ -295,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 "" @@ -309,7 +309,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} " @@ -319,7 +319,7 @@ 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 = Stdlib.String.length helpText @@ -327,7 +327,7 @@ let renderHelpBar (helpText: String) (region: Darklang.Cli.UI.Layout.Region) : U 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 () @@ -336,7 +336,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 @@ -348,11 +348,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 b29728e48a..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,60 +50,60 @@ 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" (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" (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 == 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 + 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" | 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 = 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,104 +112,104 @@ 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" (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" (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" (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" (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 - let editor = { (makeEditor outline) with cursor = 1L } + [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 == 1L then - let s = getStructure newEditor.outline 1L - assertInt "child count" (Stdlib.List.length s.children) 1L + if rootCount == 1I then + 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.Int64.toString rootCount}" + 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 - let editor = { (makeEditor outline) with cursor = 1L } + [(1I, "Parent"); (2I, "Child")] + [(1I, [2I])] + [1I] + 3I + let editor = { (makeEditor outline) with cursor = 1I } let newEditor = OutlineEditor.outdentNode editor - assertInt "root count" (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 - let editor = { (makeEditor outline) with cursor = 1L } + [1I; 2I] + 3I + let editor = { (makeEditor outline) with cursor = 1I } let newEditor = OutlineEditor.moveNodeUp editor match Stdlib.List.head newEditor.outline.rootChildren with | Some firstId -> @@ -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,30 +235,30 @@ 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 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 = buildOutline - [(1L, "Only")] + [(1I, "Only")] [] - [1L] - 2L + [1I] + 2I 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" @@ -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" (Stdlib.List.length state.documents) 2L + assertInt "doc count" (Stdlib.List.length state.documents) 2I 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" (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" (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" (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 diff --git a/packages/darklang/cli/outliner/text-editor.dark b/packages/darklang/cli/outliner/text-editor.dark index 36fe1b52c9..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,7 +10,7 @@ type Result = | Cancelled let empty : State = - State { text = ""; cursor = 0L } + State { text = ""; cursor = 0I } let fromText (text: String) : State = State { text = text; cursor = Stdlib.String.length text } @@ -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 0L (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 - 1L }) + 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 = 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 0L state.cursor + 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 + 1L }) + 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 0L state.cursor + let before = Stdlib.String.slice state.text 0I state.cursor let cursorChar = if state.cursor < (Stdlib.String.length state.text) then - Stdlib.String.slice state.text state.cursor (state.cursor + 1L) + 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 < (Stdlib.String.length state.text) then - Stdlib.String.dropFirst state.text (state.cursor + 1L) + Stdlib.String.dropFirst state.text (state.cursor + 1I) else "" before ++ cursorDisplay ++ afterCursor diff --git a/packages/darklang/cli/packages/db.dark b/packages/darklang/cli/packages/db.dark index fe2bad0494..08773ebc01 100644 --- a/packages/darklang/cli/packages/db.dark +++ b/packages/darklang/cli/packages/db.dark @@ -93,12 +93,12 @@ 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" Stdlib.printLine $"{nameHeader}{typeHeader}" - Stdlib.printLine (Stdlib.String.repeat "─" 60L) + Stdlib.printLine (Stdlib.String.repeat "─" 60I) // Print each DB dbs @@ -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}") @@ -151,7 +151,7 @@ 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 = @@ -166,8 +166,7 @@ let viewDB (state: Cli.AppState) (dbName: String) : Cli.AppState = Stdlib.printLine $"{keyHeader}{fieldHeaders}" let totalWidth = - colWidth - + (Stdlib.Int64.multiply (Stdlib.List.length fieldNames) colWidth) + colWidth + ((Stdlib.List.length fieldNames) * colWidth) Stdlib.printLine (Stdlib.String.repeat "─" totalWidth) @@ -193,7 +192,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..219d17b19d 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 @@ -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 @@ -111,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/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/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 9703dd80a7..f572536a2c 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 @@ -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 @@ -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/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 01d539d19f..51760f31c5 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,7 +104,7 @@ 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") @@ -112,27 +112,27 @@ let viewEntityTruncated (branchId: Uuid) (location: PackageLocation) : Unit = itemsToShow |> Stdlib.List.iter (fun name -> Stdlib.printLine $" {name}/") let remaining = (Stdlib.List.length directSubmodules) - maxItemsPerCategory - if remaining > 0L then - Stdlib.printLine $" ... and {Stdlib.Int64.toString remaining} more modules" + if remaining > 0I then + Stdlib.printLine $" ... and {Stdlib.Int.toString remaining} more modules" - lineCount + 1L + (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 itemsPerRemaining typesToShow |> Stdlib.List.iter (fun t -> Stdlib.printLine $" {t.location.name}") let remaining = (Stdlib.List.length results.types) - itemsPerRemaining - if remaining > 0L then - Stdlib.printLine $" ... and {Stdlib.Int64.toString remaining} more types" + if remaining > 0I then + Stdlib.printLine $" ... and {Stdlib.Int.toString remaining} more types" | _ -> // For individual entities, show full view since they're typically small @@ -159,23 +159,23 @@ 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 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 @@ -207,12 +207,12 @@ 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 + if totalItems > 0I then match Stdlib.List.getAt navState.items 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,13 +227,13 @@ let display (navState: State) : Unit = // Navigation helper functions let moveUp (navState: State) : State = - let totalItems = 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 = 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,8 +277,8 @@ 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 - if totalItems > 0L then + let totalItems = (Stdlib.List.length navState.items) + if totalItems > 0I then match Stdlib.List.getAt navState.items navState.selectedIndex with | Some selectedItem -> exitAlternateScreen () @@ -294,8 +294,8 @@ 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 - if totalItems > 0L then + 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 @@ -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,14 +404,14 @@ 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 -> 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 } @@ -455,8 +455,8 @@ let handleNavModeKeys | U -> match navState.display with | Source -> - let totalItems = Stdlib.List.length navState.items - if totalItems > 0L then + let totalItems = (Stdlib.List.length navState.items) + if totalItems > 0I then match Stdlib.List.getAt navState.items navState.selectedIndex with | Some selectedItem -> exitAlternateScreen () 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..26143b8725 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 @@ -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) @@ -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 @@ -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/cli/packages/signatures.dark b/packages/darklang/cli/packages/signatures.dark index a64f74b789..b5ec16b928 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 @@ -294,7 +294,7 @@ let execute (state: Cli.AppState) (args: List) : Cli.AppState = Stdlib.printLine (Colors.error (FlagParser.parseErrorsMessage parsed.parseErrors)) help state else if isUnscoped then - StdlibOverview.execute state args + Darklang.Cli.Docs.StdlibOverview.execute state args else executeFiltered state 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..44fc4512ef 100644 --- a/packages/darklang/cli/packages/tree.dark +++ b/packages/darklang/cli/packages/tree.dark @@ -128,12 +128,12 @@ 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=" - match Stdlib.Int64.parse depthStr with + let depthStr = Stdlib.String.dropFirst depthArg 8I // Remove "--depth=" + 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 = @@ -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 @@ -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/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/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/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/prompt.dark b/packages/darklang/cli/prompt.dark index 1db8479208..6f35ff2e0c 100644 --- a/packages/darklang/cli/prompt.dark +++ b/packages/darklang/cli/prompt.dark @@ -3,42 +3,42 @@ 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 0L 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 + (Stdlib.String.length char) - historyIndex = -1L + 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 0L (state.cursorPosition - 1L) + 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 @@ -47,27 +47,27 @@ module Editing = let textLength = 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 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 = Stdlib.String.length state.text - let newCursorPos = Stdlib.Int64.min textLength (state.cursorPosition + 1L) + 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 = @@ -78,8 +78,8 @@ module Editing = 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 = @@ -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 = 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 newIndex with | Some 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,13 +131,13 @@ 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 + -1I // Go back to empty prompt + if newIndex == -1I then let restoredPromptLength = Stdlib.String.length state.savedPrompt { state with text = state.savedPrompt @@ -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 - (Stdlib.String.length locationStr) + 1L // +1 for the space after path + (Stdlib.String.length locationStr) + 1I // +1 for the space after path locationLength + (Stdlib.String.length "> ") - + 1L + + 1I diff --git a/packages/darklang/cli/scm/branch.dark b/packages/darklang/cli/scm/branch.dark index 79225c5e13..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,11 +23,11 @@ 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 > 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/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/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 92d463e0a0..40d6bbb1cc 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)> = @@ -60,7 +60,7 @@ let loadBranchList () : List = |> 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 + if wipOpCount == 0I && committedCount == 0I then Stdlib.Option.Option.None else Stdlib.Option.Option.Some @@ -70,14 +70,14 @@ 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 = groups |> 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)) @@ -85,7 +85,7 @@ let flattenGroups (groups: List<(String * List)>) : List let shortHash = LanguageTools.ProgramTypes.hashToShort c.hash @@ -249,18 +249,18 @@ let buildCommitList (detail: DetailState) : CommitListState = { branchName = detail.branchName branchId = detail.branchId commits = entries - selected = 0L + selected = 0I returnTo = detail } /// Build diff view for a commit's ops, grouped by module let buildCommitDiffState (commitList: CommitListState) (entry: CommitEntry) : DiffState = // Skip loading ops for very large commits - if entry.opCount > 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 +274,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,7 +288,7 @@ 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 ── @@ -314,7 +314,7 @@ let handleBranchListKey (state: AppModel) (branchList: BranchListState) (key: St 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 @@ -337,7 +337,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 }) }) @@ -384,15 +384,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,24 +405,24 @@ 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 startRow (region.rows - 1L) - Stdlib.List.iter rows (fun row -> Darklang.Cli.UI.Layout.printAt region 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 = 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 -> (idx, item)) @@ -433,27 +433,27 @@ let renderScrollableList 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}" - if itemCount == 0L then - printLine region 2L (Darklang.Cli.Colors.colorize Darklang.Cli.Colors.dim " No branches with changes to review.") - clearRows region 3L + printLine region 0I $" {Darklang.Cli.Colors.bold}branches to review{Darklang.Cli.Colors.reset}" + if itemCount == 0I then + 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.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 +462,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 == 0L then - printLine region 2L (Darklang.Cli.Colors.colorize Darklang.Cli.Colors.dim " No changes on this branch.") - clearRows region 3L + if itemCount == 0I then + 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 +482,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,8 +494,8 @@ 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 + 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 -> (idx, line)) @@ -503,26 +503,26 @@ let renderDiffBody (diffState: DiffState) (region: Darklang.Cli.UI.Layout.Region |> 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 == 0L then - printLine region 2L (Darklang.Cli.Colors.colorize Darklang.Cli.Colors.dim " No commits on this branch.") - clearRows region 3L + if itemCount == 0I then + 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 +531,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 +542,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" @@ -570,7 +570,7 @@ let buildDetailForBranch (branchId: Uuid) : Screen = { branchId = branchId branchName = branchName wipCount = wipCount - committedCount = 0L } + committedCount = 0I } Screen.Detail (buildDetailState item) @@ -598,8 +598,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 @@ -608,7 +608,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:") @@ -616,7 +616,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}") @@ -653,7 +653,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 1a75d23456..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,15 +67,15 @@ 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 candidate with | Some flatItem -> @@ -87,7 +87,7 @@ let moveUpSkipping (selected: Int64) (items: List) : Int64 = | None -> candidate /// Move down, skipping empty spacer items -let moveDownSkipping (selected: Int64) (items: List) : Int64 = +let moveDownSkipping (selected: Int) (items: List) : Int = let itemCount = Stdlib.List.length items let candidate = moveDown selected itemCount match Stdlib.List.getAt items candidate with @@ -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/scm/showCommit.dark b/packages/darklang/cli/scm/showCommit.dark index e68571d70f..0aaecbbd78 100644 --- a/packages/darklang/cli/scm/showCommit.dark +++ b/packages/darklang/cli/scm/showCommit.dark @@ -12,9 +12,9 @@ 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 + let commits = SCM.PackageOps.getCommitsWithAncestors branchId 100I let matching = commits @@ -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/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/cli/scripts.dark b/packages/darklang/cli/scripts.dark index b957799595..f1e13a059d 100644 --- a/packages/darklang/cli/scripts.dark +++ b/packages/darklang/cli/scripts.dark @@ -115,9 +115,9 @@ let execute (state: AppState) (args: List) : AppState = | Some script -> let result = Builtin.cliParseAndExecuteScript state.accountID state.currentBranchId $"script:{name}" script.text [] false false match result with - | Ok 0L -> state + | Ok 0I -> state | Ok exitCode -> - Stdlib.printLine $"Script '{name}' exited with code {Stdlib.Int64.toString exitCode}" + Stdlib.printLine $"Script '{name}' exited with code {Stdlib.Int.toString exitCode}" state | Error execErr -> let pretty = ExecutionError.toString state.currentBranchId execErr 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":"