简体   繁体   English

我如何找出类型,数据构造函数或类型类的定义位置?

[英]How can I find out where a type, data constructor or typeclass is defined?

I'm trying to figure out where the LayoutClass type or data constructor is defined for XMonad https://hackage.haskell.org/package/xmonad-0.12/docs/XMonad-Core.html#t:LayoutClass . 我试图弄清楚为XMonad https://hackage.haskell.org/package/xmonad-0.12/docs/XMonad-Core.html#t:LayoutClass定义LayoutClass类型或数据构造函数的位置。

I've also tried using ghci with no success: 我也尝试使用ghci失败:

Prelude> import XMonad.Core
Prelude XMonad.Core> :t LayoutClass

<interactive>:1:1: error:
    Data constructor not in scope: LayoutClass
Prelude XMonad.Core>

LayoutClass is not a data type or a type constructor. LayoutClass不是数据类型或类型构造函数。 It is a typeclass. 它是一个类型类。 You can verify it by clicking the Source button to the right of a row starting with LayoutClass in an Instances table in the documentation. 您可以通过单击文档的Instances表中以LayoutClass开头的行右侧的Source按钮来验证它。 For example, this is the first line of code for row starting with LayoutClass Layout Window 例如,这是从LayoutClass Layout Window开始的行的第一行代码

instance LayoutClass Layout Window where

This means that Layout Window is an instance of the LayoutClass typeclass. 这意味着“ Layout WindowLayoutClass类型类的实例。

在您链接的行的右边有一个“源”链接,在本例中为https://hackage.haskell.org/package/xmonad-0.12/docs/src/XMonad-Core.html#LayoutClass

Hoogle is often used for this purpose: http://hoogle.haskell.org/?hoogle=LayoutClass Hoogle通常用于此目的: http ://hoogle.haskell.org/?hoogle=LayoutClass

But it does not seem to index all available packages on hackage. 但是它似乎并没有索引所有可破解的软件包。

The above typeclass is indexed by the latest (in Alpha for now) Hoogle: http://hoogle.haskell.org/?hoogle=LayoutClass 上面的类型类由最新(现在在Alpha中)Hoogle索引: http ://hoogle.haskell.org/?hoogle=LayoutClass

You can also search the stackage Hoogle: https://www.stackage.org/lts-8.11/hoogle?q=LayoutClass 您还可以搜索堆栈Hoogle: https ://www.stackage.org/lts-8.11/hoogle?q = LayoutClass

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何找出哪些(具体)类型满足一组类型类约束? - How can I find out which (concrete) types satisfy a set of typeclass constraints? 如何找出运算符“+”的类型? - How can I find out the type of operator “+”? 如何使用类型类转换为多态数据类型? - How to use a typeclass into a polymorphic data type? 如何重新包装类型类实例 - How can I rewrap typeclass instances 如何将 TypeApplications 与 typeclass 方法一起使用,为什么 GHCi 会推断出我无法使用的类型? - How do I use TypeApplications with typeclass methods, and why does GHCi infer a type that I can't use? 如何给编译器提示从具有多个类型变量的类型类中选择正确的实例函数的提示? - How can I give the compiler a hint for picking the right instance function from a typeclass with several type variables? 类型构造函数的类型定义的Haskell实例 - Haskell instance of typeclass definition with type constructor 了解数据类型,类型类的签名,并使数据类型成为类型类的实例 - Understanding signature of data type, typeclass, and making a data type an instance of a typeclass 为什么不能在typeclass实例中提供类型? - Why can't I provide a type within a typeclass instance? Haskell:如何将数据类型转换为特定类型类之一? - Haskell : How to cast a data type to one of its specific typeclass?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM