I have this simple code here to define a type and use makeLenses
to generate lenses.
module Api.Jira.Types.Search
(
SearchRequest(..)
) where
import GHC.Generics
import qualified Data.Text as T
import Data.Aeson (FromJSON, ToJSON)
import Control.Lens
import Data.Aeson
import Data.Aeson.Types
data SearchRequest = SearchRequest
{ _jql :: T.Text
, _startAt :: Maybe Int
, _maxResults :: Maybe Int
, _fields :: Maybe [T.Text]
, _expand :: Maybe [T.Text]
, _properties :: Maybe [T.Text]
} deriving (Show, Generic)
instance ToJSON SearchRequest where
toJSON = genericToJSON defaultOptions {
fieldLabelModifier = drop 1 }
instance FromJSON SearchRequest where
parseJSON = genericParseJSON defaultOptions {
fieldLabelModifier = drop 1 }
makeLenses SearchRequest''
This results in the error:
Data constructor not in scope: SearchRequest'' :: template-haskell-2.11.1.0:Language.Haskell.TH.Syntax.Name • Perhaps you meant one of these: ‘SearchRequest’ (line 20), variable ‘searchRequest’ (line 39)
I have found two somewhat related problems on SO, but they are related to declaration order and don't seem to apply here, since all types contained in SearchRequest
are already defined.
Any ideas what is causing this?