{-# LANGUAGE DeriveAnyClass     #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE GADTs              #-}
{-# LANGUAGE OverloadedLabels   #-}
{-# LANGUAGE TypeFamilies       #-}
module Development.IDE.Plugin.Completions.Types (
  module Development.IDE.Plugin.Completions.Types
) where

import           Control.DeepSeq
import qualified Data.Map                     as Map
import qualified Data.Text                    as T

import           Data.Aeson                   (FromJSON, ToJSON)
import           Data.Hashable                (Hashable)
import           Data.Text                    (Text)
import           Data.Typeable                (Typeable)
import           Development.IDE.GHC.Compat
import           Development.IDE.Graph        (RuleResult)
import           Development.IDE.Spans.Common
import           GHC.Generics                 (Generic)
import           Ide.Plugin.Config            (Config)
import qualified Ide.Plugin.Config            as Config
import           Ide.Plugin.Properties
import           Ide.PluginUtils              (getClientConfig, usePropertyLsp)
import           Ide.Types                    (PluginId)
import           Language.LSP.Server          (MonadLsp)
import           Language.LSP.Types           (CompletionItemKind (..), Uri)

-- | Produce completions info for a file
type instance RuleResult LocalCompletions = CachedCompletions
type instance RuleResult NonLocalCompletions = CachedCompletions

data LocalCompletions = LocalCompletions
    deriving (LocalCompletions -> LocalCompletions -> Bool
(LocalCompletions -> LocalCompletions -> Bool)
-> (LocalCompletions -> LocalCompletions -> Bool)
-> Eq LocalCompletions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: LocalCompletions -> LocalCompletions -> Bool
$c/= :: LocalCompletions -> LocalCompletions -> Bool
== :: LocalCompletions -> LocalCompletions -> Bool
$c== :: LocalCompletions -> LocalCompletions -> Bool
Eq, Int -> LocalCompletions -> ShowS
[LocalCompletions] -> ShowS
LocalCompletions -> String
(Int -> LocalCompletions -> ShowS)
-> (LocalCompletions -> String)
-> ([LocalCompletions] -> ShowS)
-> Show LocalCompletions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [LocalCompletions] -> ShowS
$cshowList :: [LocalCompletions] -> ShowS
show :: LocalCompletions -> String
$cshow :: LocalCompletions -> String
showsPrec :: Int -> LocalCompletions -> ShowS
$cshowsPrec :: Int -> LocalCompletions -> ShowS
Show, Typeable, (forall x. LocalCompletions -> Rep LocalCompletions x)
-> (forall x. Rep LocalCompletions x -> LocalCompletions)
-> Generic LocalCompletions
forall x. Rep LocalCompletions x -> LocalCompletions
forall x. LocalCompletions -> Rep LocalCompletions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep LocalCompletions x -> LocalCompletions
$cfrom :: forall x. LocalCompletions -> Rep LocalCompletions x
Generic)
instance Hashable LocalCompletions
instance NFData   LocalCompletions

data NonLocalCompletions = NonLocalCompletions
    deriving (NonLocalCompletions -> NonLocalCompletions -> Bool
(NonLocalCompletions -> NonLocalCompletions -> Bool)
-> (NonLocalCompletions -> NonLocalCompletions -> Bool)
-> Eq NonLocalCompletions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NonLocalCompletions -> NonLocalCompletions -> Bool
$c/= :: NonLocalCompletions -> NonLocalCompletions -> Bool
== :: NonLocalCompletions -> NonLocalCompletions -> Bool
$c== :: NonLocalCompletions -> NonLocalCompletions -> Bool
Eq, Int -> NonLocalCompletions -> ShowS
[NonLocalCompletions] -> ShowS
NonLocalCompletions -> String
(Int -> NonLocalCompletions -> ShowS)
-> (NonLocalCompletions -> String)
-> ([NonLocalCompletions] -> ShowS)
-> Show NonLocalCompletions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NonLocalCompletions] -> ShowS
$cshowList :: [NonLocalCompletions] -> ShowS
show :: NonLocalCompletions -> String
$cshow :: NonLocalCompletions -> String
showsPrec :: Int -> NonLocalCompletions -> ShowS
$cshowsPrec :: Int -> NonLocalCompletions -> ShowS
Show, Typeable, (forall x. NonLocalCompletions -> Rep NonLocalCompletions x)
-> (forall x. Rep NonLocalCompletions x -> NonLocalCompletions)
-> Generic NonLocalCompletions
forall x. Rep NonLocalCompletions x -> NonLocalCompletions
forall x. NonLocalCompletions -> Rep NonLocalCompletions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep NonLocalCompletions x -> NonLocalCompletions
$cfrom :: forall x. NonLocalCompletions -> Rep NonLocalCompletions x
Generic)
instance Hashable NonLocalCompletions
instance NFData   NonLocalCompletions

-- From haskell-ide-engine/src/Haskell/Ide/Engine/LSP/Completions.hs

data Backtick = Surrounded | LeftSide
  deriving (Backtick -> Backtick -> Bool
(Backtick -> Backtick -> Bool)
-> (Backtick -> Backtick -> Bool) -> Eq Backtick
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Backtick -> Backtick -> Bool
$c/= :: Backtick -> Backtick -> Bool
== :: Backtick -> Backtick -> Bool
$c== :: Backtick -> Backtick -> Bool
Eq, Eq Backtick
Eq Backtick
-> (Backtick -> Backtick -> Ordering)
-> (Backtick -> Backtick -> Bool)
-> (Backtick -> Backtick -> Bool)
-> (Backtick -> Backtick -> Bool)
-> (Backtick -> Backtick -> Bool)
-> (Backtick -> Backtick -> Backtick)
-> (Backtick -> Backtick -> Backtick)
-> Ord Backtick
Backtick -> Backtick -> Bool
Backtick -> Backtick -> Ordering
Backtick -> Backtick -> Backtick
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Backtick -> Backtick -> Backtick
$cmin :: Backtick -> Backtick -> Backtick
max :: Backtick -> Backtick -> Backtick
$cmax :: Backtick -> Backtick -> Backtick
>= :: Backtick -> Backtick -> Bool
$c>= :: Backtick -> Backtick -> Bool
> :: Backtick -> Backtick -> Bool
$c> :: Backtick -> Backtick -> Bool
<= :: Backtick -> Backtick -> Bool
$c<= :: Backtick -> Backtick -> Bool
< :: Backtick -> Backtick -> Bool
$c< :: Backtick -> Backtick -> Bool
compare :: Backtick -> Backtick -> Ordering
$ccompare :: Backtick -> Backtick -> Ordering
$cp1Ord :: Eq Backtick
Ord, Int -> Backtick -> ShowS
[Backtick] -> ShowS
Backtick -> String
(Int -> Backtick -> ShowS)
-> (Backtick -> String) -> ([Backtick] -> ShowS) -> Show Backtick
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Backtick] -> ShowS
$cshowList :: [Backtick] -> ShowS
show :: Backtick -> String
$cshow :: Backtick -> String
showsPrec :: Int -> Backtick -> ShowS
$cshowsPrec :: Int -> Backtick -> ShowS
Show)

extendImportCommandId :: Text
extendImportCommandId :: Text
extendImportCommandId = Text
"extendImport"

properties :: Properties
  '[ 'PropertyKey "autoExtendOn" 'TBoolean,
     'PropertyKey "snippetsOn" 'TBoolean]
