Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Continued safe Dval-creation #5130

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions backend/experiments/BwdDangerServer/DangerExecution.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ open Prelude

module RT = LibExecution.RuntimeTypes
module VT = RT.ValueType
module Dval = LibExecution.Dval
module PT = LibExecution.ProgramTypes
module PT2RT = LibExecution.ProgramTypesToRuntimeTypes
module AT = LibExecution.AnalysisTypes
Expand Down Expand Up @@ -148,7 +147,7 @@ let executeHandler

let fields : List<string * RT.Dval> =
[ "statusCode", RT.DInt 500
"headers", Dval.list (RT.KTTuple(VT.string, VT.string, [])) []
"headers", RT.Dval.list (RT.KTTuple(VT.string, VT.string, [])) []
"body", RT.DBytes(UTF8.toBytes msg) ]

RT.DRecord(typeName, typeName, [], Map fields)
Expand Down
1 change: 0 additions & 1 deletion backend/experiments/BwdDangerServer/Libs/Experiments.fs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ open LibExecution.RuntimeTypes
open LibExecution.Builtin.Shortcuts

module VT = ValueType
module Dval = LibExecution.Dval
module PT2RT = LibExecution.ProgramTypesToRuntimeTypes

// This makes extra careful that we're only accessing files where we expect to
Expand Down
1 change: 0 additions & 1 deletion backend/src/BuiltinCli/Libs/Directory.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ open FSharp.Control.Tasks
open Prelude
open LibExecution.RuntimeTypes
module VT = ValueType
module Dval = LibExecution.Dval
module Builtin = LibExecution.Builtin
open Builtin.Shortcuts

Expand Down
2 changes: 0 additions & 2 deletions backend/src/BuiltinCli/Libs/Environment.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ open FSharp.Control.Tasks
open Prelude
open LibExecution.RuntimeTypes

module VT = ValueType
module Dval = LibExecution.Dval
module Builtin = LibExecution.Builtin
open Builtin.Shortcuts

Expand Down
2 changes: 0 additions & 2 deletions backend/src/BuiltinCli/Libs/File.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ open FSharp.Control.Tasks

open Prelude
open LibExecution.RuntimeTypes
module VT = ValueType
module Dval = LibExecution.Dval
module Builtin = LibExecution.Builtin
open Builtin.Shortcuts

Expand Down
1 change: 0 additions & 1 deletion backend/src/BuiltinCli/Libs/Process.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ open FSharp.Control.Tasks
open Prelude
open LibExecution.RuntimeTypes

module Dval = LibExecution.Dval
module Builtin = LibExecution.Builtin
open Builtin.Shortcuts

Expand Down
1 change: 0 additions & 1 deletion backend/src/BuiltinCliHost/Libs/Cli.fs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ open LibExecution.Builtin.Shortcuts
module PT = LibExecution.ProgramTypes
module RT = LibExecution.RuntimeTypes
module VT = RT.ValueType
module Dval = LibExecution.Dval
module PT2RT = LibExecution.ProgramTypesToRuntimeTypes
module RT2DT = LibExecution.RuntimeTypesToDarkTypes
module Exe = LibExecution.Execution
Expand Down
37 changes: 13 additions & 24 deletions backend/src/BuiltinCloudExecution/Libs/DB.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ open LibExecution.RuntimeTypes
open LibExecution.Builtin.Shortcuts

module VT = ValueType
module Dval = LibExecution.Dval
module TypeChecker = LibExecution.TypeChecker
module Dval = LibExecution.Dval

module UserDB = LibCloud.UserDB
module Db = LibCloud.Db
Expand Down Expand Up @@ -81,7 +81,7 @@ let fns : List<BuiltInFn> =
uply {
let db = state.program.dbs[dbname]
let! result = UserDB.getOption state db key
return TypeChecker.DvalCreator.option VT.unknownDbTODO result
return Dval.checkedOption VT.unknownDbTODO result
}
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
Expand Down Expand Up @@ -111,10 +111,7 @@ let fns : List<BuiltInFn> =
|> UserDB.getMany state db

