module Development.IDE.Plugin ( Plugin(..) ) where

import           Data.Default
import           Development.IDE.Graph

import           Development.IDE.LSP.Server
import           Ide.Types                  (DynFlagsModifications)
import qualified Language.LSP.Server        as LSP

data Plugin c = Plugin
    {forall c. Plugin c -> Rules ()
pluginRules          :: Rules ()
    ,forall c. Plugin c -> Handlers (ServerM c)
pluginHandlers       :: LSP.Handlers (ServerM c)
    ,forall c. Plugin c -> c -> DynFlagsModifications
pluginModifyDynflags :: c -> DynFlagsModifications
    }

instance Default (Plugin c) where
    def :: Plugin c
def = forall c.
Rules ()
-> Handlers (ServerM c) -> (c -> DynFlagsModifications) -> Plugin c
Plugin forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty

instance Semigroup (Plugin c) where
    Plugin Rules ()
x1 Handlers (ServerM c)
h1 c -> DynFlagsModifications
d1 <> :: Plugin c -> Plugin c -> Plugin c
<> Plugin Rules ()
x2 Handlers (ServerM c)
h2 c -> DynFlagsModifications
d2 = forall c.
Rules ()
-> Handlers (ServerM c) -> (c -> DynFlagsModifications) -> Plugin c
Plugin (Rules ()
x1forall a. Semigroup a => a -> a -> a
<>Rules ()
x2) (Handlers (ServerM c)
h1 forall a. Semigroup a => a -> a -> a
<> Handlers (ServerM c)
h2) (c -> DynFlagsModifications
d1 forall a. Semigroup a => a -> a -> a
<> c -> DynFlagsModifications
d2)

instance Monoid (Plugin c) where
    mempty :: Plugin c
mempty = forall a. Default a => a
def