properties :: Properties
  '[ 'PropertyKey "autoExtendOn" 'TBoolean,
     'PropertyKey "snippetsOn" 'TBoolean]
properties = Properties '[]
emptyProperties
  Properties '[]
-> (Properties '[]
    -> Properties '[ 'PropertyKey "snippetsOn" 'TBoolean])
-> Properties '[ 'PropertyKey "snippetsOn" 'TBoolean]
forall a b. a -> (a -> b) -> b
& KeyNameProxy "snippetsOn"
-> Text
-> Bool
-> Properties '[]
-> Properties '[ 'PropertyKey "snippetsOn" 'TBoolean]
forall (s :: Symbol) (r :: [PropertyKey]).
(KnownSymbol s, NotElem s r) =>
KeyNameProxy s
-> Text
-> Bool
-> Properties r
-> Properties ('PropertyKey s 'TBoolean : r)
defineBooleanProperty IsLabel "snippetsOn" (KeyNameProxy "snippetsOn")
KeyNameProxy "snippetsOn"
#snippetsOn
    Text
"Inserts snippets when using code completions"
    Bool
True
  Properties '[ 'PropertyKey "snippetsOn" 'TBoolean]
-> (Properties '[ 'PropertyKey "snippetsOn" 'TBoolean]
    -> Properties
         '[ 'PropertyKey "autoExtendOn" 'TBoolean,
            'PropertyKey "snippetsOn" 'TBoolean])
