tags:

views:

123

answers:

1

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?

+4  A: 

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.

Johan Kullbom
hd -> head and tl -> tail? Don't these people care about code golf? :)
Benjol
:) - Add them back since you are already adding functions to the List module ...
Johan Kullbom
The other half of the answer, which is very confusing, is that if you have no namespace, and just a module, you mustn't put an = after the module declaration. But if you do have a namespace, you need an =
Benjol