Skip to content

Commit 02bdf9d

Browse files
authored
Add Semigroup/Monoid instances for LspT (#408)
* Add `Semigroup`/`Monoid` instances for `LspT` * Derive `Semigroup`/`Monoid` via `Ap` … as suggested by @michaelpj * Enable `DerivingVia` extension
1 parent d3e54db commit 02bdf9d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lsp/src/Language/LSP/Server/Core.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
22
{-# LANGUAGE TypeFamilyDependencies #-}
3+
{-# LANGUAGE DerivingVia #-}
34
{-# LANGUAGE UndecidableInstances #-}
45
{-# LANGUAGE BangPatterns #-}
56
{-# LANGUAGE GADTs #-}
@@ -40,6 +41,7 @@ import qualified Data.List as L
4041
import Data.List.NonEmpty (NonEmpty(..))
4142
import qualified Data.Map.Strict as Map
4243
import Data.Maybe
44+
import Data.Monoid (Ap(..))
4345
import Data.Ord (Down (Down))
4446
import qualified Data.Text as T
4547
import Data.Text ( Text )
@@ -63,6 +65,7 @@ import Control.Monad.Catch (MonadMask, MonadCatch, MonadThrow)
6365

6466
newtype LspT config m a = LspT { unLspT :: ReaderT (LanguageContextEnv config) m a }
6567
deriving (Functor, Applicative, Monad, MonadCatch, MonadIO, MonadMask, MonadThrow, MonadTrans, MonadUnliftIO, MonadFix)
68+
deriving (Semigroup, Monoid) via (Ap (LspT config m) a)
6669

6770
-- for deriving the instance of MonadUnliftIO
6871
type role LspT representational representational nominal

0 commit comments

Comments
 (0)