I am trying to implement in my code the excellent advice in the F# coding conventions
page
https://docs.microsoft.com/en-us/dotnet/fsharp/style-guide/conventions.
The section Use classes to contain values that have side effects
is particularly interesting. It says
There are many times when initializing a value can have side effects, such as instantiating a context to a database or other remote resource. It is tempting to initialize such things in a module and use it in subsequent functions.
and provides an example. Then it points out three problems with this practice (I omit those for lack of space, but they can be seen at the linked article) and recommends using a simple class to hold dependencies.
I wonder how should type providers be treated? For example, if I have the following code,
[<Literal>]
let projDataPath = __SOURCE_DIRECTORY__ + @"\data\"
[<Literal>]
let configPath = projDataPath + "config.json"
type Cnfg = JsonProvider<Sample=configPath>
let config = Cnfg.Load(configPath)
using the type provider to initialize a value is subject to the problems associated to value initialization with side effects described in the article?
In other words, should I wrap the type provider inside a class?