简体   繁体   中英

F# 2.0 namespace warning

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, eg '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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM