Reputation: 1179
I've reviewed the other posts on this error, and I don't think I'm making any of those mistakes.
Not in scope: data constructor 'Extraction'.
Configuration.hs:
module Configuration
(Config
, columns
, headers
, types
, totals
, extractions,
Extraction
, xState
, xDivisions
, xOffice
...) where
...
data Extraction = Extraction { xState :: String
, xDivisions :: Maybe [String]
, xOffice :: Maybe String } deriving Show
data Config = Config { columns :: String
, headers :: [String]
, types :: [String]
, totals :: [String]
, extractions :: [Extraction] } deriving Show
...
PIF.hs:
module PIF (...) where
import Configuration
...
data Report = Report { division :: String
, state :: String
, office :: String
, inSection :: Bool
, content :: [String] } deriving Show
...
extract :: Config -> [Report] -> [Report]
extract c = filter f
where f Report { division=d, state=s, office=o, inSection=_, content=_ } =
map or $ map isMatch $ extractions c
where isMatch
| Extraction { xState=xS, xDivisions=Just xD, xOffice=Nothing } = s==xS && (map or $ map (==d) xD)
| Extraction { xState=xS, xDivisions=Nothing, xOffice=Just xO } = s==xS && o==xO
Let me know if you need more information. Thanks.
Here is my corrected extract
:
extract c = filter f
where f Report { division=d, state=s, office=o, inSection=_, content=_ } =
or $ map isMatch $ extractions c
where isMatch x =
case ((xDivisions x), (xOffice x)) of (Nothing, Just y) -> s==(xState x) && o==y
(Just y, Nothing) -> s==(xState x) && (or $ map (==d) y)
Upvotes: 7
Views: 2081
Reputation: 38893
Change the export line Extraction
to Extraction(..)
.
Without that, you're exporting the type but not the data constructor. Since your type and constructor share the same name, this is less than obvious in this case.
Upvotes: 15