if List.length items = List.length keys then
return
items
|> TypeChecker.DvalCreator.list valueType
|> Dval.optionSome optType
return items |> Dval.checkedList valueType |> Dval.optionSome optType
else
return Dval.optionNone optType
}
Expand Down Expand Up @@ -142,7 +139,7 @@ let fns : List<BuiltInFn> =
| DString s -> s
| dv -> Exception.raiseInternal "keys aren't strings" [ "key", dv ])
|> UserDB.getMany state db
return result |> TypeChecker.DvalCreator.list VT.unknownDbTODO
return result |> Dval.checkedList VT.unknownDbTODO
}
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
Expand All @@ -167,7 +164,7 @@ let fns : List<BuiltInFn> =
| DString s -> s
| dv -> Exception.raiseInternal "keys aren't strings" [ "key", dv ])
|> UserDB.getManyWithKeys state db
return TypeChecker.DvalCreator.dict VT.unknownDbTODO result
return Dval.checkedDict VT.unknownDbTODO result
}
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
Expand Down Expand Up @@ -224,10 +221,7 @@ let fns : List<BuiltInFn> =
uply {
let db = state.program.dbs[dbname]
let! results = UserDB.getAll state db
return
results
|> List.map snd
|> TypeChecker.DvalCreator.list VT.unknownDbTODO
return results |> List.map snd |> Dval.checkedList VT.unknownDbTODO
}
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
Expand All @@ -247,7 +241,7 @@ let fns : List<BuiltInFn> =
uply {
let db = state.program.dbs[dbname]
let! result = UserDB.getAll state db
return TypeChecker.DvalCreator.dict VT.unknownDbTODO result
return Dval.checkedDict VT.unknownDbTODO result
}
| _ -> incorrectArgs ())
sqlSpec = NotQueryable
Expand Down Expand Up @@ -322,8 +316,7 @@ let fns : List<BuiltInFn> =
let db = state.program.dbs[dbname]
let! results = UserDB.queryValues state db b
match results with
| Ok results ->
return results |> TypeChecker.DvalCreator.list VT.unknownDbTODO
| Ok results -> return results |> Dval.checkedList VT.unknownDbTODO
| Error rte -> return raiseUntargetedRTE rte
with e ->
return handleUnexpectedExceptionDuringQuery state dbname b e
Expand All @@ -348,8 +341,7 @@ let fns : List<BuiltInFn> =
let db = state.program.dbs[dbname]
let! results = UserDB.query state db b
match results with
| Ok results ->
return TypeChecker.DvalCreator.dict VT.unknownDbTODO results
| Ok results -> return Dval.checkedDict VT.unknownDbTODO results
| Error rte -> return raiseUntargetedRTE rte
with e ->
return handleUnexpectedExceptionDuringQuery state dbname b e
Expand All @@ -376,8 +368,8 @@ let fns : List<BuiltInFn> =
let! results = UserDB.query state db b

match results with
| Ok [ (_, v) ] -> return TypeChecker.DvalCreator.optionSome optType v
| Ok _ -> return TypeChecker.DvalCreator.optionNone optType
| Ok [ (_, v) ] -> return Dval.checkedOptionSome optType v
| Ok _ -> return Dval.checkedOptionNone optType
| Error rte -> return raiseUntargetedRTE rte
with e ->
return handleUnexpectedExceptionDuringQuery state dbname b e
Expand Down Expand Up @@ -405,11 +397,8 @@ let fns : List<BuiltInFn> =

match results with
| Ok [ (key, dv) ] ->
return
TypeChecker.DvalCreator.optionSome
optType
(DTuple(DString key, dv, []))
| Ok _ -> return TypeChecker.DvalCreator.optionNone optType
return Dval.checkedOptionSome optType (DTuple(DString key, dv, []))
| Ok _ -> return Dval.checkedOptionNone optType
| Error rte -> return raiseUntargetedRTE rte
with e ->
return handleUnexpectedExceptionDuringQuery state dbname b e
Expand Down
1 change: 0 additions & 1 deletion backend/src/BuiltinDarkInternal/Libs/Canvases.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ open LibExecution.RuntimeTypes
open LibExecution.Builtin.Shortcuts

