Подтвердить что ты не робот

Ошибка Haskell "Не видимое поле конструктора"

Я получаю сообщение об ошибке, которое я не совсем понимаю:

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

import qualified SomeModule as M
import qualified AnotherModule as A

main = print $ A.makeSomeType M.Constructor1

SomeModule.hs

module SomeModule (SomeType(..), AnotherType(..)) where

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

AnotherModule.hs

module AnotherModule (makeSomeType) where

import qualified SomeModule as M

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

Ответ 1

something и somethingElse - это в основном функции, определенные в SomeModule. Попробуйте

makeSomeType something = M.SomeType { M.something     = []
                                    , M.somethingElse = [something]
                                    }