F#在同一项目的另一个文件中定义/使用类型/模块 [英] F# defining/using a type/module in another file in the same project

查看:49
本文介绍了F#在同一项目的另一个文件中定义/使用类型/模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

希望这会很容易.我有一个带有两个文件(Program.fs,Stack.fs)的F#项目(最新的F#CTP).在Stack.fs中,我有一个简单的命名空间和类型定义

This will hopefully be an easy one. I have an F# project (latest F# CTP) with two files (Program.fs, Stack.fs). In Stack.fs I have a simple namespace and type definition

Stack.fs

namespace Col

type Stack= 
 ...

现在,我通过声明尝试在Program.fs中包含名称空间

Now I try to include the namespace in Program.fs by declaring

open Col

这不起作用,并给我错误未定义名称空间或模块Col".但是它是在同一项目中定义的.我必须错过一些显而易见的东西

This doesn't work and gives me the error "The namespace or module Col is not defined." Yet it's defined within the same project. I've got to be missing something obvious

推荐答案

项目中文件的顺序是什么?为了让Program.fs能够看到"它,Stack.fs需要先于Program.fs.

What order are the files in the project? Stack.fs needs to come before Program.fs for Program.fs to be able to 'see' it.

另请参阅

http://lorgonblog.spaces.live.com/blog/cns!701679AD17B6D310!444.entry

http://lorgonblog.spaces.live.com/blog/cns!701679AD17B6D310!347.entry

这篇关于F#在同一项目的另一个文件中定义/使用类型/模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