To mimic your example, this is more or less how it would go:
module Database = type Response = Response of string let connectionString_ = "connectionString not injected" let connectionStringD = Depend.depend0 <@ connectionString_ @> let readDataD = Depend.depend { let! connectionString = connectionStringD return fun (query:string) -> async { return [ Response (connectionString + " : " + query) ] } } module Person = open Database type Person = Person of string let getPersonD = Depend.depend { let! readData = readDataD return fun (personId : string) -> async { let query = sprintf "SELECT person FROM Table WHERE id = %s" personId match! readData query with | [ Response resp ] -> return Some (Person resp) | _-> return None } } module Startup = open Database let getPerson = Person.getPersonD |> Depend.resolver [ Depend.replace0 <@ connectionString_ @> "dbConnection" ] getPerson "111" |> Async.RunSynchronously |> printfn "%A"
which prints: Some (Person "dbConnection : SELECT person FROM Table WHERE id = 111")
Some (Person "dbConnection : SELECT person FROM Table WHERE id = 111")
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
To mimic your example, this is more or less how it would go:
which prints:
Some (Person "dbConnection : SELECT person FROM Table WHERE id = 111")