Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

F# 2.0 namespace warning

Tags:

namespaces

f#

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?

like image 864
Benjol Avatar asked Feb 12 '10 07:02

Benjol


1 Answers

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.

like image 91
Johan Kullbom Avatar answered Oct 22 '22 22:10

Johan Kullbom