-> Properties
     '[ 'PropertyKey "autoExtendOn" 'TBoolean,
        'PropertyKey "snippetsOn" 'TBoolean]
forall a b. a -> (a -> b) -> b
& KeyNameProxy "autoExtendOn"
-> Text
-> Bool
-> Properties '[ 'PropertyKey "snippetsOn" 'TBoolean]
-> Properties
     '[ 'PropertyKey "autoExtendOn" 'TBoolean,
        'PropertyKey "snippetsOn" 'TBoolean]
forall (s :: Symbol) (r :: [PropertyKey]).
(KnownSymbol s, NotElem s r) =>
KeyNameProxy s
-> Text
-> Bool
-> Properties r
-> Properties ('PropertyKey s 'TBoolean : r)
defineBooleanProperty IsLabel "autoExtendOn" (KeyNameProxy "autoExtendOn")
KeyNameProxy "autoExtendOn"
#autoExtendOn
    Text
"Extends the import list automatically when completing a out-of-scope identifier"
    Bool
True

getCompletionsConfig :: (MonadLsp Config m) => PluginId -> m CompletionsConfig
getCompletionsConfig :: PluginId -> m CompletionsConfig
getCompletionsConfig PluginId
pId =
  Bool -> Bool -> Int -> CompletionsConfig
CompletionsConfig
    (Bool -> Bool -> Int -> CompletionsConfig)
-> m Bool -> m (Bool -> Int -> CompletionsConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> KeyNameProxy "snippetsOn"
-> PluginId
-> Properties
     '[ 'PropertyKey "autoExtendOn" 'TBoolean,
        'PropertyKey "snippetsOn" 'TBoolean]
-> m (ToHsType 'TBoolean)
forall (s :: Symbol) (k :: PropertyKey) (t :: PropertyType)
       (r :: [PropertyKey]) (m :: * -> *).
(HasProperty s k t r, MonadLsp Config m) =>
KeyNameProxy s -> PluginId -> Properties r -> m (ToHsType t)
usePropertyLsp IsLabel "snippetsOn" (KeyNameProxy "snippetsOn")
KeyNameProxy "snippetsOn"
#snippetsOn PluginId
pId Properties
  '[ 'PropertyKey "autoExtendOn" 'TBoolean,
     'PropertyKey "snippetsOn" 'TBoolean]
properties
    m (Bool -> Int -> CompletionsConfig)
-> m Bool -> m (Int -> CompletionsConfig)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> KeyNameProxy "autoExtendOn"
-> PluginId
-> Properties
     '[ 'PropertyKey "autoExtendOn" 'TBoolean,
        'PropertyKey "snippetsOn" 'TBoolean]
-> m (ToHsType 'TBoolean)
forall (s :: Symbol) (k :: PropertyKey) (t :: PropertyType)
       (r :: [PropertyKey]) (m :: * -> *).
(HasProperty s k t r, MonadLsp Config m) =>
KeyNameProxy s -> PluginId -> Properties r -> m (ToHsType t)
usePropertyLsp IsLabel "autoExtendOn" (KeyNameProxy "autoExtendOn")
KeyNameProxy "autoExtendOn"
#autoExtendOn PluginId
pId Properties
  '[ 'PropertyKey "autoExtendOn" 'TBoolean,
     'PropertyKey "snippetsOn" 'TBoolean]
properties
    m (Int -> CompletionsConfig) -> m Int -> m CompletionsConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Config -> Int