module VT = ValueType
module Dval = LibExecution.Dval
module PT = LibExecution.ProgramTypes
module Canvas = LibCloud.Canvas
module Serialize = LibCloud.Serialize
Expand Down
1 change: 0 additions & 1 deletion backend/src/BuiltinDarkInternal/Libs/DBs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ open Prelude
open LibExecution.RuntimeTypes
open LibExecution.Builtin.Shortcuts

module Dval = LibExecution.Dval
module UserDB = LibCloud.UserDB

let modules = [ "DarkInternal"; "Canvas"; "DB" ]
Expand Down
1 change: 0 additions & 1 deletion backend/src/BuiltinDarkInternal/Libs/Documentation.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ open LibExecution.RuntimeTypes
open LibExecution.Builtin.Shortcuts

module VT = ValueType
module Dval = LibExecution.Dval

let modules = [ "DarkInternal"; "Documentation" ]

Expand Down
2 changes: 0 additions & 2 deletions backend/src/BuiltinDarkInternal/Libs/Domains.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ open Prelude
open LibExecution.RuntimeTypes
open LibExecution.Builtin.Shortcuts

module VT = ValueType
module Dval = LibExecution.Dval
module Canvas = LibCloud.Canvas

let modules = [ "DarkInternal"; "Canvas"; "Domain" ]
Expand Down
2 changes: 0 additions & 2 deletions backend/src/BuiltinDarkInternal/Libs/Infra.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ open Prelude
open LibExecution.RuntimeTypes
open LibExecution.Builtin.Shortcuts

module VT = ValueType
module Dval = LibExecution.Dval
module DvalReprDeveloper = LibExecution.DvalReprDeveloper
module Telemetry = LibService.Telemetry

Expand Down
2 changes: 0 additions & 2 deletions backend/src/BuiltinDarkInternal/Libs/Secrets.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ open Prelude
open LibExecution.RuntimeTypes
open LibExecution.Builtin.Shortcuts

module VT = ValueType
module Dval = LibExecution.Dval
module Secret = LibCloud.Secret


Expand Down
1 change: 0 additions & 1 deletion backend/src/BuiltinDarkInternal/Libs/Workers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ open Prelude
open LibExecution.RuntimeTypes
open LibExecution.Builtin.Shortcuts

module Dval = LibExecution.Dval
module DarkDateTime = LibExecution.DarkDateTime
module SchedulingRules = LibCloud.QueueSchedulingRules
module Pusher = LibCloud.Pusher
Expand Down
1 change: 0 additions & 1 deletion backend/src/BuiltinExecution/Libs/Base64.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ open LibExecution.RuntimeTypes
open LibExecution.Builtin.Shortcuts

module VT = ValueType
module Dval = LibExecution.Dval


let types : List<BuiltInType> = []
Expand Down
2 changes: 0 additions & 2 deletions backend/src/BuiltinExecution/Libs/Bytes.fs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ open Prelude
open LibExecution.RuntimeTypes
open LibExecution.Builtin.Shortcuts

module Dval = LibExecution.Dval

let types : List<BuiltInType> = []

let modules = [ "Bytes" ]
Expand Down
3 changes: 0 additions & 3 deletions backend/src/BuiltinExecution/Libs/Char.fs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ open Prelude
open LibExecution.RuntimeTypes
open LibExecution.Builtin.Shortcuts

module VT = ValueType
module Dval = LibExecution.Dval


let types : List<BuiltInType> = []
let constants : List<BuiltInConstant> = []
Expand Down
2 changes: 0 additions & 2 deletions backend/src/BuiltinExecution/Libs/DateTime.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ type Instant = NodaTime.Instant
open Prelude
open LibExecution.RuntimeTypes
open LibExecution.Builtin.Shortcuts
module VT = ValueType
module Dval = LibExecution.Dval
module DarkDateTime = LibExecution.DarkDateTime

let ISO8601Format = "yyyy-MM-ddTHH:mm:ssZ"
Expand Down
20 changes: 9 additions & 11 deletions backend/src/BuiltinExecution/Libs/Dict.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ open Prelude
open LibExecution.RuntimeTypes
open LibExecution.Builtin.Shortcuts
module TypeChecker = LibExecution.TypeChecker
module Dval = LibExecution.Dval

