简体   繁体   English

Haskell - 导出数据构造函数

[英]Haskell - Export data constructor

I have this data on my Module Formula :我的模块公式中有这些数据:

data Formula = Formula {
    typeFormula :: String, 
    nbClauses   :: Int,
    nbVars      :: Int,
    clauses     :: Clauses       
}

And I want to export it but I don't know the right syntax :我想导出它,但我不知道正确的语法:

module Formula (
    Formula ( Formula ),
    solve
) where

Someone can tell me the right syntax please ?有人可以告诉我正确的语法吗?

Some of your confusion is coming from having the same module name as the constructor you're trying to export.您的一些困惑来自与您尝试导出的构造函数具有相同的模块名称。

module Formula (
    Formula ( Formula ),
    solve
) where

Should be应该

module Formula (
    Formula (..),
    solve
) where

Or或者

module Formula (
    module Formula ( Formula (..)),
    solve
) where

Your current export statement says, in the Module Forumla, export the Type Formula defined in the Module Formula and the function solve (that is in scope for the module, wherever it is defined))您当前的导出语句说,在模块论坛中,导出模块Formula定义的类型Formula和函数解决(即在模块的范围内,无论定义在哪里))

The (..) syntax means, export all constructors for the preceding type. (..)语法意味着,导出前面类型的所有构造函数。 In your case, it is equivalent to the explicit在你的情况下,它相当于显式

module Formula (
    Formula (typeFormula,nbClauses, nbVars,clauses),
    solve
) where

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

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