0

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?

theduke
  • 3,027
  • 4
  • 29
  • 28

1 Answers1

6

It's ''SearchRequest, not SearchRequest''.

Gurkenglas
  • 2,317
  • 9
  • 17
  • 1
    Haha ouch. Well, that's embarrasing... Thanks for the quick response, I'll accept once the time limit expires. – theduke Dec 10 '17 at 18:28