Module and class with same name
f#, f#-3.1
Solution
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 ;)
Problem
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.