module VT = ValueType
module Dval = LibExecution.Dval
module Interpreter = LibExecution.Interpreter

let varA = TVariable "a"
Expand Down Expand Up @@ -116,7 +116,7 @@ let fns : List<BuiltInFn> =
[ "dval", dv ]

List.fold f Map.empty l
|> TypeChecker.DvalCreator.dictFromMap VT.unknownTODO
|> Dval.checkedDictFromMap VT.unknownTODO
|> Ply
| _ -> incorrectArgs ())
sqlSpec = NotYetImplemented
Expand Down Expand Up @@ -155,10 +155,8 @@ let fns : List<BuiltInFn> =

match result with
| Some entries ->
DDict(dictType, entries)
|> TypeChecker.DvalCreator.optionSome optType
|> Ply
| None -> TypeChecker.DvalCreator.optionNone optType |> Ply
DDict(dictType, entries) |> Dval.checkedOptionSome optType |> Ply
| None -> Dval.checkedOptionNone optType |> Ply
| _ -> incorrectArgs ())
sqlSpec = NotYetImplemented
previewable = Pure
Expand All @@ -175,7 +173,7 @@ let fns : List<BuiltInFn> =
fn =
(function
| _, _, [ DDict(_vtTODO, o); DString s ] ->
Map.find s o |> TypeChecker.DvalCreator.option VT.unknownTODO |> Ply
Map.find s o |> Dval.checkedOption VT.unknownTODO |> Ply
| _ -> incorrectArgs ())
sqlSpec = NotYetImplemented
previewable = Pure
Expand Down Expand Up @@ -227,7 +225,7 @@ let fns : List<BuiltInFn> =
Interpreter.applyFnVal state state.caller b [] args)
mapped

return TypeChecker.DvalCreator.dictFromMap VT.unknownTODO result
return Dval.checkedDictFromMap VT.unknownTODO result
}
| _ -> incorrectArgs ())
sqlSpec = NotYetImplemented
Expand Down Expand Up @@ -301,7 +299,7 @@ let fns : List<BuiltInFn> =
TypeChecker.raiseFnValResultNotExpectedType state.caller v TBool
}
let! result = Ply.Map.filterSequentially f o
return TypeChecker.DvalCreator.dictFromMap VT.unknownTODO result
return Dval.checkedDictFromMap VT.unknownTODO result
}
| _ -> incorrectArgs ())
sqlSpec = NotYetImplemented
Expand Down Expand Up @@ -360,7 +358,7 @@ let fns : List<BuiltInFn> =
}

let! result = Ply.Map.filterMapSequentially f o
return TypeChecker.DvalCreator.dictFromMap VT.unknownTODO result
return Dval.checkedDictFromMap VT.unknownTODO result
}
| _ -> incorrectArgs ())
sqlSpec = NotYetImplemented
Expand Down Expand Up @@ -392,7 +390,7 @@ let fns : List<BuiltInFn> =
(function
| _, _, [ DDict(_vtTODO1, l); DDict(_vtTODO2, r) ] ->
Map.mergeFavoringRight l r
|> TypeChecker.DvalCreator.dictFromMap VT.unknownTODO
|> Dval.checkedDictFromMap VT.unknownTODO
|> Ply
| _ -> incorrectArgs ())
sqlSpec = NotYetImplemented
Expand Down
3 changes: 0 additions & 3 deletions backend/src/BuiltinExecution/Libs/Float.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ open Prelude
open LibExecution.RuntimeTypes
open LibExecution.Builtin.Shortcuts

module VT = ValueType
module Dval = LibExecution.Dval

let types : List<BuiltInType> = []
let constants : List<BuiltInConstant> = []

Expand Down
3 changes: 0 additions & 3 deletions backend/src/BuiltinExecution/Libs/Int.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ open Prelude
open LibExecution.RuntimeTypes
open LibExecution.Builtin.Shortcuts

module VT = ValueType
module Dval = LibExecution.Dval

let types : List<BuiltInType> = []
let constants : List<BuiltInConstant> = []

Expand Down
Loading