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
    {Plugin c -> Rules ()
pluginRules          :: Rules ()
    ,Plugin c -> Handlers (ServerM c)
pluginHandlers       :: LSP.Handlers (ServerM c)
    ,Plugin c -> c -> DynFlagsModifications
pluginModifyDynflags :: c -> DynFlagsModifications
    }

instance Default (Plugin c) where
    def :: Plugin c
def = Rules ()
-> Handlers (ServerM c) -> (c -> DynFlagsModifications) -> Plugin c
forall c.
Rules ()
-> Handlers (ServerM c) -> (c -> DynFlagsModifications) -> Plugin c
Plugin Rules ()
forall a. Monoid a => a
mempty Handlers (ServerM c)
forall a. Monoid a => a
mempty c -> DynFlagsModifications
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 = Rules ()
-> Handlers (ServerM c) -> (c -> DynFlagsModifications) -> Plugin c
forall c.
Rules ()
-> Handlers (ServerM c) -> (c -> DynFlagsModifications) -> Plugin c
Plugin (Rules ()
x1Rules () -> Rules () -> Rules ()
forall a. Semigroup a => a -> a -> a
<>Rules ()
x2) (Handlers (ServerM c)
h1 Handlers (ServerM c)
-> Handlers (ServerM c) -> Handlers (ServerM c)
forall a. Semigroup a => a -> a -> a
<> Handlers (ServerM c)
h2) (c -> DynFlagsModifications
d1 (c -> DynFlagsModifications)
-> (c -> DynFlagsModifications) -> c -> DynFlagsModifications
forall a. Semigroup a => a -> a -> a
<> c -> DynFlagsModifications
d2)

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