如何明确导入' fn' test.quickcheck的模式?

发布于 2025-02-08 02:00:38 字数 540 浏览 1 评论 0原文

haskell的 /a>模块导出模式FN,我一直在使用。

当我将其导入时:

import Test.QuickCheck

它可以正常工作。但是,当我将其导入以下内容时:

import Test.QuickCheck (Fn)

我会收到错误:模块'test.quickcheck'不导出'fn'。我还尝试了import test.quickcheck(fun(fn)),但是这样做了类似的错误。

如前所述,毛毯导入有效,但是在这里我的偏爱是使用显式导入,以便我可以轻松地看到每个导入术语来自何处。是否可以明确导入此类“模式”?

Haskell's Test.QuickCheck module exports pattern Fn, which I have been using.

When I import it with:

import Test.QuickCheck

it works fine. However, when I import it with:

import Test.QuickCheck (Fn)

I get an error: Module ‘Test.QuickCheck’ does not export ‘Fn’. I have also tried import Test.QuickCheck (Fun(Fn)), but get a similar error doing that.

As mentioned, the blanket import works, but here my preference is to use explicit imports so that I can easily see where each imported term came from. Is it possible to import such 'patterns' explicitly?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甚是思念 2025-02-15 02:00:38

您不能执行导入test.quickcheck(fun(fn)),因为,尽管fn确实构造了fun值,但实际上不是这种类型的相关构造函数之一。相反,它是独立的模式同义词。因此,您需要相应的扩展名来明确导入它:

{-# LANGUAGE PatternSynonyms #-}
import Test.QuickCheck (pattern Fn)

You can't do import Test.QuickCheck (Fun(Fn)) because, although Fn does construct a Fun value, it is not actually one of the associated constructors of this type. Rather, it is a standalone pattern synonym. As such, you need the corresponding extension to explicitly import it:

{-# LANGUAGE PatternSynonyms #-}
import Test.QuickCheck (pattern Fn)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文