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

查看:15
本文介绍了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

推荐答案

项目中的文件是什么顺序?Stack.fs 需要在 Program.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天全站免登陆