2015-07-27 2 views
2

Я пытаюсь импортировать модуль с некоторыми типами данных в файл упражнения , как показано ниже: структура дереваНе в области видимости: конструктор типа или класса «ClientR»

--SimpleFunctions.hs 
{-# LANGUAGE ViewPatterns #-} 
{-# LANGUAGE RecordWildCards #-} 

module Chapter2.SimpleFunctions 
    (
    ) where 

data ClientR = GovOrgR { clientRName :: String } 
      | CompanyR { clientRName :: String, 
         companyID :: Integer, 
         person :: PersonR, 
         duty :: String} 
      | IndividualR {person :: PersonR, ads :: Bool } 
      deriving(Show) 

data PersonR = PersonR { firstName :: String, 
         lastName :: String, 
         gender :: Gender } 
         deriving(Show) 

--exercise.hs 
import Chapter2.SimpleFunctions 

filterGovOrgs :: [ClientR] -> [ClientR] 
filterGovOrgs xs = xs 

проект выглядит следующим образом:

. 
├── ProjectApproachBook.cabal 
├── Setup.hs 
├── chapter2 
│   ├── Section2 
│   │   └── Example.hs 
│   └── SimpleFunctions.hs 
├── chapter3 
│   └── exercise.hs 
└── dist 

, когда я загружаю exercise.hs в GHCI Я получаю сообщение об ошибке:

не входят в комплект: Тип CONSTR uctor или класс «» ClientR

Prelude > :l chapter3/exercise.hs 
[1 of 2] Compiling Chapter2.SimpleFunctions (Chapter2/SimpleFunctions.hs, interpreted) 
[2 of 2] Compiling Main    (chapter3/exercise.hs, interpreted) 

chapter3/exercise.hs:53:19: 
    Not in scope: type constructor or class ‘ClientR’ 

chapter3/exercise.hs:53:32: 
    Not in scope: type constructor or class ‘ClientR’ 
Failed, modules loaded: Chapter2.SimpleFunctions. 

ответ

4

Проблема в том, что ClientR не был разоблачен в модуле Chapter2.SimpleFunctions:

module Chapter2.SimpleFunctions 
    (ClientR 
    ) where