1+ {-# LANGUAGE DeriveGeneric #-}
2+
13module Language.PureScript.Docs.Types
24 ( module Language.PureScript.Docs.Types
35 , module ReExports
@@ -7,6 +9,8 @@ module Language.PureScript.Docs.Types
79import Protolude hiding (to , from )
810import Prelude (String , unlines , lookup )
911
12+ import GHC.Generics (Generic )
13+ import Control.DeepSeq (NFData )
1014import Control.Arrow ((***) )
1115
1216import Data.Aeson ((.=) )
@@ -55,10 +59,14 @@ data Package a = Package
5559 -- ^ The version of the PureScript compiler which was used to generate
5660 -- this data. We store this in order to reject packages which are too old.
5761 }
58- deriving (Show , Eq , Ord )
62+ deriving (Show , Eq , Ord , Generic )
63+
64+ instance NFData a => NFData (Package a )
5965
6066data NotYetKnown = NotYetKnown
61- deriving (Show , Eq , Ord )
67+ deriving (Show , Eq , Ord , Generic )
68+
69+ instance NFData NotYetKnown
6270
6371type UploadedPackage = Package NotYetKnown
6472type VerifiedPackage = Package GithubUser
@@ -111,7 +119,9 @@ data Module = Module
111119 -- Re-exported values from other modules
112120 , modReExports :: [(InPackage P. ModuleName , [Declaration ])]
113121 }
114- deriving (Show , Eq , Ord )
122+ deriving (Show , Eq , Ord , Generic )
123+
124+ instance NFData Module
115125
116126data Declaration = Declaration
117127 { declTitle :: Text
@@ -120,7 +130,9 @@ data Declaration = Declaration
120130 , declChildren :: [ChildDeclaration ]
121131 , declInfo :: DeclarationInfo
122132 }
123- deriving (Show , Eq , Ord )
133+ deriving (Show , Eq , Ord , Generic )
134+
135+ instance NFData Declaration
124136
125137-- |
126138-- A value of this type contains information that is specific to a particular
@@ -170,7 +182,9 @@ data DeclarationInfo
170182 -- A kind declaration
171183 --
172184 | ExternKindDeclaration
173- deriving (Show , Eq , Ord )
185+ deriving (Show , Eq , Ord , Generic )
186+
187+ instance NFData DeclarationInfo
174188
175189convertFundepsToStrings :: [(Text , Maybe P. Kind )] -> [P. FunctionalDependency ] -> [([Text ], [Text ])]
176190convertFundepsToStrings args fundeps =
@@ -265,7 +279,9 @@ data ChildDeclaration = ChildDeclaration
265279 , cdeclSourceSpan :: Maybe P. SourceSpan
266280 , cdeclInfo :: ChildDeclarationInfo
267281 }
268- deriving (Show , Eq , Ord )
282+ deriving (Show , Eq , Ord , Generic )
283+
284+ instance NFData ChildDeclaration
269285
270286data ChildDeclarationInfo
271287 -- |
@@ -284,7 +300,9 @@ data ChildDeclarationInfo
284300 -- example, `pure` from `Applicative` would be `forall a. a -> f a`.
285301 --
286302 | ChildTypeClassMember P. Type
287- deriving (Show , Eq , Ord )
303+ deriving (Show , Eq , Ord , Generic )
304+
305+ instance NFData ChildDeclarationInfo
288306
289307childDeclInfoToString :: ChildDeclarationInfo -> Text
290308childDeclInfoToString (ChildInstance _ _) = " instance"
@@ -319,11 +337,15 @@ isDataConstructor ChildDeclaration{..} =
319337
320338newtype GithubUser
321339 = GithubUser { runGithubUser :: Text }
322- deriving (Show , Eq , Ord )
340+ deriving (Show , Eq , Ord , Generic )
341+
342+ instance NFData GithubUser
323343
324344newtype GithubRepo
325345 = GithubRepo { runGithubRepo :: Text }
326- deriving (Show , Eq , Ord )
346+ deriving (Show , Eq , Ord , Generic )
347+
348+ instance NFData GithubRepo
327349
328350data PackageError
329351 = CompilerTooOld Version Version
@@ -337,12 +359,16 @@ data PackageError
337359 | InvalidKind Text
338360 | InvalidDataDeclType Text
339361 | InvalidTime
340- deriving (Show , Eq , Ord )
362+ deriving (Show , Eq , Ord , Generic )
363+
364+ instance NFData PackageError
341365
342366data InPackage a
343367 = Local a
344368 | FromDep PackageName a
345- deriving (Show , Eq , Ord )
369+ deriving (Show , Eq , Ord , Generic )
370+
371+ instance NFData a => NFData (InPackage a )
346372
347373instance Functor InPackage where
348374 fmap f (Local x) = Local (f x)
@@ -370,14 +396,18 @@ data LinksContext = LinksContext
370396 , ctxVersion :: Version
371397 , ctxVersionTag :: Text
372398 }
373- deriving (Show , Eq , Ord )
399+ deriving (Show , Eq , Ord , Generic )
400+
401+ instance NFData LinksContext
374402
375403data DocLink = DocLink
376404 { linkLocation :: LinkLocation
377405 , linkTitle :: Text
378406 , linkNamespace :: Namespace
379407 }
380- deriving (Show , Eq , Ord )
408+ deriving (Show , Eq , Ord , Generic )
409+
410+ instance NFData DocLink
381411
382412data LinkLocation
383413 -- | A link to a declaration in the same module.
@@ -397,7 +427,9 @@ data LinkLocation
397427 -- module. In this case we only need to store the module that the builtin
398428 -- comes from (at the time of writing, this will only ever be "Prim").
399429 | BuiltinModule P. ModuleName
400- deriving (Show , Eq , Ord )
430+ deriving (Show , Eq , Ord , Generic )
431+
432+ instance NFData LinkLocation
401433
402434-- | Given a links context, the current module name, the namespace of a thing
403435-- to link to, its title, and its containing module, attempt to create a
0 commit comments