Haskell - Export data constructor

前端 未结 1 1485
无人及你
无人及你 2021-01-08 00:17

I have this data on my Module Formula :

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


        
相关标签:
1条回答
  • 2021-01-08 01:08

    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))

    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
    
    0 讨论(0)
提交回复
热议问题