12
12
{-# LANGUAGE MultiParamTypeClasses #-}
13
13
{-# LANGUAGE NamedFieldPuns #-}
14
14
{-# LANGUAGE OverloadedStrings #-}
15
+ {-# LANGUAGE PatternSynonyms #-}
15
16
{-# LANGUAGE PolyKinds #-}
16
17
{-# LANGUAGE RecordWildCards #-}
17
18
{-# LANGUAGE ScopedTypeVariables #-}
20
21
{-# LANGUAGE ViewPatterns #-}
21
22
22
23
module Ide.Types
24
+ ( PluginDescriptor (.. ), defaultPluginDescriptor, defaultCabalPluginDescriptor
25
+ , IdeCommand (.. )
26
+ , IdeMethod (.. )
27
+ , IdeNotification (.. )
28
+ , IdePlugins (IdePlugins , ipMap)
29
+ , DynFlagsModifications (.. )
30
+ , ConfigDescriptor (.. ), defaultConfigDescriptor, configForPlugin, pluginEnabledConfig
31
+ , CustomConfig (.. ), mkCustomConfig
32
+ , FallbackCodeActionParams (.. )
33
+ , FormattingType (.. ), FormattingMethod , FormattingHandler , mkFormattingHandlers
34
+ , HasTracing (.. )
35
+ , PluginCommand (.. ), CommandId (.. ), CommandFunction , mkLspCommand, mkLspCmdId
36
+ , PluginId (.. )
37
+ , PluginHandler (.. ), mkPluginHandler
38
+ , PluginHandlers (.. )
39
+ , PluginMethod (.. )
40
+ , PluginMethodHandler
41
+ , PluginNotificationHandler (.. ), mkPluginNotificationHandler
42
+ , PluginNotificationHandlers (.. )
43
+ , PluginRequestMethod (.. )
44
+ , getProcessID, getPid
45
+ , installSigUsr1Handler
46
+ , responseError
47
+ )
23
48
where
24
49
25
50
#ifdef mingw32_HOST_OS
@@ -36,6 +61,7 @@ import Data.Dependent.Map (DMap)
36
61
import qualified Data.Dependent.Map as DMap
37
62
import qualified Data.DList as DList
38
63
import Data.GADT.Compare
64
+ import Data.List.Extra (nubOrdOn )
39
65
import Data.List.NonEmpty (NonEmpty (.. ), toList )
40
66
import qualified Data.Map as Map
41
67
import Data.Maybe
@@ -76,9 +102,19 @@ import Text.Regex.TDFA.Text ()
76
102
77
103
-- ---------------------------------------------------------------------
78
104
79
- newtype IdePlugins ideState = IdePlugins
80
- { ipMap :: [(PluginId , PluginDescriptor ideState )]}
81
- deriving newtype (Monoid , Semigroup )
105
+ newtype IdePlugins ideState = IdePlugins_
106
+ { ipMap_ :: [(PluginId , PluginDescriptor ideState )]}
107
+ deriving newtype Monoid
108
+
109
+ -- | Smart constructor that deduplicates plugins
110
+ pattern IdePlugins :: [(PluginId , PluginDescriptor ideState )] -> IdePlugins ideState
111
+ pattern IdePlugins {ipMap} <- IdePlugins_ ipMap
112
+ where
113
+ IdePlugins ipMap = IdePlugins_ {ipMap_ = nubOrdOn fst ipMap}
114
+ {-# COMPLETE IdePlugins #-}
115
+
116
+ instance Semigroup (IdePlugins s ) where
117
+ IdePlugins a <> IdePlugins b = IdePlugins (a <> b)
82
118
83
119
-- | Hooks for modifying the 'DynFlags' at different times of the compilation
84
120
-- process. Plugins can install a 'DynFlagsModifications' via
0 commit comments