I just installed the latest version of F#, and opened an old solution to see what it would tell me.
It's a multi-file solution, where the first file includes some 'extension functions' on the List module:
module List =
///Given list of 'rows', returns list of 'columns'
let rec transpose lst =
match lst with
| (_::_)::_ -> List.map List.hd lst :: transpose (List.map List.tl lst)
| _ -> []
The compiler no longer likes this, and says:
Files in libraries or multiple-file applications must begin with a namespace or module declaration, e.g. 'namespace SomeNamespace.SubNamespace' or 'module SomeNamespace.SomeModule'
But if I do this:
module Foo.List =
It says:
A module abbreviation must be a simple name, not a path
What am I missing here? And what is the solution for this 'special' case where I'm extending a module that comes from elsewhere?
Make the namespace explicit:
namespace Microsoft.FSharp.Collections
module List =
///Given list of 'rows', returns list of 'columns'
let rec transpose lst =
match lst with
| (_::_)::_ -> List.map List.head lst :: transpose (List.map List.tail lst)
| _ -> []
Note that List.hd
and List.tl
have been renamed to List.head
and List.tail
.
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