Config.maxCompletions (Config -> Int) -> m Config -> m Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> m Config
forall (m :: * -> *). MonadLsp Config m => m Config
getClientConfig)


data CompletionsConfig = CompletionsConfig {
  CompletionsConfig -> Bool
enableSnippets   :: Bool,
  CompletionsConfig -> Bool
enableAutoExtend :: Bool,
  CompletionsConfig -> Int
maxCompletions   :: Int
}

data ExtendImport = ExtendImport
  { ExtendImport -> Uri
doc         :: !Uri,
    ExtendImport -> Text
newThing    :: !T.Text,
    ExtendImport -> Maybe Text
thingParent :: !(Maybe T.Text),
    ExtendImport -> Text
importName  :: !T.Text,
    ExtendImport -> Maybe Text
importQual  :: !(Maybe T.Text)
  }
  deriving (ExtendImport -> ExtendImport -> Bool
(ExtendImport -> ExtendImport -> Bool)
-> (ExtendImport -> ExtendImport -> Bool) -> Eq ExtendImport
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExtendImport -> ExtendImport -> Bool
$c/= :: ExtendImport -> ExtendImport -> Bool
== :: ExtendImport -> ExtendImport -> Bool
$c== :: ExtendImport -> ExtendImport -> Bool
Eq, Int -> ExtendImport -> ShowS
[ExtendImport] -> ShowS
ExtendImport -> String
(Int -> ExtendImport -> ShowS)
-> (ExtendImport -> String)
-> ([ExtendImport] -> ShowS)
-> Show ExtendImport
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExtendImport] -> ShowS
$cshowList :: [ExtendImport] -> ShowS
show :: ExtendImport -> String
$cshow :: ExtendImport -> String
showsPrec :: Int -> ExtendImport -> ShowS
$cshowsPrec :: Int -> ExtendImport -> ShowS
Show, (forall x. ExtendImport -> Rep ExtendImport x)
-> (forall x. Rep ExtendImport x -> ExtendImport)
-> Generic ExtendImport
forall x. Rep ExtendImport x -> ExtendImport
forall x. ExtendImport -> Rep ExtendImport x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExtendImport x -> ExtendImport
$cfrom :: forall x. ExtendImport -> Rep ExtendImport x
Generic)
  deriving anyclass (Value -> Parser [ExtendImport]
Value -> Parser ExtendImport
(Value -> Parser ExtendImport)
-> (Value -> Parser [ExtendImport]) -> FromJSON ExtendImport
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [ExtendImport]
$cparseJSONList :: Value -> Parser [ExtendImport]
parseJSON :: Value -> Parser ExtendImport
$cparseJSON :: Value -> Parser ExtendImport
FromJSON, [ExtendImport] -> Encoding
[ExtendImport] -> Value
ExtendImport -> Encoding
ExtendImport -> Value
(ExtendImport -> Value)
-> (ExtendImport -> Encoding)
-> ([ExtendImport] -> Value)
-> ([ExtendImport] -> Encoding)
-> ToJSON ExtendImport
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [ExtendImport] -> Encoding
$ctoEncodingList :: [ExtendImport] -> Encoding
toJSONList :: [ExtendImport] -> Value
$ctoJSONList :: [ExtendImport] -> Value
toEncoding :: ExtendImport -> Encoding
$ctoEncoding :: ExtendImport -> Encoding
toJSON :: ExtendImport -> Value
$ctoJSON :: ExtendImport -> Value
ToJSON)

