I want to expand one of the existing "core" modules, for example Core.Option:
module Microsoft.FSharp.Core.Option
let filter predicate op =
match op with
| Some(v) -> if predicate(v) then Some(v) else None
| None -> None
(I know about the function bind, but I think that the method filterfor parameters is more convenient in some cases).
But unfortunately, I cannot use the method filterwithout an explicitly open namespace Microsoft.FSharp.Core:
open Microsoft.FSharp.Core
let v1 = Some 42
let v2 = v1 |> Option.filter (fun v -> v > 40)
printfn "v2 is: %A" v2
In most cases, we cannot use functions from the module without opening the corresponding namespace. The F # compiler "automatically opens" some predefined (main) namespace (for example Microsoft.FSharp.Core), this will not lead to scope methods from the "extension modules", and we still have to open the namespace manually.
My question is: are there any workarounds?
"" - ?
module CustomNamespace.Option
let filter predicate op = ...
open CustomNamespace
let v1 = Some 42
let b =
v1 |> Option.filter (fun v -> v > 40)
|> Option.isSome