喜欢如何更改F#交互式shell的颜色,但这次是Visual Studio 2010(RTM).
我尝试更改"只读区域"背景颜色,重新启动visual studio,背景颜色不是我选择的颜色.
所以我安装了F#并且我正在运行VS 2008.我正在关注微软家伙之前发布的视频教程.有一次,他想把他的输出扔到网格窗口和类型
grid prices;;
这会给我带来错误:
C:\ Documents and Settings\myusername\Local Settings\Temp\stdin(3,1):error FS0039:未定义值或构造函数'grid'
我错过了什么吗?这只是VS 2010的一个功能吗?
谢谢.
使用F#Interactive时,我需要捕获F#函数的输入和输出.当程序在Visual Studio下使用F5或Ctrl-F5运行时,我能够让NLog正常工作.包含输出到日志的语句的相同方法也可以正常工作,并在通过F#Interactive调用时调用; 日志文件中没有任何内容.
我还尝试使用F#Interactive来设置对NLog的引用,当从F#Interactive运行时,在日志中仍然没有任何内容.
#I @"..\packages\NLog.2.0.0.2000\lib\net40" 
#r @"NLog.dll"
我甚至发现这导致我尝试了这些
NLog.Config.SimpleConfigurator.ConfigureForConsoleLogging()
NLog.Config.SimpleConfigurator.ConfigureForFileLogging(<full file name>)
并且仍然没有在日志文件中.
有人知道Nlog是否可以与F#Interactive一起使用?
如果是这样,它是如何完成的?
编辑
当作为独立运行时,我能够让NLog与fsi.exe一起使用.所以现在问题似乎是让NLog找到配置文件,因为NLog无法从Visual Studio的fsi.exe位置找到配置文件.看看在NLog.dll目录中使用NLog.dll.nlog.
我试图找到一个简单的示例或介绍CSV类型提供程序.所以我按照这个链接来帮助我开始.现在我有一个Visual Studio 2012学生版,虽然文档说F#3.0有CSV类型提供程序但我无法找到它.所以我试图为本地CSV文件使用类型提供程序.我看到的是提到的CSV TypeProvider根本不存在.由于给定的示例没有真正编译,我环顾四周并使用类似的东西来加载oData服务:
#r "FSharp.Data.TypeProviders"
///loading a stackoverflow odata type provider
type stackOverflow = Microsoft.FSharp.Data.TypeProviders.ODataService<"http://data.stackexchange.com/stackoverflow/atom">
所以这与上面的示例页面中提到的有点不同.我无法看到csv类型提供程序.我使用Visual Studio IDE列出类型提供程序,并且未列出csv.我尝试使用nuget更新软件包,但这仍然存在.任何人都可以指出如何使用csv类型提供程序的正确文档,以及可以找到一个简单示例的正确更新链接?
在示例中显示更容易.如果我将以下内容发送给F#interactive
type Person = {Name : string; Age : int}
let joe = {Name = "Joe"; Age=30}
输出是:
type Person =
  {Name: string;
   Age: int;}
val joe : Person = {Name = "Joe";
                    Age = 30;}
Fsi非常聪明,可以打印所有属性.
逐行发送以下内容
let l = new List<int>()
l
结果是
val l : List<int>
val it : List<int> = seq []
Fsi看到了这个l实现IEnumerable,并且(正确地)认为这是我期望看到的.但也有其他的属性l,特别是Count和Capacity.(这对于列表来说并不重要,但在我的情况下它适用于复杂类型)
如何使F#交互式打印出对象的属性并忽略它IEnumerable?(就像Person第一个例子中的类型一样)
我注意到如果我用StructLayout.Sequential定义一个结构,就像这样:
open System.Runtime.InteropServices
[<StructLayout(LayoutKind.Sequential, Pack=1)>]
type SomeType =
 val mutable Field1: uint32
 val mutable Field2: uint32
这在实际程序中编译并正常工作,但FSI给出了错误 error FS0193: internal error: Could not load type 'SomeType' from assembly 'FSI-ASSEMBLY, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' because field 'Field1' was not given an explicit offset.
这是FSI的错误或限制吗?有解决方法吗?
我无法弄清楚如何在F#中实现Zip功能.谁能告诉我我做错了什么?这是我输入的内容fsi.exe:
> let rec zip xs ys =
-  match xs with
-   | [] -> []
-   | head :: tail -> (match ys with
-                       | [] -> []
-                       | headY :: tailY -> (head, headY) :: zip tail tailY);;
val zip : xs:'a list -> ys:'b list -> ('a * 'b) list
> zip [1;2;3;4] ["a","b","c","d"];;
val it : (int * (string * string * string * string)) list =
  [(1, ("a", "b", "c", …我正在尝试将一个有区别的联合转换为字符串,但我不明白为什么这个代码不起作用.
type 'a sampleType =
 | A of 'a
 | B of 'a
let sampleTypeToString x =
 match x with
 | A (value) -> string value
 | B (value) -> string value
这是fsharp交互输出
sampleTypeToString A(2);;
 Stopped due to error
 System.Exception: Operation could not be completed due to earlier error
 Successive arguments should be separated by spaces or tupled, and arguments involving function or method applications should be parenthesized at 3,19
 This expression was expected to have type
     'obj'    
 but here …我有以下类型:
type MultiSet<'a when 'a: comparison> = MSet of Map<'a, int>
我现在想要使用签名声明此类型的af map函数:
('a -> 'b) -> Multiset<'a> -> Multiset<'b> when 'a : comparison and 'b : comparison
我试过了 :
let map m ms =
    match ms with
    | MSet s -> MSet ( Map.map (fun key value -> m key) s )
但它有签名:
('a -> int) -> Multiset<'a> -> Multiset<'a> when 'a : comparison
当我想要第一个提到的函数签名时,我的实现有什么问题?
当我尝试通过#r“ FsCheck”打开FsCheck命令打开FsCheck时,在.fsx文件中,出现此错误。
尝试使用谷歌搜索,但找不到任何答案可以解决我的问题。
#r“ FsCheck”-打开FsCheck ;;
->引用了“ / * / FsCheck.dll”(文件可能被F#Interactive进程锁定了)