Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Haskell “哈斯克尔”;不是构造函数的可见字段“;错误_Haskell_Constructor_Algebraic Data Types - Fatal编程技术网

Haskell “哈斯克尔”;不是构造函数的可见字段“;错误

Haskell “哈斯克尔”;不是构造函数的可见字段“;错误,haskell,constructor,algebraic-data-types,Haskell,Constructor,Algebraic Data Types,我犯了一个我不太明白的错误: AnotherModule.hs:6:38: `something' is not a (visible) field of constructor `M.SomeType' AnotherModule.hs:7:38: `somethingElse' is not a (visible) field of constructor `M.SomeType' 有人能解释一下我为什么会出现这个错误,以及我该如何着手修复它吗 Main.hs SomeM

我犯了一个我不太明白的错误:

AnotherModule.hs:6:38:
    `something' is not a (visible) field of constructor `M.SomeType'

AnotherModule.hs:7:38:
    `somethingElse' is not a (visible) field of constructor `M.SomeType'
有人能解释一下我为什么会出现这个错误,以及我该如何着手修复它吗

Main.hs SomeModule.hs AnotherModule.hs
something
somethingElse
基本上是
SomeModule
中定义的函数。试一试

makeSomeType something = M.SomeType { M.something     = []
                                    , M.somethingElse = [something]
                                    }
module SomeModule (SomeType(..), AnotherType(..)) where

data SomeType = SomeType { something     :: [String]
                         , somethingElse :: [AnotherType]
                         } deriving (Show)
data AnotherType = Constructor1
                 | Constructor2
                 deriving (Show)
module AnotherModule (makeSomeType) where

import qualified SomeModule as M

makeSomeType :: M.AnotherType -> M.SomeType
makeSomeType something = M.SomeType { something     = []
                                    , somethingElse = [something]
                                    }
makeSomeType something = M.SomeType { M.something     = []
                                    , M.somethingElse = [something]
                                    }