A little late to the party, but I wanted to add another usage.
I tend to use [<AutoOpen>]
to expose types within a namespace.
// SlimSql\Types.fs
namespace SlimSql
[<AutoOpen>]
module Types =
type SqlOperation =
{
Statement : string
Parameters : SqlParam list
}
Then I can attach functions to the same type name without getting a compiler error that the name is already in use.
// SlimSql\SqlOperation.fs
namespace SlimSql
module SqlOperation =
let merge (operations : SqlOperation list) : SqlOperation =
...
let wrapInTransaction operation =
...
Then everything is nicely packaged up with the same name in consuming code. So when the user is looking for a behavior on SqlOperation data, they can naturally find it by typing SqlOperation.
and Intellisense will show it. Much in the same way that types such as List
are used in practice.
open SlimSql
let operations =
[
sql "INSERT INTO ...." [ p "@Value" 123; ... ]
...
]
let writeOp =
operations
|> SqlOperation.merge
|> SqlOperation.wrapInTransaction
The SlimSql.Types module can also be opened by itself to access only the types for composition with other types.
I much prefer this solution to augmenting types with static members.