简体   繁体   English

如何从 Test.QuickCheck 显式导入“Fn”模式?

[英]How to explicitly import 'Fn' pattern from Test.QuickCheck?

Haskell's Test.QuickCheck module exports pattern Fn , which I have been using. Haskell 的Test.QuickCheck模块导出了我一直在使用的pattern Fn

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' .我收到一个错误: Module 'Test.QuickCheck' does not export 'Fn' I have also tried import Test.QuickCheck (Fun(Fn)) , but get a similar error doing that.我也尝试过import Test.QuickCheck (Fun(Fn)) ,但是这样做会出现类似的错误。

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?是否可以明确导入此类“模式”?

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.您不能import Test.QuickCheck (Fun(Fn)) ,因为尽管Fn确实构造了一个Fun值,但它实际上并不是这种类型的关联构造函数之一。 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)

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM