如何真正“开始”?

时间:2021-06-19 07:30:50

I'm having real trouble trying to get started with FunScript, I really love the idea of F# -> Javascript but constantly frustrated by the amount information/documentation of how to work with such beautiful-looking technologies.

我在尝试开始使用FunScript时遇到了很大的麻烦,我非常喜欢f# -> Javascript的想法,但是对于如何使用如此美观的技术的数量信息/文档,我一直感到沮丧。

Here's the problem:

问题就在这里:

The FunScript Project (No Hosting) template cannot be installed because: "You need Nuget Installed", says VS when I try to download it. // Dah, I do have Nuget and just updated it to latest release. I'm using VS2013 Ultimate.

FunScript项目(没有托管)模板无法安装,因为“您需要安装Nuget”,在我尝试下载它的时候说。// Dah,我有Nuget,刚刚更新到最新版本。我用VS2013终极。

I did the following:

我做了以下几点:

I created a new FSharp Library Project and then I ran the Package Maneger command for getting the needed FunScript Libs:

我创建了一个新的FSharp库项目,然后我运行Package Maneger命令来获得所需的FunScript Libs:

PM> Install-Package FunScript

that worked nice but then . . . When I look at a FunScript example I see the open FunScript.TypeScript in the program which currently does not exist when I type that as it says TypeScript is not defines, and looking at the examples FunScript.TypeScript gives the ability to use jQuery and interact with the DOM. so without it i can't do anything here

这样做很好,但是……当我查看一个FunScript示例时,我看到了open FunScript。当我键入该程序时,该程序中的TypeScript并不存在,因为它说TypeScript没有定义,并且查看示例脚本。TypeScript提供了使用jQuery和与DOM交互的能力。没有它,我什么都做不了。

I did notice the 3rd-party libs on Nuget for FunScript, the:

我确实注意到,在Nuget上的第三方libs是FunScript的:

FuncScript.TypeScript.Bindings.(lib|jquery)

but i can't reference those in an "open [namespace]" statement.

但我不能在“open [namespace]”语句中引用它们。

and at last, there must be a "do Runtime components ..." something at the end of the program. this also is 'not defined'

最后,必须有一个“做运行时组件…”在程序的最后。这也是没有定义的

