F#文档有没有办法通过类型搜索功能? [英] Does F# documentation have a way to search for functions by their types?

查看:88
本文介绍了F#文档有没有办法通过类型搜索功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我想知道F#是否有一个类型为

的库函数

 ('T  - > bool) - > ; 'T list  - > int 

即,可以计算一个函数返回真值的列表中有多少项。 (或返回返回true的第一个项目的索引)



在MSDN上的文档准备就绪之前,我曾经在MSR站点使用F#的大列表。我可以搜索页面上面的文本,因为列出了类型。但现在,MSDN文档仅列出了各个页面上的类型 - 模块页面是一个描述性的文本。 Google kinda-sorta是有效的,但是对于

  //兼容的接口
('T - > ; bool) - > SEQ< T> - > int
//参数交换
Seq<'T> - > ('T - > bool) - > int
// type-variable names
('a - > bool) - > SEQ<一> - > int
// wrappers
('a - > bool) - > '列表 - >选项<诠释>
// uncurried versions
('T - > bool)*'T list - > int
// .NET通用语法
('T - > bool) - >列表与LT; T> - > int
//方法
列表<'T>成员:('T - > bool) - > int

Haskell有一个独立的程序,称为 Hoogle 。 F#有一个等价的,像Fing还是什么?

解决方案

根据kvb的答案,我创建了一个完整的应用程序。它由github托管在 http://github.com/sandersn/fing



代码仍然很丑,但它适用于简单的情况。我现在取出了kvb最通用的整数( mgu ),因为它增加了很多不明显的结果。像结构约束和大多数一般超类型的花哨的东西也不起作用。



如果您不想构建命令行版本,还有二进制代码从源头。 (它仍然需要安装.NET运行时的现代版本。)最终,我将找到一些ASP.NET托管,学习ASP,并将整个内容包装在一个Web应用程序中,以免根本不需要安装。 (我想如果有需求我可以创建一个客户端的GUI,但是我对这种事情的经验更少)。


Say I want to know if F# has a library function of type

('T -> bool) -> 'T list -> int

ie, something that counts how many items of a list that a function returns true for. (or returns the index of the first item that returns true)

I used to use the big list at the MSR site for F# before the documentation on MSDN was ready. I could just search the page for the above text because the types were listed. But now the MSDN documentation only lists types on the individual pages--the module page is a mush of descriptive text. Google kinda-sorta works, but it can't help with

// compatible interfaces
('T -> bool) -> Seq<'T> -> int
// argument-swaps
Seq<'T> -> ('T -> bool) -> int
// type-variable names
('a -> bool) -> Seq<'a> -> int
// wrappers
('a -> bool) -> 'a list -> option<int>
// uncurried versions
('T -> bool) * 'T list -> int
// .NET generic syntax
('T -> bool) -> List<'T> -> int
// methods
List<'T> member : ('T -> bool) -> int

Haskell has a standalone program for this called Hoogle. Does F# have an equivalent, like Fing or something?

解决方案

Based on kvb's answer, I created a complete application. It's hosted on github at http://github.com/sandersn/fing.

The code is still pretty ugly, but it works for simple cases. I took out kvb's most-general-unifier (mgu) for now because it adds a lot of non-obvious results. Fancy things like structural constraints and most-general-supertype don't work yet either.

There's also binary for a command-line version if you don't want to build from source. (It still requires a modern version of the .NET runtime installed, though.) Eventually I will find some ASP.NET hosting, learn ASP, and wrap the whole thing in a web app so that no installation is needed at all. (I guess if there is demand I could create a client-side GUI, but I have even less experience with that kind of thing.)

这篇关于F#文档有没有办法通过类型搜索功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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