开发者

Haskell "not a visible field of constructor" error

开发者 https://www.devze.com 2023-02-16 02:59 出处:网络
I\'m getting an error I don\'t quite understand: AnotherModule.hs:6:38: `something\' is not a (visible) field of constructor `M.SomeType\'

I'm getting an error I don't quite understand:

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'

Can anyone explain why I'm getting this error and how I might go about fixing it?

Main.hs

import qualified SomeModule as M
import qualified AnotherModu开发者_JAVA技巧le 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]
                                    }


something and somethingElse are basically functions defined in SomeModule. Try

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

精彩评论

暂无评论...
验证码 换一张
取 消