data Provenance
    = ImportedFrom Text
    | DefinedIn Text
    | Local SrcSpan
    deriving (Provenance -> Provenance -> Bool
(Provenance -> Provenance -> Bool)
-> (Provenance -> Provenance -> Bool) -> Eq Provenance
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Provenance -> Provenance -> Bool
$c/= :: Provenance -> Provenance -> Bool
== :: Provenance -> Provenance -> Bool
$c== :: Provenance -> Provenance -> Bool
Eq, Eq Provenance
Eq Provenance
-> (Provenance -> Provenance -> Ordering)
-> (Provenance -> Provenance -> Bool)
-> (Provenance -> Provenance -> Bool)
-> (Provenance -> Provenance -> Bool)
-> (Provenance -> Provenance -> Bool)
-> (Provenance -> Provenance -> Provenance)
-> (Provenance -> Provenance -> Provenance)
-> Ord Provenance
Provenance -> Provenance -> Bool
Provenance -> Provenance -> Ordering
Provenance -> Provenance -> Provenance
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: Provenance -> Provenance -> Provenance
$cmin :: Provenance -> Provenance -> Provenance
max :: Provenance -> Provenance -> Provenance
$cmax :: Provenance -> Provenance -> Provenance
>= :: Provenance -> Provenance -> Bool
$c>= :: Provenance -> Provenance -> Bool
> :: Provenance -> Provenance -> Bool
$c> :: Provenance -> Provenance -> Bool
<= :: Provenance -> Provenance -> Bool
$c<= :: Provenance -> Provenance -> Bool
< :: Provenance -> Provenance -> Bool
$c< :: Provenance -> Provenance -> Bool
compare :: Provenance -> Provenance -> Ordering
$ccompare :: Provenance -> Provenance -> Ordering
$cp1Ord :: Eq Provenance
Ord, Int -> Provenance -> ShowS
[Provenance] -> ShowS
Provenance -> String
(Int -> Provenance -> ShowS)
-> (Provenance -> String)
-> ([Provenance] -> ShowS)
-> Show Provenance
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Provenance] -> ShowS
$cshowList :: [Provenance] -> ShowS
show :: Provenance -> String
$cshow :: Provenance -> String
showsPrec :: Int -> Provenance -> ShowS
$cshowsPrec :: Int -> Provenance -> ShowS
Show)

data CompItem = CI
  { CompItem -> CompletionItemKind
compKind            :: CompletionItemKind
  , CompItem -> Text
insertText          :: T.Text         -- ^ Snippet for the completion
  , CompItem -> Provenance
provenance          :: Provenance     -- ^ From where this item is imported from.
  , CompItem -> Maybe Text
typeText            :: Maybe T.Text   -- ^ Available type information.
  , CompItem -> Text
label               :: T.Text         -- ^ Label to display to the user.
  , CompItem -> Maybe Backtick
isInfix             :: Maybe Backtick -- ^ Did the completion happen
                                   -- in the context of an infix notation.
  , CompItem -> SpanDoc
docs                :: SpanDoc        -- ^ Available documentation.
  , CompItem -> Bool
isTypeCompl         :: Bool
  , CompItem -> Maybe ExtendImport
additionalTextEdits :: Maybe ExtendImport
  }
  deriving (CompItem -> CompItem -> Bool
(CompItem -> CompItem -> Bool)
-> (CompItem -> CompItem -> Bool) -> Eq CompItem
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CompItem -> CompItem -> Bool
$c/= :: CompItem -> CompItem -> Bool
== :: CompItem -> CompItem -> Bool
$c== :: CompItem -> CompItem -> Bool
Eq, Int -> CompItem -> ShowS
[CompItem] -> ShowS
CompItem -> String
(Int -> CompItem -> ShowS)
-> (CompItem -> String) -> ([CompItem] -> ShowS) -> Show CompItem
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CompItem] -> ShowS
$cshowList :: [CompItem] -> ShowS
show :: CompItem -> String
$cshow :: CompItem -> String
showsPrec :: Int -> CompItem -> ShowS
$cshowsPrec :: Int -> CompItem -> ShowS
Show)

-- Associates a module's qualifier with its members
newtype QualCompls
  = QualCompls { QualCompls -> Map Text [CompItem]
getQualCompls :: Map.Map T.Text [CompItem] }
  deriving Int -> QualCompls -> ShowS
