diff --git a/.gitignore b/.gitignore
index 4ca2aa69e1..5bdbb3b811 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,6 +12,7 @@ config/local
rundir/
# F# / dotnet
+backend/src/Language/package-ref-hashes.txt
backend/src/LibExecution/package-ref-hashes.txt
backend/packages/
backend/paket-files/
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
index f8f79c1496..8a191201a1 100644
--- a/.vscode/tasks.json
+++ b/.vscode/tasks.json
@@ -55,6 +55,22 @@
"runOptions": {
"runOn": "folderOpen"
}
+ },
+ {
+ "label": "Watch & rebuild backend",
+ "type": "shell",
+ "command": "./scripts/build/_build-server --watch >> rundir/logs/build-server.log 2>&1",
+ "isBackground": true,
+ "presentation": {
+ "echo": true,
+ "reveal": "never",
+ "focus": false,
+ "panel": "dedicated"
+ },
+ "runOptions": {
+ "runOn": "folderOpen"
+ },
+ "problemMatcher": []
}
]
}
diff --git a/backend/Directory.Build.props b/backend/Directory.Build.props
index a4fd2fb178..8d9f5c32e0 100644
--- a/backend/Directory.Build.props
+++ b/backend/Directory.Build.props
@@ -17,6 +17,11 @@
$(OtherFlags) --test:GraphBasedChecking --test:ParallelOptimization --test:ParallelIlxGen
- $(OtherFlags) --warnaserror --warnon:1182,3387,3366
+
+
+
+
+
+ $(OtherFlags) --warnaserror --warnon:1182,3387,3366 --nowarn:3511
diff --git a/backend/fsdark.sln b/backend/fsdark.sln
index 8b54259134..dc384b07dd 100644
--- a/backend/fsdark.sln
+++ b/backend/fsdark.sln
@@ -23,6 +23,12 @@ EndProject
# Core projects
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Prelude", "src\Prelude\Prelude.fsproj", "{5FD0E378-FD88-45E5-9963-BFF2921E6A6A}"
EndProject
+Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Language", "src\Language\Language.fsproj", "{A1B2C3D4-0001-4001-8001-000000000001}"
+EndProject
+Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Runtime", "src\Runtime\Runtime.fsproj", "{A1B2C3D4-0002-4002-8002-000000000002}"
+EndProject
+Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "DarkTypes", "src\DarkTypes\DarkTypes.fsproj", "{A1B2C3D4-0003-4003-8003-000000000003}"
+EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "LibExecution", "src\LibExecution\LibExecution.fsproj", "{D8ECA989-4383-47D3-B443-4D7BFF1F05E7}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "LibTreeSitter", "src\LibTreeSitter\LibTreeSitter.fsproj", "{625B113A-D5DC-40A5-B833-4BA342AB4936}"
@@ -53,8 +59,9 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "LibCloud", "src\LibCloud\Li
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "LibHttpMiddleware", "src\LibHttpMiddleware\LibHttpMiddleware.fsproj", "{DAE2B2E9-40AF-4D99-A5B0-79678F94BFDA}"
EndProject
-Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "BwdServer", "src\BwdServer\BwdServer.fsproj", "{B56110F0-2D27-4718-8C80-E7FDE3439A63}"
-EndProject
+# BwdServer disabled — kept on disk; restore when HTTP server functionality returns.
+# Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "BwdServer", "src\BwdServer\BwdServer.fsproj", "{B56110F0-2D27-4718-8C80-E7FDE3439A63}"
+# EndProject
# CLI stuff
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "Cli", "src\Cli\Cli.fsproj", "{DF812CBE-894C-4C90-9EDC-4558983CCDEA}"
EndProject
@@ -86,14 +93,27 @@ Global
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {B56110F0-2D27-4718-8C80-E7FDE3439A63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {B56110F0-2D27-4718-8C80-E7FDE3439A63}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {B56110F0-2D27-4718-8C80-E7FDE3439A63}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {B56110F0-2D27-4718-8C80-E7FDE3439A63}.Release|Any CPU.Build.0 = Release|Any CPU
+ # BwdServer disabled
+ # {B56110F0-2D27-4718-8C80-E7FDE3439A63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ # {B56110F0-2D27-4718-8C80-E7FDE3439A63}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ # {B56110F0-2D27-4718-8C80-E7FDE3439A63}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ # {B56110F0-2D27-4718-8C80-E7FDE3439A63}.Release|Any CPU.Build.0 = Release|Any CPU
{D8ECA989-4383-47D3-B443-4D7BFF1F05E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D8ECA989-4383-47D3-B443-4D7BFF1F05E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D8ECA989-4383-47D3-B443-4D7BFF1F05E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D8ECA989-4383-47D3-B443-4D7BFF1F05E7}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A1B2C3D4-0001-4001-8001-000000000001}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A1B2C3D4-0001-4001-8001-000000000001}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A1B2C3D4-0001-4001-8001-000000000001}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A1B2C3D4-0001-4001-8001-000000000001}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A1B2C3D4-0002-4002-8002-000000000002}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A1B2C3D4-0002-4002-8002-000000000002}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A1B2C3D4-0002-4002-8002-000000000002}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A1B2C3D4-0002-4002-8002-000000000002}.Release|Any CPU.Build.0 = Release|Any CPU
+ {A1B2C3D4-0003-4003-8003-000000000003}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {A1B2C3D4-0003-4003-8003-000000000003}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {A1B2C3D4-0003-4003-8003-000000000003}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {A1B2C3D4-0003-4003-8003-000000000003}.Release|Any CPU.Build.0 = Release|Any CPU
{DB61305F-4CA9-4D92-82A5-503495F515E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DB61305F-4CA9-4D92-82A5-503495F515E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DB61305F-4CA9-4D92-82A5-503495F515E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -187,11 +207,15 @@ Global
# Notes of what projects being in which folders
GlobalSection(NestedProjects) = preSolution
# in /src
+ {A1B2C3D4-0001-4001-8001-000000000001} = {F84DCF8A-FC1A-4677-AF4D-616AD7DB3470}
+ {A1B2C3D4-0002-4002-8002-000000000002} = {F84DCF8A-FC1A-4677-AF4D-616AD7DB3470}
+ {A1B2C3D4-0003-4003-8003-000000000003} = {F84DCF8A-FC1A-4677-AF4D-616AD7DB3470}
{D8ECA989-4383-47D3-B443-4D7BFF1F05E7} = {F84DCF8A-FC1A-4677-AF4D-616AD7DB3470}
{5FD0E378-FD88-45E5-9963-BFF2921E6A6A} = {F84DCF8A-FC1A-4677-AF4D-616AD7DB3470}
{BBFC824F-A0DE-4A28-B82F-49C04EBA7475} = {F84DCF8A-FC1A-4677-AF4D-616AD7DB3470}
{625B113A-D5DC-40A5-B833-4BA342AB4936} = {F84DCF8A-FC1A-4677-AF4D-616AD7DB3470}
- {B56110F0-2D27-4718-8C80-E7FDE3439A63} = {F84DCF8A-FC1A-4677-AF4D-616AD7DB3470}
+ # BwdServer disabled
+ # {B56110F0-2D27-4718-8C80-E7FDE3439A63} = {F84DCF8A-FC1A-4677-AF4D-616AD7DB3470}
{3FC57943-9D51-49AE-9FBD-4A112B4F68D6} = {F84DCF8A-FC1A-4677-AF4D-616AD7DB3470}
{824DD2A5-7F01-4A8A-9ABD-9F91F52582AD} = {F84DCF8A-FC1A-4677-AF4D-616AD7DB3470}
{524e142b-bfb1-4f4b-8e67-bfe82301f7c6} = {F84DCF8A-FC1A-4677-AF4D-616AD7DB3470}
diff --git a/backend/paket.dependencies b/backend/paket.dependencies
index 9daca539b5..e19638cdfd 100644
--- a/backend/paket.dependencies
+++ b/backend/paket.dependencies
@@ -5,7 +5,6 @@ framework: net10.0
storage: none
// Basics
-nuget Ply = 0.3.1
nuget FSharpPlus = 1.5.0
nuget FsRegEx = 0.7.2
nuget FSharpx.Extras = 3.1.0
diff --git a/backend/paket.lock b/backend/paket.lock
index e8e13bf5fa..38c4aee5d3 100644
--- a/backend/paket.lock
+++ b/backend/paket.lock
@@ -109,9 +109,6 @@ NUGET
Microsoft.Extensions.Logging (>= 2.0)
Microsoft.Extensions.Logging.Configuration (>= 2.0)
Microsoft.Extensions.Options.ConfigurationExtensions (>= 2.0)
- Ply (0.3.1)
- FSharp.Core (>= 4.6.2)
- System.Threading.Tasks.Extensions (>= 4.5.4)
SimpleBase (4.0)
System.Memory (>= 4.5.5)
Sodium.Core (1.3.4)
@@ -135,4 +132,3 @@ NUGET
System.Runtime.CompilerServices.Unsafe (6.1.2)
System.Text.Json (10.0)
System.Threading.Channels (10.0.5)
- System.Threading.Tasks.Extensions (4.6.3)
diff --git a/backend/src/BuiltinCli/Libs/Directory.fs b/backend/src/BuiltinCli/Libs/Directory.fs
index af4d162795..8037315c69 100644
--- a/backend/src/BuiltinCli/Libs/Directory.fs
+++ b/backend/src/BuiltinCli/Libs/Directory.fs
@@ -2,7 +2,6 @@
module BuiltinCli.Libs.Directory
open System.Threading.Tasks
-open FSharp.Control.Tasks
open Prelude
open LibExecution.RuntimeTypes
@@ -21,10 +20,8 @@ let fns () : List =
fn =
(function
| _, _, _, [ DUnit ] ->
- uply {
- let contents = System.IO.Directory.GetCurrentDirectory()
- return DString contents
- }
+ let contents = System.IO.Directory.GetCurrentDirectory()
+ DString contents |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -38,8 +35,8 @@ let fns () : List =
description =
"Creates a new directory at the specified . If the directory already exists, no action is taken. Returns a Result type indicating success or failure."
fn =
- let resultOk r = Dval.resultOk KTUnit KTString r |> Ply
- let resultError r = Dval.resultError KTUnit KTString r |> Ply
+ let resultOk r = Dval.resultOk KTUnit KTString r |> Task.FromResult
+ let resultError r = Dval.resultError KTUnit KTString r |> Task.FromResult
(function
| _, _, _, [ DString path ] ->
try
@@ -61,8 +58,8 @@ let fns () : List =
description =
"Deletes the directory at the specified . If is set to true, it will delete the directory and its contents. If set to false (default), it will only delete an empty directory. Returns a Result type indicating success or failure."
fn =
- let resultOk r = Dval.resultOk KTUnit KTString r |> Ply
- let resultError r = Dval.resultError KTUnit KTString r |> Ply
+ let resultOk r = Dval.resultOk KTUnit KTString r |> Task.FromResult
+ let resultError r = Dval.resultError KTUnit KTString r |> Task.FromResult
(function
| _, _, _, [ DString path ] ->
try
@@ -84,16 +81,14 @@ let fns () : List =
fn =
(function
| _, _, _, [ DString path ] ->
- uply {
- // TODO make async
- let contents =
- try
- System.IO.Directory.EnumerateFileSystemEntries path |> Seq.toList
- with _ ->
- []
+ // TODO make async
+ let contents =
+ try
+ System.IO.Directory.EnumerateFileSystemEntries path |> Seq.toList
+ with _ ->
+ []
- return DList(VT.string, List.map DString contents)
- }
+ DList(VT.string, List.map DString contents) |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -108,11 +103,9 @@ let fns () : List =
fn =
(function
| _, _, _, [ DUnit ] ->
- uply {
- let exePath =
- System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName
- return DString exePath
- }
+ let exePath =
+ System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName
+ DString exePath |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
diff --git a/backend/src/BuiltinCli/Libs/Environment.fs b/backend/src/BuiltinCli/Libs/Environment.fs
index d60924fd80..796d44b760 100644
--- a/backend/src/BuiltinCli/Libs/Environment.fs
+++ b/backend/src/BuiltinCli/Libs/Environment.fs
@@ -2,7 +2,6 @@
module BuiltinCli.Libs.Environment
open System.Threading.Tasks
-open FSharp.Control.Tasks
open Prelude
open LibExecution.RuntimeTypes
@@ -26,9 +25,9 @@ let fns () : List =
let envValue = System.Environment.GetEnvironmentVariable(varName)
if isNull envValue then
- Dval.optionNone KTString |> Ply
+ Dval.optionNone KTString |> Task.FromResult
else
- Dval.optionSome KTString (DString envValue) |> Ply
+ Dval.optionSome KTString (DString envValue) |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -53,7 +52,7 @@ let fns () : List =
|> Seq.toList
|> Dval.dict KTString
- Ply(envMap)
+ Task.FromResult(envMap)
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -67,7 +66,7 @@ let fns () : List =
description = "Returns the git hash of the current CLI build"
fn =
function
- | _, _, [], [ DUnit ] -> uply { return DString LibConfig.Config.buildHash }
+ | _, _, [], [ DUnit ] -> Task.FromResult(DString LibConfig.Config.buildHash)
| _ -> incorrectArgs ()
sqlSpec = NotQueryable
previewable = Impure
diff --git a/backend/src/BuiltinCli/Libs/Execution.fs b/backend/src/BuiltinCli/Libs/Execution.fs
index 4293e274cf..e1e5bfcbe7 100644
--- a/backend/src/BuiltinCli/Libs/Execution.fs
+++ b/backend/src/BuiltinCli/Libs/Execution.fs
@@ -2,7 +2,6 @@
module BuiltinCli.Libs.Execution
open System.Threading.Tasks
-open FSharp.Control.Tasks
open System.Collections.Concurrent
open System.IO
open System.Threading
@@ -181,7 +180,7 @@ let fns () : List =
p.WaitForExit()
- createExecutionOutcome p.ExitCode stdout stderr |> Ply
+ createExecutionOutcome p.ExitCode stdout stderr |> Task.FromResult
| _ -> incorrectArgs ()
sqlSpec = NotQueryable
previewable = Impure
@@ -202,13 +201,13 @@ let fns () : List =
let resultError = Dval.resultError osTypeRef KTString
if RuntimeInformation.IsOSPlatform OSPlatform.Windows then
- OS.Windows |> OS.toDT |> resultOk |> Ply
+ OS.Windows |> OS.toDT |> resultOk |> Task.FromResult
else if RuntimeInformation.IsOSPlatform OSPlatform.Linux then
- OS.Linux |> OS.toDT |> resultOk |> Ply
+ OS.Linux |> OS.toDT |> resultOk |> Task.FromResult
else if RuntimeInformation.IsOSPlatform OSPlatform.OSX then
- OS.OSX |> OS.toDT |> resultOk |> Ply
+ OS.OSX |> OS.toDT |> resultOk |> Task.FromResult
else
- "Unsupported OS" |> DString |> resultError |> Ply
+ "Unsupported OS" |> DString |> resultError |> Task.FromResult
| _ -> incorrectArgs ()
sqlSpec = NotQueryable
@@ -254,7 +253,7 @@ let fns () : List =
ErrorBuffer = "" }
processHandles.TryAdd(processId, processInfo) |> ignore
- DInt64 processId |> Ply
+ DInt64 processId |> Task.FromResult
| _ -> incorrectArgs ()
sqlSpec = NotQueryable
previewable = Impure
@@ -356,11 +355,13 @@ let fns () : List =
else
0
createExecutionOutcome exitCode (stdout.ToString()) (stderr.ToString())
- |> Ply
+ |> Task.FromResult
with ex ->
- createExecutionOutcome -1L "" $"Process IO error: {ex.Message}" |> Ply
+ createExecutionOutcome -1L "" $"Process IO error: {ex.Message}"
+ |> Task.FromResult
| _ ->
- createExecutionOutcome -1L "" "Process not found or has exited" |> Ply
+ createExecutionOutcome -1L "" "Process not found or has exited"
+ |> Task.FromResult
| _ -> incorrectArgs ()
sqlSpec = NotQueryable
previewable = Impure
@@ -405,15 +406,17 @@ let fns () : List =
processHandles.TryRemove processId |> ignore
- createExecutionOutcome exitCode finalStdout finalStderr |> Ply
+ createExecutionOutcome exitCode finalStdout finalStderr
+ |> Task.FromResult
with ex ->
processHandles.TryRemove processId |> ignore
createExecutionOutcome
-1L
""
$"Process termination error: {ex.Message}"
- |> Ply
- | false, _ -> createExecutionOutcome -1L "" "Process not found" |> Ply
+ |> Task.FromResult
+ | false, _ ->
+ createExecutionOutcome -1L "" "Process not found" |> Task.FromResult
| _ -> incorrectArgs ()
sqlSpec = NotQueryable
previewable = Impure
diff --git a/backend/src/BuiltinCli/Libs/File.fs b/backend/src/BuiltinCli/Libs/File.fs
index 6bde2cde49..3a446bb34f 100644
--- a/backend/src/BuiltinCli/Libs/File.fs
+++ b/backend/src/BuiltinCli/Libs/File.fs
@@ -2,7 +2,6 @@
module BuiltinCli.Libs.File
open System.Threading.Tasks
-open FSharp.Control.Tasks
open Prelude
open LibExecution.RuntimeTypes
@@ -24,7 +23,7 @@ let fns () : List =
let resultError = Dval.resultError KTBlob KTString
(function
| state, _, _, [ DString path ] ->
- uply {
+ task {
try
let path =
path.Replace(
@@ -37,6 +36,7 @@ let fns () : List =
with e ->
return resultError (DString($"Error reading file: {e.Message}"))
}
+
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -54,7 +54,7 @@ let fns () : List =
let resultError = Dval.resultError KTUnit KTString
(function
| state, _, _, [ DBlob ref; DString path ] ->
- uply {
+ task {
try
let path =
path.Replace(
@@ -68,6 +68,7 @@ let fns () : List =
with e ->
return resultError (DString($"Error writing file: {e.Message}"))
}
+
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -82,17 +83,15 @@ let fns () : List =
fn =
(function
| _, _, _, [ DString path ] ->
- uply {
- try
- System.IO.File.Delete path
- return Dval.resultOk KTUnit KTString DUnit
- with e ->
- return
- Dval.resultError
- KTUnit
- KTString
- (DString $"Error deleting file: {e.Message}")
- }
+ try
+ System.IO.File.Delete path
+ Dval.resultOk KTUnit KTString DUnit |> Task.FromResult
+ with e ->
+ Dval.resultError
+ KTUnit
+ KTString
+ (DString $"Error deleting file: {e.Message}")
+ |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -110,13 +109,14 @@ let fns () : List =
let resultError = Dval.resultError KTUnit KTString
(function
| _, _, _, [ DString path; DString content ] ->
- uply {
+ task {
try
do! System.IO.File.AppendAllTextAsync(path, content)
return resultOk DUnit
with e ->
return resultError (DString e.Message)
}
+
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -130,8 +130,8 @@ let fns () : List =
description =
"Creates a new temporary file with a unique name in the system's temporary directory. Returns a Result type containing the temporary file path or an error if the creation fails."
fn =
- let resultOk r = Dval.resultOk KTString KTString r |> Ply
- let resultError r = Dval.resultError KTString KTString r |> Ply
+ let resultOk r = Dval.resultOk KTString KTString r |> Task.FromResult
+ let resultError r = Dval.resultError KTString KTString r |> Task.FromResult
(function
| _, _, _, [ DUnit ] ->
try
@@ -154,14 +154,12 @@ let fns () : List =
fn =
(function
| _, _, _, [ DString path ] ->
- uply {
- try
- let attrs = System.IO.File.GetAttributes(path)
- let isDir = attrs.HasFlag(System.IO.FileAttributes.Directory)
- return DBool isDir
- with _ ->
- return DBool false
- }
+ try
+ let attrs = System.IO.File.GetAttributes(path)
+ let isDir = attrs.HasFlag(System.IO.FileAttributes.Directory)
+ DBool isDir |> Task.FromResult
+ with _ ->
+ DBool false |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -177,16 +175,14 @@ let fns () : List =
fn =
(function
| _, _, _, [ DString path ] ->
- uply {
- try
- let attrs = System.IO.File.GetAttributes(path)
- let isDir = attrs.HasFlag(System.IO.FileAttributes.Directory)
- let exists =
- System.IO.File.Exists(path) || System.IO.Directory.Exists(path)
- return DBool(exists && not isDir)
- with _ ->
- return DBool false
- }
+ try
+ let attrs = System.IO.File.GetAttributes(path)
+ let isDir = attrs.HasFlag(System.IO.FileAttributes.Directory)
+ let exists =
+ System.IO.File.Exists(path) || System.IO.Directory.Exists(path)
+ DBool(exists && not isDir) |> Task.FromResult
+ with _ ->
+ DBool false |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -202,14 +198,12 @@ let fns () : List =
fn =
(function
| _, _, _, [ DString path ] ->
- uply {
- try
- let exists =
- System.IO.File.Exists(path) || System.IO.Directory.Exists(path)
- return DBool exists
- with _ ->
- return DBool false
- }
+ try
+ let exists =
+ System.IO.File.Exists(path) || System.IO.Directory.Exists(path)
+ DBool exists |> Task.FromResult
+ with _ ->
+ DBool false |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -223,8 +217,8 @@ let fns () : List =
description =
"Returns the size of the file at the specified in bytes, or an error if the file does not exist or an error occurs"
fn =
- let resultOk r = Dval.resultOk KTInt64 KTString r |> Ply
- let resultError r = Dval.resultError KTInt64 KTString r |> Ply
+ let resultOk r = Dval.resultOk KTInt64 KTString r |> Task.FromResult
+ let resultError r = Dval.resultError KTInt64 KTString r |> Task.FromResult
(function
| _, _, _, [ DString path ] ->
try
diff --git a/backend/src/BuiltinCli/Libs/Output.fs b/backend/src/BuiltinCli/Libs/Output.fs
index 08fe75856d..a081da02d4 100644
--- a/backend/src/BuiltinCli/Libs/Output.fs
+++ b/backend/src/BuiltinCli/Libs/Output.fs
@@ -3,7 +3,6 @@
module BuiltinCli.Libs.Output
open System.Threading.Tasks
-open FSharp.Control.Tasks
open Prelude
open LibExecution.RuntimeTypes
@@ -23,7 +22,7 @@ let fns () : List =
(function
| _, _, _, [ DString str ] ->
print str
- Ply DUnit
+ Task.FromResult DUnit
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -39,7 +38,7 @@ let fns () : List =
(function
| _, _, _, [ DString str ] ->
printInline str
- Ply DUnit
+ Task.FromResult DUnit
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -58,7 +57,7 @@ let fns () : List =
System.Console.Clear()
else
System.Console.Write("\u001b[2J\u001b[H") // ANSI escape for non-Windows
- Ply DUnit
+ Task.FromResult DUnit
| _ -> incorrectArgs ()
sqlSpec = NotQueryable
previewable = Impure
diff --git a/backend/src/BuiltinCli/Libs/Posix.fs b/backend/src/BuiltinCli/Libs/Posix.fs
index e2571c28d1..5b423f4500 100644
--- a/backend/src/BuiltinCli/Libs/Posix.fs
+++ b/backend/src/BuiltinCli/Libs/Posix.fs
@@ -16,6 +16,7 @@ module PackageRefs = LibExecution.PackageRefs
module NR = LibExecution.RuntimeTypes.NameResolution
module Blob = LibExecution.Blob
open Builtin.Shortcuts
+open System.Threading.Tasks
// =====================================================================
@@ -489,9 +490,11 @@ let fns () : List =
(function
| _, _, _, [ DUnit ] ->
match Libc.getcwd () with
- | Ok cwd -> Dval.resultOk KTString (posixErrorKT ()) (DString cwd) |> Ply
+ | Ok cwd ->
+ Dval.resultOk KTString (posixErrorKT ()) (DString cwd) |> Task.FromResult
| Error e ->
- Dval.resultError KTString (posixErrorKT ()) (dPosixError e) |> Ply
+ Dval.resultError KTString (posixErrorKT ()) (dPosixError e)
+ |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -507,9 +510,10 @@ let fns () : List =
(function
| _, _, _, [ DString path ] ->
match Libc.chdir path with
- | Ok() -> Dval.resultOk KTUnit (posixErrorKT ()) DUnit |> Ply
+ | Ok() -> Dval.resultOk KTUnit (posixErrorKT ()) DUnit |> Task.FromResult
| Error e ->
- Dval.resultError KTUnit (posixErrorKT ()) (dPosixError e) |> Ply
+ Dval.resultError KTUnit (posixErrorKT ()) (dPosixError e)
+ |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -527,9 +531,10 @@ let fns () : List =
(function
| _, _, _, [ DString name; DString value ] ->
match Libc.setenv name value with
- | Ok() -> Dval.resultOk KTUnit (posixErrorKT ()) DUnit |> Ply
+ | Ok() -> Dval.resultOk KTUnit (posixErrorKT ()) DUnit |> Task.FromResult
| Error e ->
- Dval.resultError KTUnit (posixErrorKT ()) (dPosixError e) |> Ply
+ Dval.resultError KTUnit (posixErrorKT ()) (dPosixError e)
+ |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -545,9 +550,10 @@ let fns () : List =
(function
| _, _, _, [ DString name ] ->
match Libc.unsetenv name with
- | Ok() -> Dval.resultOk KTUnit (posixErrorKT ()) DUnit |> Ply
+ | Ok() -> Dval.resultOk KTUnit (posixErrorKT ()) DUnit |> Task.FromResult
| Error e ->
- Dval.resultError KTUnit (posixErrorKT ()) (dPosixError e) |> Ply
+ Dval.resultError KTUnit (posixErrorKT ()) (dPosixError e)
+ |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -565,9 +571,10 @@ let fns () : List =
(function
| _, _, _, [ DString path; DInt64 mode ] ->
match Libc.mkdir path (int mode) with
- | Ok() -> Dval.resultOk KTUnit (posixErrorKT ()) DUnit |> Ply
+ | Ok() -> Dval.resultOk KTUnit (posixErrorKT ()) DUnit |> Task.FromResult
| Error e ->
- Dval.resultError KTUnit (posixErrorKT ()) (dPosixError e) |> Ply
+ Dval.resultError KTUnit (posixErrorKT ()) (dPosixError e)
+ |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -583,9 +590,10 @@ let fns () : List =
(function
| _, _, _, [ DString path ] ->
match Libc.rmdir path with
- | Ok() -> Dval.resultOk KTUnit (posixErrorKT ()) DUnit |> Ply
+ | Ok() -> Dval.resultOk KTUnit (posixErrorKT ()) DUnit |> Task.FromResult
| Error e ->
- Dval.resultError KTUnit (posixErrorKT ()) (dPosixError e) |> Ply
+ Dval.resultError KTUnit (posixErrorKT ()) (dPosixError e)
+ |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -601,9 +609,10 @@ let fns () : List =
(function
| _, _, _, [ DString path ] ->
match Libc.unlink path with
- | Ok() -> Dval.resultOk KTUnit (posixErrorKT ()) DUnit |> Ply
+ | Ok() -> Dval.resultOk KTUnit (posixErrorKT ()) DUnit |> Task.FromResult
| Error e ->
- Dval.resultError KTUnit (posixErrorKT ()) (dPosixError e) |> Ply
+ Dval.resultError KTUnit (posixErrorKT ()) (dPosixError e)
+ |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -621,9 +630,10 @@ let fns () : List =
(function
| _, _, _, [ DString oldpath; DString newpath ] ->
match Libc.rename oldpath newpath with
- | Ok() -> Dval.resultOk KTUnit (posixErrorKT ()) DUnit |> Ply
+ | Ok() -> Dval.resultOk KTUnit (posixErrorKT ()) DUnit |> Task.FromResult
| Error e ->
- Dval.resultError KTUnit (posixErrorKT ()) (dPosixError e) |> Ply
+ Dval.resultError KTUnit (posixErrorKT ()) (dPosixError e)
+ |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -641,9 +651,10 @@ let fns () : List =
(function
| _, _, _, [ DString path; DInt64 mode ] ->
match Libc.chmod path (int mode) with
- | Ok() -> Dval.resultOk KTUnit (posixErrorKT ()) DUnit |> Ply
+ | Ok() -> Dval.resultOk KTUnit (posixErrorKT ()) DUnit |> Task.FromResult
| Error e ->
- Dval.resultError KTUnit (posixErrorKT ()) (dPosixError e) |> Ply
+ Dval.resultError KTUnit (posixErrorKT ()) (dPosixError e)
+ |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -659,9 +670,10 @@ let fns () : List =
(function
| _, _, _, [ DString path ] ->
match Libc.utimesNow path with
- | Ok() -> Dval.resultOk KTUnit (posixErrorKT ()) DUnit |> Ply
+ | Ok() -> Dval.resultOk KTUnit (posixErrorKT ()) DUnit |> Task.FromResult
| Error e ->
- Dval.resultError KTUnit (posixErrorKT ()) (dPosixError e) |> Ply
+ Dval.resultError KTUnit (posixErrorKT ()) (dPosixError e)
+ |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -679,9 +691,10 @@ let fns () : List =
(function
| _, _, _, [ DString target; DString linkpath ] ->
match Libc.symlink target linkpath with
- | Ok() -> Dval.resultOk KTUnit (posixErrorKT ()) DUnit |> Ply
+ | Ok() -> Dval.resultOk KTUnit (posixErrorKT ()) DUnit |> Task.FromResult
| Error e ->
- Dval.resultError KTUnit (posixErrorKT ()) (dPosixError e) |> Ply
+ Dval.resultError KTUnit (posixErrorKT ()) (dPosixError e)
+ |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -698,9 +711,11 @@ let fns () : List =
| _, _, _, [ DString path ] ->
match Libc.readlink path with
| Ok target ->
- Dval.resultOk KTString (posixErrorKT ()) (DString target) |> Ply
+ Dval.resultOk KTString (posixErrorKT ()) (DString target)
+ |> Task.FromResult
| Error e ->
- Dval.resultError KTString (posixErrorKT ()) (dPosixError e) |> Ply
+ Dval.resultError KTString (posixErrorKT ()) (dPosixError e)
+ |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -727,8 +742,8 @@ let fns () : List =
Dval.resultError (KTTuple(VT.int64, VT.string, [])) (posixErrorKT ())
match Libc.mkstemp prefix with
| Ok(fd, path) ->
- resultOk (DTuple(DInt64(int64 fd), DString path, [])) |> Ply
- | Error e -> resultError (dPosixError e) |> Ply
+ resultOk (DTuple(DInt64(int64 fd), DString path, [])) |> Task.FromResult
+ | Error e -> resultError (dPosixError e) |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -749,9 +764,12 @@ let fns () : List =
(function
| _, _, _, [ DString prefix ] ->
match Libc.mkdtemp prefix with
- | Ok path -> Dval.resultOk KTString (posixErrorKT ()) (DString path) |> Ply
+ | Ok path ->
+ Dval.resultOk KTString (posixErrorKT ()) (DString path)
+ |> Task.FromResult
| Error e ->
- Dval.resultError KTString (posixErrorKT ()) (dPosixError e) |> Ply
+ Dval.resultError KTString (posixErrorKT ()) (dPosixError e)
+ |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -774,8 +792,8 @@ let fns () : List =
match Libc.listDir path with
| Ok entries ->
let dvals = entries |> List.map DString
- resultOk (DList(ValueType.Known KTString, dvals)) |> Ply
- | Error e -> resultError (dPosixError e) |> Ply
+ resultOk (DList(ValueType.Known KTString, dvals)) |> Task.FromResult
+ | Error e -> resultError (dPosixError e) |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -791,8 +809,8 @@ let fns () : List =
(function
| _, _, _, [ DString name ] ->
match Libc.getenv name with
- | Some v -> Dval.optionSome KTString (DString v) |> Ply
- | None -> Dval.optionNone KTString |> Ply
+ | Some v -> Dval.optionSome KTString (DString v) |> Task.FromResult
+ | None -> Dval.optionNone KTString |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -832,8 +850,8 @@ let fns () : List =
resultOk (
DTuple(DInt64(int64 exitCode), DString stdout, [ DString stderr ])
)
- |> Ply
- | Error e -> resultError (dPosixError e) |> Ply
+ |> Task.FromResult
+ | Error e -> resultError (dPosixError e) |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -874,8 +892,8 @@ let fns () : List =
resultOk (
DTuple(DInt64(int64 exitCode), DString stdout, [ DString stderr ])
)
- |> Ply
- | Error e -> resultError (dPosixError e) |> Ply
+ |> Task.FromResult
+ | Error e -> resultError (dPosixError e) |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -896,9 +914,10 @@ let fns () : List =
(function
| _, _, _, [ DInt64 pid; DInt64 signal ] ->
match Libc.kill (int pid) (int signal) with
- | Ok() -> Dval.resultOk KTUnit (posixErrorKT ()) DUnit |> Ply
+ | Ok() -> Dval.resultOk KTUnit (posixErrorKT ()) DUnit |> Task.FromResult
| Error e ->
- Dval.resultError KTUnit (posixErrorKT ()) (dPosixError e) |> Ply
+ Dval.resultError KTUnit (posixErrorKT ()) (dPosixError e)
+ |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -919,8 +938,8 @@ let fns () : List =
let resultOk = Dval.resultOk KTBlob (posixErrorKT ())
let resultError = Dval.resultError KTBlob (posixErrorKT ())
match Libc.fdRead (int fd) (int count) with
- | Ok bytes -> resultOk (Blob.newEphemeral state bytes) |> Ply
- | Error e -> resultError (dPosixError e) |> Ply
+ | Ok bytes -> resultOk (Blob.newEphemeral state bytes) |> Task.FromResult
+ | Error e -> resultError (dPosixError e) |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -937,7 +956,7 @@ let fns () : List =
fn =
(function
| state, _, _, [ DInt64 fd; DBlob ref ] ->
- uply {
+ task {
let! bytes = Blob.readBytes state ref
match Libc.fdWrite (int fd) bytes with
| Ok n ->
@@ -945,6 +964,7 @@ let fns () : List =
| Error e ->
return Dval.resultError KTInt64 (posixErrorKT ()) (dPosixError e)
}
+
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -960,9 +980,10 @@ let fns () : List =
(function
| _, _, _, [ DInt64 fd ] ->
match Libc.fdClose (int fd) with
- | Ok() -> Dval.resultOk KTUnit (posixErrorKT ()) DUnit |> Ply
+ | Ok() -> Dval.resultOk KTUnit (posixErrorKT ()) DUnit |> Task.FromResult
| Error e ->
- Dval.resultError KTUnit (posixErrorKT ()) (dPosixError e) |> Ply
+ Dval.resultError KTUnit (posixErrorKT ()) (dPosixError e)
+ |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -985,9 +1006,11 @@ let fns () : List =
| _, _, _, [ DString path; DInt64 flags; DInt64 mode ] ->
match Libc.openFile path (int flags) (int mode) with
| Ok fd ->
- Dval.resultOk KTInt64 (posixErrorKT ()) (DInt64(int64 fd)) |> Ply
+ Dval.resultOk KTInt64 (posixErrorKT ()) (DInt64(int64 fd))
+ |> Task.FromResult
| Error e ->
- Dval.resultError KTInt64 (posixErrorKT ()) (dPosixError e) |> Ply
+ Dval.resultError KTInt64 (posixErrorKT ()) (dPosixError e)
+ |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -1001,7 +1024,7 @@ let fns () : List =
description = "Returns the O_RDONLY flag for open()"
fn =
(function
- | _, _, _, [ DUnit ] -> DInt64(int64 Libc.O_RDONLY) |> Ply
+ | _, _, _, [ DUnit ] -> DInt64(int64 Libc.O_RDONLY) |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Pure
@@ -1015,7 +1038,7 @@ let fns () : List =
description = "Returns the O_WRONLY flag for open()"
fn =
(function
- | _, _, _, [ DUnit ] -> DInt64(int64 Libc.O_WRONLY) |> Ply
+ | _, _, _, [ DUnit ] -> DInt64(int64 Libc.O_WRONLY) |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Pure
@@ -1029,7 +1052,7 @@ let fns () : List =
description = "Returns the O_RDWR flag for open()"
fn =
(function
- | _, _, _, [ DUnit ] -> DInt64(int64 Libc.O_RDWR) |> Ply
+ | _, _, _, [ DUnit ] -> DInt64(int64 Libc.O_RDWR) |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Pure
@@ -1043,7 +1066,7 @@ let fns () : List =
description = "Returns the O_CREAT flag for open() (platform-aware)"
fn =
(function
- | _, _, _, [ DUnit ] -> DInt64(int64 Libc.O_CREAT) |> Ply
+ | _, _, _, [ DUnit ] -> DInt64(int64 Libc.O_CREAT) |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Pure
@@ -1057,7 +1080,7 @@ let fns () : List =
description = "Returns the O_TRUNC flag for open() (platform-aware)"
fn =
(function
- | _, _, _, [ DUnit ] -> DInt64(int64 Libc.O_TRUNC) |> Ply
+ | _, _, _, [ DUnit ] -> DInt64(int64 Libc.O_TRUNC) |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Pure
@@ -1071,7 +1094,7 @@ let fns () : List =
description = "Returns the O_APPEND flag for open() (platform-aware)"
fn =
(function
- | _, _, _, [ DUnit ] -> DInt64(int64 Libc.O_APPEND) |> Ply
+ | _, _, _, [ DUnit ] -> DInt64(int64 Libc.O_APPEND) |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Pure
@@ -1100,8 +1123,8 @@ let fns () : List =
match Libc.stat path with
| Ok(mode, size, mtimeSec) ->
resultOk (DTuple(DInt64(int64 mode), DInt64 size, [ DInt64 mtimeSec ]))
- |> Ply
- | Error e -> resultError (dPosixError e) |> Ply
+ |> Task.FromResult
+ | Error e -> resultError (dPosixError e) |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -1130,8 +1153,8 @@ let fns () : List =
match Libc.uname () with
| Ok(sysname, nodename, machine) ->
resultOk (DTuple(DString sysname, DString nodename, [ DString machine ]))
- |> Ply
- | Error e -> resultError (dPosixError e) |> Ply
+ |> Task.FromResult
+ | Error e -> resultError (dPosixError e) |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -1145,7 +1168,7 @@ let fns () : List =
description = "Returns the current process ID via libc getpid()"
fn =
(function
- | _, _, _, [ DUnit ] -> DInt64(int64 (Libc.getpid ())) |> Ply
+ | _, _, _, [ DUnit ] -> DInt64(int64 (Libc.getpid ())) |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -1159,7 +1182,7 @@ let fns () : List =
description = "Returns the current user ID via libc getuid()"
fn =
(function
- | _, _, _, [ DUnit ] -> DInt64(int64 (Libc.getuid ())) |> Ply
+ | _, _, _, [ DUnit ] -> DInt64(int64 (Libc.getuid ())) |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -1177,8 +1200,8 @@ let fns () : List =
| _, _, _, [ DUnit ] ->
let uid = Libc.getuid ()
match Libc.getUserName (uint32 uid) with
- | Some name -> Dval.optionSome KTString (DString name) |> Ply
- | None -> Dval.optionNone KTString |> Ply
+ | Some name -> Dval.optionSome KTString (DString name) |> Task.FromResult
+ | None -> Dval.optionNone KTString |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -1192,7 +1215,7 @@ let fns () : List =
description = "Returns the number of online CPUs via sysconf()"
fn =
(function
- | _, _, _, [ DUnit ] -> DInt64(Libc.cpuCount ()) |> Ply
+ | _, _, _, [ DUnit ] -> DInt64(Libc.cpuCount ()) |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -1209,8 +1232,8 @@ let fns () : List =
(function
| _, _, _, [ DUnit ] ->
match Libc.getHomeDir () with
- | Some dir -> Dval.optionSome KTString (DString dir) |> Ply
- | None -> Dval.optionNone KTString |> Ply
+ | Some dir -> Dval.optionSome KTString (DString dir) |> Task.FromResult
+ | None -> Dval.optionNone KTString |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -1229,7 +1252,7 @@ let fns () : List =
(function
| _, _, _, [ DString pattern; DString str; DBool pathMode ] ->
let flags = if pathMode then Libc.FNM_PATHNAME else 0
- DBool(Libc.fnmatch pattern str flags) |> Ply
+ DBool(Libc.fnmatch pattern str flags) |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Pure
@@ -1248,9 +1271,10 @@ let fns () : List =
| _, _, _, [ DInt64 fd; DBool exclusive ] ->
let op = if exclusive then Libc.LOCK_EX else Libc.LOCK_UN
match Libc.flock (int fd) op with
- | Ok() -> Dval.resultOk KTUnit (posixErrorKT ()) DUnit |> Ply
+ | Ok() -> Dval.resultOk KTUnit (posixErrorKT ()) DUnit |> Task.FromResult
| Error e ->
- Dval.resultError KTUnit (posixErrorKT ()) (dPosixError e) |> Ply
+ Dval.resultError KTUnit (posixErrorKT ()) (dPosixError e)
+ |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -1266,9 +1290,12 @@ let fns () : List =
(function
| _, _, _, [ DString path ] ->
match Libc.fileOwner path with
- | Ok name -> Dval.resultOk KTString (posixErrorKT ()) (DString name) |> Ply
+ | Ok name ->
+ Dval.resultOk KTString (posixErrorKT ()) (DString name)
+ |> Task.FromResult
| Error e ->
- Dval.resultError KTString (posixErrorKT ()) (dPosixError e) |> Ply
+ Dval.resultError KTString (posixErrorKT ()) (dPosixError e)
+ |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
diff --git a/backend/src/BuiltinCli/Libs/Process.fs b/backend/src/BuiltinCli/Libs/Process.fs
index 76dc76bfbc..92c8569c96 100644
--- a/backend/src/BuiltinCli/Libs/Process.fs
+++ b/backend/src/BuiltinCli/Libs/Process.fs
@@ -2,7 +2,6 @@
module BuiltinCli.Libs.Process
open System.Threading.Tasks
-open FSharp.Control.Tasks
open Prelude
open LibExecution.RuntimeTypes
@@ -22,49 +21,48 @@ let fns () : List =
fn =
(function
| _state, _, _, [ DList(_vtTODO, args) ] ->
- uply {
- try
- let argStrings =
- args
- |> List.map (fun arg ->
- match arg with
- | DString s -> s
- | _ -> Exception.raiseInternal "Expected string arguments" [])
-
- // Get the current executable path
- let currentExe =
- System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName
-
- let psi = System.Diagnostics.ProcessStartInfo()
- psi.FileName <- currentExe
- psi.UseShellExecute <- false
- psi.CreateNoWindow <- true
- // Redirect to prevent inheriting parent's streams
- psi.RedirectStandardOutput <- true
- psi.RedirectStandardError <- true
- psi.RedirectStandardInput <- true
-
- // Add arguments
- for arg in argStrings do
- psi.ArgumentList.Add(arg)
-
- let proc = System.Diagnostics.Process.Start(psi)
-
- if isNull proc then
- return
- Dval.resultError
- KTInt64
- KTString
- (DString "Failed to start background process")
- else
- return Dval.resultOk KTInt64 KTString (DInt64(int64 proc.Id))
- with ex ->
- return
- Dval.resultError
- KTInt64
- KTString
- (DString $"Error spawning process: {ex.Message}")
- }
+ try
+ let argStrings =
+ args
+ |> List.map (fun arg ->
+ match arg with
+ | DString s -> s
+ | _ -> Exception.raiseInternal "Expected string arguments" [])
+
+ // Get the current executable path
+ let currentExe =
+ System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName
+
+ let psi = System.Diagnostics.ProcessStartInfo()
+ psi.FileName <- currentExe
+ psi.UseShellExecute <- false
+ psi.CreateNoWindow <- true
+ // Redirect to prevent inheriting parent's streams
+ psi.RedirectStandardOutput <- true
+ psi.RedirectStandardError <- true
+ psi.RedirectStandardInput <- true
+
+ // Add arguments
+ for arg in argStrings do
+ psi.ArgumentList.Add(arg)
+
+ let proc = System.Diagnostics.Process.Start(psi)
+
+ if isNull proc then
+ Dval.resultError
+ KTInt64
+ KTString
+ (DString "Failed to start background process")
+ |> Task.FromResult
+ else
+ Dval.resultOk KTInt64 KTString (DInt64(int64 proc.Id))
+ |> Task.FromResult
+ with ex ->
+ Dval.resultError
+ KTInt64
+ KTString
+ (DString $"Error spawning process: {ex.Message}")
+ |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotYetImplemented
previewable = Impure
@@ -79,18 +77,15 @@ let fns () : List =
fn =
(function
| _, _, _, [ DInt64 pid ] ->
- uply {
- try
- let proc = System.Diagnostics.Process.GetProcessById(int pid)
- let isRunning = not proc.HasExited
- return DBool isRunning
- with
- | :? System.ArgumentException
-
- | :? System.InvalidOperationException ->
- // Process doesn't exist or has exited
- return DBool false
- }
+ try
+ let proc = System.Diagnostics.Process.GetProcessById(int pid)
+ let isRunning = not proc.HasExited
+ DBool isRunning |> Task.FromResult
+ with
+ | :? System.ArgumentException
+ | :? System.InvalidOperationException ->
+ // Process doesn't exist or has exited
+ DBool false |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotYetImplemented
previewable = Impure
@@ -106,22 +101,21 @@ let fns () : List =
fn =
(function
| _state, _, _, [ DInt64 pid ] ->
- uply {
- try
- let proc = System.Diagnostics.Process.GetProcessById(int pid)
- proc.Kill()
- proc.WaitForExit(5000) |> ignore
- return Dval.resultOk KTUnit KTString DUnit
- with
- | :? System.ArgumentException ->
- return Dval.resultError KTUnit KTString (DString "Process not found")
- | ex ->
- return
- Dval.resultError
- KTUnit
- KTString
- (DString $"Error killing process: {ex.Message}")
- }
+ try
+ let proc = System.Diagnostics.Process.GetProcessById(int pid)
+ proc.Kill()
+ proc.WaitForExit(5000) |> ignore
+ Dval.resultOk KTUnit KTString DUnit |> Task.FromResult
+ with
+ | :? System.ArgumentException ->
+ Dval.resultError KTUnit KTString (DString "Process not found")
+ |> Task.FromResult
+ | ex ->
+ Dval.resultError
+ KTUnit
+ KTString
+ (DString $"Error killing process: {ex.Message}")
+ |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotYetImplemented
previewable = Impure
diff --git a/backend/src/BuiltinCli/Libs/Stdin.fs b/backend/src/BuiltinCli/Libs/Stdin.fs
index c7256afa79..4ef8ee5696 100644
--- a/backend/src/BuiltinCli/Libs/Stdin.fs
+++ b/backend/src/BuiltinCli/Libs/Stdin.fs
@@ -11,6 +11,7 @@ module PackageRefs = LibExecution.PackageRefs
module NR = LibExecution.RuntimeTypes.NameResolution
open Builtin.Shortcuts
+open System.Threading.Tasks
/// Drain any buffered input characters that arrived in a burst
/// (e.g. mouse wheel scroll generates many escape sequences at once).
@@ -229,7 +230,7 @@ let fns () : List =
Map [ "key", key; "modifiers", modifiers; "keyChar", keyChar ]
)
- Ply(keyRead)
+ Task.FromResult(keyRead)
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -245,7 +246,10 @@ let fns () : List =
(function
| _, _, _, [ DUnit ] ->
let input = System.Console.ReadLine()
- if input = null then Ply(DString "") else Ply(DString input)
+ if input = null then
+ Task.FromResult(DString "")
+ else
+ Task.FromResult(DString input)
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -262,7 +266,7 @@ let fns () : List =
| _, _, _, [ DUnit ] ->
(not Console.IsInputRedirected || not Console.IsOutputRedirected)
|> DBool
- |> Ply
+ |> Task.FromResult
| _ -> incorrectArgs ()
sqlSpec = NotQueryable
previewable = Impure
@@ -283,7 +287,7 @@ let fns () : List =
let buffer = Array.zeroCreate (int length)
let bytesRead = System.Console.In.Read(buffer, 0, (int length))
let input = System.String(buffer, 0, bytesRead)
- Ply(DString input)
+ Task.FromResult(DString input)
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -301,7 +305,7 @@ let fns () : List =
(function
| _, _, _, [ DUnit ] ->
let input = System.Console.In.ReadToEnd()
- Ply(DString input)
+ Task.FromResult(DString input)
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
diff --git a/backend/src/BuiltinCli/Libs/Terminal.fs b/backend/src/BuiltinCli/Libs/Terminal.fs
index c4dc22460d..26d4326905 100644
--- a/backend/src/BuiltinCli/Libs/Terminal.fs
+++ b/backend/src/BuiltinCli/Libs/Terminal.fs
@@ -1,7 +1,6 @@
module BuiltinCli.Libs.Terminal
open System.Threading.Tasks
-open FSharp.Control.Tasks
open Prelude
open LibExecution.RuntimeTypes
@@ -99,7 +98,7 @@ let fns () : List =
24
&cachedHeight
)
- |> Ply
+ |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -122,7 +121,7 @@ let fns () : List =
80
&cachedWidth
)
- |> Ply
+ |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -136,7 +135,7 @@ let fns () : List =
description = "Returns the absolute path to the CLI log directory"
fn =
(function
- | _, _, [], [ DUnit ] -> DString(LibConfig.Config.logDir) |> Ply
+ | _, _, [], [ DUnit ] -> DString(LibConfig.Config.logDir) |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
diff --git a/backend/src/BuiltinCli/Libs/Time.fs b/backend/src/BuiltinCli/Libs/Time.fs
index a7cd9101a5..b553705d5a 100644
--- a/backend/src/BuiltinCli/Libs/Time.fs
+++ b/backend/src/BuiltinCli/Libs/Time.fs
@@ -2,7 +2,6 @@
module BuiltinCli.Libs.Time
open System.Threading.Tasks
-open FSharp.Control.Tasks
open Prelude
open LibExecution.RuntimeTypes
@@ -19,11 +18,12 @@ let fns () : List =
fn =
(function
| _, _, _, [ DFloat delay ] ->
- uply {
+ task {
let delay = System.TimeSpan.FromMilliseconds delay
do! Task.Delay(delay)
return DUnit
}
+
| _ -> incorrectArgs ())
sqlSpec = NotYetImplemented
previewable = Impure
@@ -42,7 +42,7 @@ let fns () : List =
| _, _, _, [ DUnit ] ->
let ts = System.Diagnostics.Stopwatch.GetTimestamp()
let ms = ts * 1000L / System.Diagnostics.Stopwatch.Frequency
- DInt64 ms |> Ply
+ DInt64 ms |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotYetImplemented
previewable = Impure
@@ -58,7 +58,7 @@ let fns () : List =
| _, vm, _, [ DUnit ] ->
vm.stats.reset ()
vm.stats.enabled <- true
- DUnit |> Ply
+ DUnit |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotYetImplemented
previewable = Impure
@@ -120,7 +120,7 @@ let fns () : List =
sb.Append("}") |> ignore
sb.Append("}") |> ignore
- DString(sb.ToString()) |> Ply
+ DString(sb.ToString()) |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotYetImplemented
previewable = Impure
@@ -138,7 +138,7 @@ let fns () : List =
| _, vm, _, [ DBool enabled ] ->
vm.stats.enabled <- true
vm.stats.detailedTiming <- enabled
- DUnit |> Ply
+ DUnit |> Task.FromResult
| _ -> incorrectArgs ())
sqlSpec = NotYetImplemented
previewable = Impure
diff --git a/backend/src/BuiltinCli/paket.references b/backend/src/BuiltinCli/paket.references
index 4b5bc5d60f..0dec7672bd 100644
--- a/backend/src/BuiltinCli/paket.references
+++ b/backend/src/BuiltinCli/paket.references
@@ -1,3 +1,2 @@
-Ply
FSharp.Core
FSharpPlus
\ No newline at end of file
diff --git a/backend/src/BuiltinCliHost/Libs/Canvas.fs b/backend/src/BuiltinCliHost/Libs/Canvas.fs
index a9004d8c8d..65b03a4443 100644
--- a/backend/src/BuiltinCliHost/Libs/Canvas.fs
+++ b/backend/src/BuiltinCliHost/Libs/Canvas.fs
@@ -1,6 +1,7 @@
/// Builtin functions for canvas and DB operations in the CLI
module BuiltinCliHost.Libs.Canvas
+open System.Threading.Tasks
open Prelude
open LibExecution.RuntimeTypes
open LibExecution.Builtin.Shortcuts
@@ -34,7 +35,7 @@ let fns () : List =
(function
| _, _, _, [ DUuid canvasID; DString dbName; typeHashDval ] ->
let typeHash = PT2DT.Hash.fromDT typeHashDval
- uply {
+ task {
// Check for existing DB with the same name
let! existing =
Sql.query
@@ -70,6 +71,7 @@ let fns () : List =
do! Canvas.saveTLIDs canvasID [ (toplevel, Serialize.NotDeleted) ]
return Dval.resultOk KTUInt64 KTString (DUInt64 tlid)
}
+
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -87,10 +89,11 @@ let fns () : List =
fn =
(function
| _, _, _, [ DUuid accountID; DString domain ] ->
- uply {
+ task {
let! canvasID = Canvas.getOrCreateForAccount accountID domain
return DUuid canvasID
}
+
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -108,29 +111,30 @@ let fns () : List =
fn =
(function
| _, _, _, [ DUuid canvasID; DUuid branchId ] ->
- uply {
+ task {
let! canvas = Canvas.loadAllDBs canvasID
let pm = LibPackageManager.PackageManager.pt
let! dbs =
canvas.dbs
|> Map.values
- |> Ply.List.mapSequentially (fun (db : PT.DB.T) ->
- uply {
+ |> Task.mapSequentially (fun (db : PT.DB.T) ->
+ task {
let! typeName =
match db.typ with
| PT.TypeReference.TCustomType({ resolved = Ok(PT.FQTypeName.Package typeID) },
_) ->
- uply {
+ task {
let! locs = pm.getTypeLocations branchId typeID
match locs with
| location :: _ -> return PackageLocation.toFQN location
| [] -> return typeID.ToString()
}
- | _ -> Ply "unknown"
+ | _ -> Task.FromResult "unknown"
return DTuple(DString db.name, DString typeName, [])
})
return Dval.list (KTTuple(VT.string, VT.string, [])) dbs
}
+
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -148,7 +152,7 @@ let fns () : List =
fn =
(function
| _, _, _, [ DUuid canvasID; DString dbName ] ->
- uply {
+ task {
let! matchingTlids =
Sql.query
"SELECT tlid FROM toplevels_v0
@@ -184,6 +188,7 @@ let fns () : List =
|> Sql.executeStatementAsync)
return Dval.resultOk KTUnit KTString DUnit
}
+
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
@@ -199,12 +204,13 @@ let fns () : List =
fn =
(function
| _, _, _, [ DString name ] ->
- uply {
+ task {
let! result = Account.getUserByName name
match result with
| Some userID -> return Dval.optionSome KTUuid (DUuid userID)
| None -> return Dval.optionNone KTUuid
}
+
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
previewable = Impure
diff --git a/backend/src/BuiltinCliHost/Libs/Cli.fs b/backend/src/BuiltinCliHost/Libs/Cli.fs
index 98bdc9b033..7221a4824e 100644
--- a/backend/src/BuiltinCliHost/Libs/Cli.fs
+++ b/backend/src/BuiltinCliHost/Libs/Cli.fs
@@ -3,7 +3,6 @@
module BuiltinCliHost.Libs.Cli
open System.Threading.Tasks
-open FSharp.Control.Tasks
open Prelude
@@ -32,8 +31,8 @@ module Tracing = LibCloud.Tracing
// Load canvas ID and DBs for an account
let loadCanvasAndDBs
(accountID : Option)
- : Ply