F# 文档是否可以按类型搜索函数? [英] Does F# documentation have a way to search for functions by their types?

查看:19
本文介绍了F# 文档是否可以按类型搜索函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我想知道F#有没有类型的库函数

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

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

即,计算一个函数返回 true 的列表中有多少项的东西.(或返回第一个返回真项的索引)

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)

在 MSDN 上的文档准备好之前,我曾经在 MSR 站点上使用 F# 的大列表.我可以在页面上搜索上述文本,因为列出了类型.但是现在 MSDN 文档只在各个页面上列出类型——模块页面是一堆描述性文本.谷歌有点工作,但它无济于事

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 有一个名为 Hoogle 的独立程序.F# 是否有等价物,例如 Fing 之类的?

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

推荐答案

基于 kvb 的回答,我创建了一个完整的应用程序.它托管在 github 上,地址为 http://github.com/sandersn/fing.

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

代码仍然很丑,但它适用于简单的情况.我暂时拿出了 kvb 最通用的统一器(mgu),因为它增加了很多不明显的结果.结构约束和最通用的超类型等奇特的东西也不起作用.

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.

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

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天全站免登陆