[QualCompls] -> ShowS
QualCompls -> String
(Int -> QualCompls -> ShowS)
-> (QualCompls -> String)
-> ([QualCompls] -> ShowS)
-> Show QualCompls
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [QualCompls] -> ShowS
$cshowList :: [QualCompls] -> ShowS
show :: QualCompls -> String
$cshow :: QualCompls -> String
showsPrec :: Int -> QualCompls -> ShowS
$cshowsPrec :: Int -> QualCompls -> ShowS
Show
instance Semigroup QualCompls where
  (QualCompls Map Text [CompItem]
a) <> :: QualCompls -> QualCompls -> QualCompls
<> (QualCompls Map Text [CompItem]
b) = Map Text [CompItem] -> QualCompls
QualCompls (Map Text [CompItem] -> QualCompls)
-> Map Text [CompItem] -> QualCompls
forall a b. (a -> b) -> a -> b
$ ([CompItem] -> [CompItem] -> [CompItem])
-> Map Text [CompItem]
-> Map Text [CompItem]
-> Map Text [CompItem]
forall k a. Ord k => (a -> a -> a) -> Map k a -> Map k a -> Map k a
Map.unionWith [CompItem] -> [CompItem] -> [CompItem]
forall a. [a] -> [a] -> [a]
(++) Map Text [CompItem]
a Map Text [CompItem]
b
instance Monoid QualCompls where
  mempty :: QualCompls
mempty = Map Text [CompItem] -> QualCompls
QualCompls Map Text [CompItem]
forall k a. Map k a
Map.empty
  mappend :: QualCompls -> QualCompls -> QualCompls
mappend = QualCompls -> QualCompls -> QualCompls
forall a. Semigroup a => a -> a -> a
(Prelude.<>)

-- | End result of the completions
data CachedCompletions = CC
  { CachedCompletions -> [Text]
allModNamesAsNS   :: [T.Text] -- ^ All module names in scope.
                                -- Prelude is a single module
  , CachedCompletions -> [CompItem]
unqualCompls      :: [CompItem]  -- ^ Unqualified completion items
  , CachedCompletions -> QualCompls
qualCompls        :: QualCompls    -- ^ Completion items associated to
                                -- to a specific module name.
  , CachedCompletions -> [Maybe Text -> CompItem]
anyQualCompls     :: [Maybe T.Text -> CompItem] -- ^ Items associated to any qualifier
  , CachedCompletions -> [Text]
importableModules :: [T.Text] -- ^ All modules that may be imported.
  }

instance Show CachedCompletions where show :: CachedCompletions -> String
show CachedCompletions
_ = String
"<cached completions>"

instance NFData CachedCompletions where
    rnf :: CachedCompletions -> ()
rnf = CachedCompletions -> ()
forall a. a -> ()
rwhnf

instance Monoid CachedCompletions where
    mempty :: CachedCompletions
mempty = [Text]
-> [CompItem]
-> QualCompls
-> [Maybe Text -> CompItem]
-> [Text]
-> CachedCompletions
CC [Text]
forall a. Monoid a => a
mempty [CompItem]
forall a. Monoid a => a
mempty QualCompls
forall a. Monoid a => a
mempty [Maybe Text -> CompItem]
forall a. Monoid a => a
mempty [Text]
forall a. Monoid a => a
mempty

instance Semigroup CachedCompletions where
    CC [Text]
a [CompItem]
b QualCompls
c [Maybe Text -> CompItem]
d [Text]
e <> :: CachedCompletions -> CachedCompletions -> CachedCompletions
<> CC [Text]
a' [CompItem]
b' QualCompls
c' [Maybe Text -> CompItem]
d' [Text]
e' =
        [Text]
-> [CompItem]
-> QualCompls
-> [Maybe Text -> CompItem]
-> [Text]
-> CachedCompletions
CC ([Text]
a[Text] -> [Text] -> [Text]
forall a. Semigroup a => a -> a -> a
<>[Text]
a') ([CompItem]
b[CompItem] -> [CompItem] -> [CompItem]
forall a. Semigroup a => a -> a -> a
<>[CompItem]
b') (QualCompls
cQualCompls -> QualCompls -> QualCompls
forall a. Semigroup a => a -> a -> a
<>QualCompls
c') ([Maybe Text -> CompItem]
d[Maybe Text -> CompItem]
-> [Maybe Text -> CompItem] -> [Maybe Text -> CompItem]
forall a. Semigroup a => a -> a -> a
<>[Maybe Text -> CompItem]
d') ([Text]
e[Text] -> [Text] -> [Text]
forall a. Semigroup a => a -> a -> a
<>[Text]
e')