This is allowed:
type Test = class end
[<CompilationRepresentation (CompilationRepresentationFlags.ModuleSuffix)>]
module Test = begin end
But this not:
[<CompilationRepresentation (CompilationRepresentationFlags.ModuleSuffix)>]
module Test = begin end
type Test = class end
Why?
In the second case, the error is: Duplicate definition of type or module 'Test'.
I'd love to be able to define some public [<Literal>]
constants that are required for a type and important for users of the type inside a module with the same name.
You can open the type declaration, close it and re open later, something like this:
type Test = class end
[<CompilationRepresentation (CompilationRepresentationFlags.ModuleSuffix)>]
module Test =
[<Literal>]
let myLiteral = "myLiteral"
type Test with
static member test = ()
I use this trick all the time ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With