Do you guys have a complete FunScript example that I can start with? (I have already searched the web alot, the programs i saw didn't work with me)

你们有一个完整的FunScript例子吗?(我已经搜索了web alot,我看到的程序对我不起作用)

3 个解决方案

#1


14  

Sorry, the project is still a bit thin on documentation. We will try to improve this soon.

不好意思,这个项目在文档方面还是有点少。我们将尽快改善这一状况。

I have now updated the FunScript Visual Studio Project Template to remove the NuGet Package Manager dependency. From v1.1.0.15 It should work on Visual Studio 2013. Note: you may need to build twice to restore the NuGet packages correctly.

现在,我已经更新了FunScript Visual Studio项目模板,以删除NuGet包管理器依赖项。从v1.1.0.15开始,它应该在Visual Studio 2013中工作。注意:您可能需要构建两次才能正确地恢复NuGet包。

You only get the basic F# to JS compiler (and some FSharp.Data type provider mappings) in the main NuGet package. If you want to access JavaScript through TypeScript bindings you must add references to those "Bindings" packages you mentioned.

您只获得了基本的f#到JS编译器(还有一些FSharp)。数据类型提供者映射)在主NuGet包中。如果您希望通过TypeScript绑定访问JavaScript,您必须添加您提到的那些“绑定”包的引用。

The names of these packages don't actually reflect any namespace within the assemblies. Currently, they import types into the global namespace (i.e., they should just become available in intellisense without opening any namespaces). Unless the TypeScript contains modules, in which case the functions and types are mapped to the corresponding .NET namespaces.

这些包的名称实际上并没有反映程序集内的任何名称空间。目前,它们将类型导入到全局名称空间中(即:,它们应该可以在智能感知中使用,而不需要打开任何名称空间。除非TypeScript包含模块,在这种情况下,函数和类型映射到相应的。net名称空间。

E.g., Globals.alert(message) should type-check after you have added the FunScript.TypeScript.Binding.lib NuGet package.

在您添加了FunScript.TypeScript.Binding之后,应该对“Globals.alert”(消息)进行类型检查。*NuGet包。

Please note, we may move these definitions all up into the FunScript.TypeScript namespace in future to avoid polluting the global namespace.

请注意,我们可以将这些定义全部移到FunScript中。未来的TypeScript命名空间,以避免污染全局名称空间。

The do Runtime.Run(components) call in the examples is actually just a helper method. We should probably remove this from the examples, as it confuses a lot of people. The only method call you really need is Compiler.Compile(<@ main() @>, noReturn = true), which compiles the quotation and returns a string of JavaScript. It is then up to the user what they do with this JavaScript (e.g., put it in a hosted page).

实例中的run(组件)调用实际上只是一个辅助方法。我们应该从例子中去掉这个,因为它让很多人困惑。唯一需要的方法是编译器。编译(<@ main() @>, noReturn = true),它编译引用并返回一串JavaScript。然后是用户对该JavaScript的处理(例如,将其放入托管页面)。

I'll be adding more documentation around using FunScript when I release another project called HashBang, which makes use of FunScript to build crawlable-dynamic-websites. This will include step-by-step tutorials for building and deploying with HashBang/FunScript.

当我发布另一个名为HashBang的项目时,我将添加更多关于使用FunScript的文档,该项目使用了FunScript来构建小爬虫动态网站。这将包括用于构建和部署HashBang/FunScript的逐步教程。

#2


4  

I had a smooth entry ...

我顺利地进入了……

Used MS Visual Studio 2013 (professional), with the vanilla "FunScript - Not Hosted" project template (by Zach Bary), which can be found through the online project search.

使用MS Visual Studio 2013(专业版),使用香草“FunScript - Not托管”项目模板(通过Zach Bary),可以通过在线项目搜索找到。

Then add relevant FunScript binding packages (through NuGet). I added for some of my solutions: FunScript.TypeScript.Binding.jquerymobile and FunScript.TypeScript.Binding.phonegap

然后添加相关的FunScript绑定包(通过NuGet)。我添加了一些我的解决方案:FunScript.TypeScript.Binding。jquerymobile和FunScript.TypeScript.Binding.phonegap

You can see several of my examples on GiHub (https://github.com/ZachBray/FunScript/tree/master/src/samples/EasyGettingStarted). All you need to do is replace the Program.fs from the default project (FunScript - Not Hosted). And add the rest of the files. I am using as a base some of Zach Bray code. See the README file on the link above.

您可以在GiHub上看到我的几个示例(https://github.com/ZachBray/FunScript/tree/master/src/samples/EasyGettingStarted)。您所需要做的就是替换程序。来自默认项目的fs (FunScript -不托管)。然后添加其余的文件。我用的是Zach Bray代码的基础。请参阅上面链接中的README文件。

Should be a 5-10 minutes experience for you if you have MS VS 2013 installed. I am in the process of submitting more examples. I recommend Funscript.

如果你已经安装了MS VS 2013,应该是5-10分钟的经验。我正在提交更多的例子。我建议Funscript。

#3


0  

As per Zach's advice above, I created a working (at least time of writing) example project for OSX and Xamarin Studio:

根据Zach的建议,我为OSX和Xamarin工作室创建了一个工作(至少是写作的时间)示例项目:

https://github.com/mfrawley/Funny

https://github.com/mfrawley/Funny

I found the install process absolutely unintuitive but now that it's working and seeing the plethora of NuGet packages available, I'm getting pretty excited to see how this thing develops.

我发现安装过程非常不直观,但是现在它正在工作,看到大量的NuGet包可用,我非常兴奋地看到它的发展。

#1


14  

Sorry, the project is still a bit thin on documentation. We will try to improve this soon.

不好意思,这个项目在文档方面还是有点少。我们将尽快改善这一状况。

I have now updated the FunScript Visual Studio Project Template to remove the NuGet Package Manager dependency. From v1.1.0.15 It should work on Visual Studio 2013. Note: you may need to build twice to restore the NuGet packages correctly.

现在,我已经更新了FunScript Visual Studio项目模板,以删除NuGet包管理器依赖项。从v1.1.0.15开始,它应该在Visual Studio 2013中工作。注意:您可能需要构建两次才能正确地恢复NuGet包。

You only get the basic F# to JS compiler (and some FSharp.Data type provider mappings) in the main NuGet package. If you want to access JavaScript through TypeScript bindings you must add references to those "Bindings" packages you mentioned.

您只获得了基本的f#到JS编译器(还有一些FSharp)。数据类型提供者映射)在主NuGet包中。如果您希望通过TypeScript绑定访问JavaScript,您必须添加您提到的那些“绑定”包的引用。

The names of these packages don't actually reflect any namespace within the assemblies. Currently, they import types into the global namespace (i.e., they should just become available in intellisense without opening any namespaces). Unless the TypeScript contains modules, in which case the functions and types are mapped to the corresponding .NET namespaces.

这些包的名称实际上并没有反映程序集内的任何名称空间。目前,它们将类型导入到全局名称空间中(即:,它们应该可以在智能感知中使用,而不需要打开任何名称空间。除非TypeScript包含模块,在这种情况下,函数和类型映射到相应的。net名称空间。

E.g., Globals.alert(message) should type-check after you have added the FunScript.TypeScript.Binding.lib NuGet package.

在您添加了FunScript.TypeScript.Binding之后,应该对“Globals.alert”(消息)进行类型检查。*NuGet包。

Please note, we may move these definitions all up into the FunScript.TypeScript namespace in future to avoid polluting the global namespace.

请注意,我们可以将这些定义全部移到FunScript中。未来的TypeScript命名空间,以避免污染全局名称空间。

The do Runtime.Run(components) call in the examples is actually just a helper method. We should probably remove this from the examples, as it confuses a lot of people. The only method call you really need is Compiler.Compile(<@ main() @>, noReturn = true), which compiles the quotation and returns a string of JavaScript. It is then up to the user what they do with this JavaScript (e.g., put it in a hosted page).

实例中的run(组件)调用实际上只是一个辅助方法。我们应该从例子中去掉这个,因为它让很多人困惑。唯一需要的方法是编译器。编译(<@ main() @>, noReturn = true),它编译引用并返回一串JavaScript。然后是用户对该JavaScript的处理(例如,将其放入托管页面)。

I'll be adding more documentation around using FunScript when I release another project called HashBang, which makes use of FunScript to build crawlable-dynamic-websites. This will include step-by-step tutorials for building and deploying with HashBang/FunScript.

当我发布另一个名为HashBang的项目时,我将添加更多关于使用FunScript的文档,该项目使用了FunScript来构建小爬虫动态网站。这将包括用于构建和部署HashBang/FunScript的逐步教程。

#2


4  

I had a smooth entry ...

我顺利地进入了……

Used MS Visual Studio 2013 (professional), with the vanilla "FunScript - Not Hosted" project template (by Zach Bary), which can be found through the online project search.

使用MS Visual Studio 2013(专业版),使用香草“FunScript - Not托管”项目模板(通过Zach Bary),可以通过在线项目搜索找到。

Then add relevant FunScript binding packages (through NuGet). I added for some of my solutions: FunScript.TypeScript.Binding.jquerymobile and FunScript.TypeScript.Binding.phonegap

然后添加相关的FunScript绑定包(通过NuGet)。我添加了一些我的解决方案:FunScript.TypeScript.Binding。jquerymobile和FunScript.TypeScript.Binding.phonegap

You can see several of my examples on GiHub (https://github.com/ZachBray/FunScript/tree/master/src/samples/EasyGettingStarted). All you need to do is replace the Program.fs from the default project (FunScript - Not Hosted). And add the rest of the files. I am using as a base some of Zach Bray code. See the README file on the link above.

您可以在GiHub上看到我的几个示例(https://github.com/ZachBray/FunScript/tree/master/src/samples/EasyGettingStarted)。您所需要做的就是替换程序。来自默认项目的fs (FunScript -不托管)。然后添加其余的文件。我用的是Zach Bray代码的基础。请参阅上面链接中的README文件。

Should be a 5-10 minutes experience for you if you have MS VS 2013 installed. I am in the process of submitting more examples. I recommend Funscript.

如果你已经安装了MS VS 2013,应该是5-10分钟的经验。我正在提交更多的例子。我建议Funscript。

#3


0  

As per Zach's advice above, I created a working (at least time of writing) example project for OSX and Xamarin Studio:

根据Zach的建议,我为OSX和Xamarin工作室创建了一个工作(至少是写作的时间)示例项目:

https://github.com/mfrawley/Funny

https://github.com/mfrawley/Funny

I found the install process absolutely unintuitive but now that it's working and seeing the plethora of NuGet packages available, I'm getting pretty excited to see how this thing develops.

我发现安装过程非常不直观,但是现在它正在工作,看到大量的NuGet包可用,我非常兴奋地看到它的发展。