Is it possible to split an F# module across files?
According to the book I have it is, but the book is probably outdated (Foundations of F#)
The split() method splits a string into a list. You can specify the separator, default separator is any whitespace. Note: When maxsplit is specified, the list will contain the specified number of elements plus one.
The PySpark SQL provides the split() function to convert delimiter separated String to an Array (StringType to ArrayType) column on DataFrame It can be done by splitting the string column on the delimiter like space, comma, pipe, etc. and converting it into ArrayType.
The split() method splits a string into an array of substrings. The split() method returns the new array. The split() method does not change the original string. If (" ") is used as separator, the string is split between words.
Python String split() Method A string can be split into substrings using the split(param) method. This method is part of the string object. The parameter is optional, but you can split on a specific string or character. Given a sentence, the string can be split into words.
Apparently not:
C:\temp\Tim>type 1.fs 2.fs 1.fs #light module Module let sayHello1 = printfn "Hello, " 2.fs #light module Module let sayHello2 = printfn "world!" C:\temp\Tim>fsc 1.fs 2.fs Microsoft F# Compiler, (c) Microsoft Corporation, All Rights Reserved F# Version 1.9.6.2, compiling for .NET Framework Version v2.0.50727 2.fs(2,1): error FS0191: An implementation of the file or module Module has already been given.
Update: the error has changed in F# 4.0, it is now:
error FS0248: Two modules named 'Module' occur in two parts of this assembly
where Module
is the fully qualified name of your assembly, including the namespace part.
The type extensions are cool, and hopefully they will allow to be cross file, while still being intrinsic. If you do a type extension in the same file, it compiles to one class, and the extension has access to private members and so on. If you do it in another file, it's just an "optional" extension, like C# static extension methods. (Even though the F# specs say differently.)
I'd be surprised if this isn't addressed at some point, if only for designer support. If intrinsic type extensions could be anywhere in the assembly, that'd be pretty slick.
Another option, which might not be what you want, is to create a type and a module, call the module the same name, and then add the ModuleSuffix flag to it:
type Foo() = static member Bar = 1 [<CompilationRepresentationAttribute(CompilationRepresentationFlags.ModuleSuffix)>] module Foo = let Baz = 2 printfn "%d %d" Foo.Bar Foo.Baz
This is used in the F# libraries, so they can have a type List or whatever, along with tons of helper stuff in a module.
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