{-# LANGUAGE FlexibleInstances #-}
module Development.IDE.Plugin.CodeAction.Args
( module Development.IDE.Plugin.CodeAction.Args,
)
where
import Control.Lens (alaf)
import Data.Monoid (Ap (..))
import qualified Data.Text as T
import Development.IDE (Diagnostic,
HieAstResult,
TcModuleResult)
import Development.IDE.GHC.Compat (DynFlags,
ParsedModule,
ParsedSource)
import Development.IDE.Plugin.CodeAction.ExactPrint (Rewrite,
rewriteToEdit)
import Development.IDE.Plugin.TypeLenses (GlobalBindingTypeSigsResult)
import Development.IDE.Spans.LocalBindings (Bindings)
import Development.IDE.Types.Exports (ExportsMap)
import Development.IDE.Types.Options (IdeOptions)
import Language.LSP.Types (CodeActionKind (CodeActionQuickFix),
TextEdit)
import Retrie (Annotated (astA))
import Retrie.ExactPrint (annsA)
type CodeActionTitle = T.Text
type CodeActionPreferred = Bool
type GhcideCodeActions = [(CodeActionTitle, Maybe CodeActionKind, Maybe CodeActionPreferred, [TextEdit])]
class ToTextEdit a where
toTextEdit :: CodeActionArgs -> a -> [TextEdit]
instance ToTextEdit TextEdit where
toTextEdit :: CodeActionArgs -> TextEdit -> [TextEdit]
toTextEdit CodeActionArgs
_ = TextEdit -> [TextEdit]
forall (f :: * -> *) a. Applicative f => a -> f a
pure
instance ToTextEdit Rewrite where
toTextEdit :: CodeActionArgs -> Rewrite -> [TextEdit]
toTextEdit CodeActionArgs {Maybe Text
Maybe ParsedModule
Maybe DynFlags
Maybe (Annotated ParsedSource)
Maybe Bindings
Maybe HieAstResult
Maybe TcModuleResult
Maybe GlobalBindingTypeSigsResult
Diagnostic
ExportsMap
IdeOptions
caaDiagnostics :: CodeActionArgs -> Diagnostic
caaGblSigs :: CodeActionArgs -> Maybe GlobalBindingTypeSigsResult
caaBindings :: CodeActionArgs -> Maybe Bindings
caaHar :: CodeActionArgs -> Maybe HieAstResult
caaTmr :: CodeActionArgs -> Maybe TcModuleResult
caaAnnSource :: CodeActionArgs -> Maybe (Annotated ParsedSource)
caaDf :: CodeActionArgs -> Maybe DynFlags
caaContents :: CodeActionArgs -> Maybe Text
caaParsedModule :: CodeActionArgs -> Maybe ParsedModule
caaIdeOptions :: CodeActionArgs -> IdeOptions
caaExportsMap :: CodeActionArgs -> ExportsMap
caaDiagnostics :: Diagnostic
caaGblSigs :: Maybe GlobalBindingTypeSigsResult
caaBindings :: Maybe Bindings
caaHar :: Maybe HieAstResult
caaTmr :: Maybe TcModuleResult
caaAnnSource :: Maybe (Annotated ParsedSource)
caaDf :: Maybe DynFlags
caaContents :: Maybe Text
caaParsedModule :: Maybe ParsedModule
caaIdeOptions :: IdeOptions
caaExportsMap :: ExportsMap
..} Rewrite
rw
| Just DynFlags
df <- Maybe DynFlags
caaDf,
Just Annotated ParsedSource
ps <- Maybe (Annotated ParsedSource)
caaAnnSource,
Right [TextEdit]
x <- DynFlags -> Anns -> Rewrite -> Either String [TextEdit]
rewriteToEdit DynFlags
df (Annotated ParsedSource -> Anns
forall ast. Annotated ast -> Anns
annsA Annotated ParsedSource
ps) Rewrite
rw =
[TextEdit]
x
| Bool
otherwise = []
instance ToTextEdit a => ToTextEdit [a] where
toTextEdit :: CodeActionArgs -> [a] -> [TextEdit]
toTextEdit CodeActionArgs
caa = (a -> [TextEdit]) -> [a] -> [TextEdit]
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (CodeActionArgs -> a -> [TextEdit]
forall a. ToTextEdit a => CodeActionArgs -> a -> [TextEdit]
toTextEdit CodeActionArgs
caa)
instance ToTextEdit a => ToTextEdit (Maybe a) where
toTextEdit :: CodeActionArgs -> Maybe a -> [TextEdit]
toTextEdit CodeActionArgs
caa = [TextEdit] -> (a -> [TextEdit]) -> Maybe a -> [TextEdit]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (CodeActionArgs -> a -> [TextEdit]
forall a. ToTextEdit a => CodeActionArgs -> a -> [TextEdit]
toTextEdit CodeActionArgs
caa)
instance (ToTextEdit a, ToTextEdit b) => ToTextEdit (Either a b) where
toTextEdit :: CodeActionArgs -> Either a b -> [TextEdit]
toTextEdit CodeActionArgs
caa = (a -> [TextEdit]) -> (b -> [TextEdit]) -> Either a b -> [TextEdit]
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (CodeActionArgs -> a -> [TextEdit]
forall a. ToTextEdit a => CodeActionArgs -> a -> [TextEdit]
toTextEdit CodeActionArgs
caa) (CodeActionArgs -> b -> [TextEdit]
forall a. ToTextEdit a => CodeActionArgs -> a -> [TextEdit]
toTextEdit CodeActionArgs
caa)
data CodeActionArgs = CodeActionArgs
{ CodeActionArgs -> ExportsMap
caaExportsMap :: ExportsMap,
CodeActionArgs -> IdeOptions
caaIdeOptions :: IdeOptions,
CodeActionArgs -> Maybe ParsedModule
caaParsedModule :: Maybe ParsedModule,
CodeActionArgs -> Maybe Text
caaContents :: Maybe T.Text,
CodeActionArgs -> Maybe DynFlags
caaDf :: Maybe DynFlags,
CodeActionArgs -> Maybe (Annotated ParsedSource)
caaAnnSource :: Maybe (Annotated ParsedSource),
CodeActionArgs -> Maybe TcModuleResult
caaTmr :: Maybe TcModuleResult,
CodeActionArgs -> Maybe HieAstResult
caaHar :: Maybe HieAstResult,
CodeActionArgs -> Maybe Bindings
caaBindings :: Maybe Bindings,
CodeActionArgs -> Maybe GlobalBindingTypeSigsResult
caaGblSigs :: Maybe GlobalBindingTypeSigsResult,
CodeActionArgs -> Diagnostic
caaDiagnostics :: Diagnostic
}
rewrite ::
Maybe DynFlags ->
Maybe (Annotated ParsedSource) ->
[(T.Text, [Rewrite])] ->
[(T.Text, [TextEdit])]
rewrite :: Maybe DynFlags
-> Maybe (Annotated ParsedSource)
-> [(Text, [Rewrite])]
-> [(Text, [TextEdit])]
rewrite (Just DynFlags
df) (Just Annotated ParsedSource
ps) [(Text, [Rewrite])]
r
| Right [(Text, [TextEdit])]
edit <-
(((Text, [Rewrite]) -> Either String (Text, [TextEdit]))
-> [(Text, [Rewrite])] -> Either String [(Text, [TextEdit])]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (((Text, [Rewrite]) -> Either String (Text, [TextEdit]))
-> [(Text, [Rewrite])] -> Either String [(Text, [TextEdit])])
-> (([Rewrite] -> Either String [TextEdit])
-> (Text, [Rewrite]) -> Either String (Text, [TextEdit]))
-> ([Rewrite] -> Either String [TextEdit])
-> [(Text, [Rewrite])]
-> Either String [(Text, [TextEdit])]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ([Rewrite] -> Either String [TextEdit])
-> (Text, [Rewrite]) -> Either String (Text, [TextEdit])
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse)
((Unwrapped (Ap (Either String) [TextEdit])
-> Ap (Either String) [TextEdit])
-> ((Rewrite -> Ap (Either String) [TextEdit])
-> [Rewrite] -> Ap (Either String) [TextEdit])
-> (Rewrite -> Unwrapped (Ap (Either String) [TextEdit]))
-> [Rewrite]
-> Unwrapped (Ap (Either String) [TextEdit])
forall (f :: * -> *) (g :: * -> *) s t.
(Functor f, Functor g, Rewrapping s t) =>
(Unwrapped s -> s)
-> (f t -> g s) -> f (Unwrapped t) -> g (Unwrapped s)
alaf Unwrapped (Ap (Either String) [TextEdit])
-> Ap (Either String) [TextEdit]
forall k (f :: k -> *) (a :: k). f a -> Ap f a
Ap (Rewrite -> Ap (Either String) [TextEdit])
-> [Rewrite] -> Ap (Either String) [TextEdit]
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (DynFlags -> Anns -> Rewrite -> Either String [TextEdit]
rewriteToEdit DynFlags
df (Annotated ParsedSource -> Anns
forall ast. Annotated ast -> Anns
annsA Annotated ParsedSource
ps)))
[(Text, [Rewrite])]
r =
[(Text, [TextEdit])]
edit
rewrite Maybe DynFlags
_ Maybe (Annotated ParsedSource)
_ [(Text, [Rewrite])]
_ = []
class ToCodeAction a where
toCodeAction :: CodeActionArgs -> a -> GhcideCodeActions
instance ToCodeAction a => ToCodeAction [a] where
toCodeAction :: CodeActionArgs -> [a] -> GhcideCodeActions
toCodeAction CodeActionArgs
caa = (a -> GhcideCodeActions) -> [a] -> GhcideCodeActions
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (CodeActionArgs -> a -> GhcideCodeActions
forall a.
ToCodeAction a =>
CodeActionArgs -> a -> GhcideCodeActions
toCodeAction CodeActionArgs
caa)
instance ToCodeAction a => ToCodeAction (Maybe a) where
toCodeAction :: CodeActionArgs -> Maybe a -> GhcideCodeActions
toCodeAction CodeActionArgs
caa = GhcideCodeActions
-> (a -> GhcideCodeActions) -> Maybe a -> GhcideCodeActions
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (CodeActionArgs -> a -> GhcideCodeActions
forall a.
ToCodeAction a =>
CodeActionArgs -> a -> GhcideCodeActions
toCodeAction CodeActionArgs
caa)
instance ToTextEdit a => ToCodeAction (CodeActionTitle, a) where
toCodeAction :: CodeActionArgs -> (Text, a) -> GhcideCodeActions
toCodeAction CodeActionArgs
caa (Text
title, a
te) = [(Text
title, CodeActionKind -> Maybe CodeActionKind
forall a. a -> Maybe a
Just CodeActionKind
CodeActionQuickFix, Maybe Bool
forall a. Maybe a
Nothing, CodeActionArgs -> a -> [TextEdit]
forall a. ToTextEdit a => CodeActionArgs -> a -> [TextEdit]
toTextEdit CodeActionArgs
caa a
te)]
instance ToTextEdit a => ToCodeAction (CodeActionTitle, CodeActionKind, a) where
toCodeAction :: CodeActionArgs -> (Text, CodeActionKind, a) -> GhcideCodeActions
toCodeAction CodeActionArgs
caa (Text
title, CodeActionKind
kind, a
te) = [(Text
title, CodeActionKind -> Maybe CodeActionKind
forall a. a -> Maybe a
Just CodeActionKind
kind, Maybe Bool
forall a. Maybe a
Nothing, CodeActionArgs -> a -> [TextEdit]
forall a. ToTextEdit a => CodeActionArgs -> a -> [TextEdit]
toTextEdit CodeActionArgs
caa a
te)]
instance ToTextEdit a => ToCodeAction (CodeActionTitle, CodeActionPreferred, a) where
toCodeAction :: CodeActionArgs -> (Text, Bool, a) -> GhcideCodeActions
toCodeAction CodeActionArgs
caa (Text
title, Bool
isPreferred, a
te) = [(Text
title, CodeActionKind -> Maybe CodeActionKind
forall a. a -> Maybe a
Just CodeActionKind
CodeActionQuickFix, Bool -> Maybe Bool
forall a. a -> Maybe a
Just Bool
isPreferred, CodeActionArgs -> a -> [TextEdit]
forall a. ToTextEdit a => CodeActionArgs -> a -> [TextEdit]
toTextEdit CodeActionArgs
caa a
te)]
instance ToTextEdit a => ToCodeAction (CodeActionTitle, CodeActionKind, CodeActionPreferred, a) where
toCodeAction :: CodeActionArgs
-> (Text, CodeActionKind, Bool, a) -> GhcideCodeActions
toCodeAction CodeActionArgs
caa (Text
title, CodeActionKind
kind, Bool
isPreferred, a
te) = [(Text
title, CodeActionKind -> Maybe CodeActionKind
forall a. a -> Maybe a
Just CodeActionKind
kind, Bool -> Maybe Bool
forall a. a -> Maybe a
Just Bool
isPreferred, CodeActionArgs -> a -> [TextEdit]
forall a. ToTextEdit a => CodeActionArgs -> a -> [TextEdit]
toTextEdit CodeActionArgs
caa a
te)]
instance ToCodeAction r => ToCodeAction (ParsedSource -> r) where
toCodeAction :: CodeActionArgs -> (ParsedSource -> r) -> GhcideCodeActions
toCodeAction caa :: CodeActionArgs
caa@CodeActionArgs {caaAnnSource :: CodeActionArgs -> Maybe (Annotated ParsedSource)
caaAnnSource = Just Annotated ParsedSource
ps} ParsedSource -> r
f = CodeActionArgs -> r -> GhcideCodeActions
forall a.
ToCodeAction a =>
CodeActionArgs -> a -> GhcideCodeActions
toCodeAction CodeActionArgs
caa (r -> GhcideCodeActions) -> r -> GhcideCodeActions
forall a b. (a -> b) -> a -> b
$ ParsedSource -> r
f (ParsedSource -> r) -> ParsedSource -> r
forall a b. (a -> b) -> a -> b
$ Annotated ParsedSource -> ParsedSource
forall ast. Annotated ast -> ast
astA Annotated ParsedSource
ps
toCodeAction CodeActionArgs
_ ParsedSource -> r
_ = []
instance ToCodeAction r => ToCodeAction (ExportsMap -> r) where
toCodeAction :: CodeActionArgs -> (ExportsMap -> r) -> GhcideCodeActions
toCodeAction caa :: CodeActionArgs
caa@CodeActionArgs {caaExportsMap :: CodeActionArgs -> ExportsMap
caaExportsMap = ExportsMap
x} ExportsMap -> r
f =
CodeActionArgs -> r -> GhcideCodeActions
forall a.
ToCodeAction a =>
CodeActionArgs -> a -> GhcideCodeActions
toCodeAction CodeActionArgs
caa (r -> GhcideCodeActions) -> r -> GhcideCodeActions
forall a b. (a -> b) -> a -> b
$ ExportsMap -> r
f ExportsMap
x
instance ToCodeAction r => ToCodeAction (IdeOptions -> r) where
toCodeAction :: CodeActionArgs -> (IdeOptions -> r) -> GhcideCodeActions
toCodeAction caa :: CodeActionArgs
caa@CodeActionArgs {caaIdeOptions :: CodeActionArgs -> IdeOptions
caaIdeOptions = IdeOptions
x} IdeOptions -> r
f =
CodeActionArgs -> r -> GhcideCodeActions
forall a.
ToCodeAction a =>
CodeActionArgs -> a -> GhcideCodeActions
toCodeAction CodeActionArgs
caa (r -> GhcideCodeActions) -> r -> GhcideCodeActions
forall a b. (a -> b) -> a -> b
$ IdeOptions -> r
f IdeOptions
x
instance
ToCodeAction r =>
ToCodeAction (Maybe ParsedModule -> r)
where
toCodeAction :: CodeActionArgs -> (Maybe ParsedModule -> r) -> GhcideCodeActions
toCodeAction caa :: CodeActionArgs
caa@CodeActionArgs {caaParsedModule :: CodeActionArgs -> Maybe ParsedModule
caaParsedModule = Maybe ParsedModule
x} Maybe ParsedModule -> r
f =
CodeActionArgs -> r -> GhcideCodeActions
forall a.
ToCodeAction a =>
CodeActionArgs -> a -> GhcideCodeActions
toCodeAction CodeActionArgs
caa (r -> GhcideCodeActions) -> r -> GhcideCodeActions
forall a b. (a -> b) -> a -> b
$ Maybe ParsedModule -> r
f Maybe ParsedModule
x
instance ToCodeAction r => ToCodeAction (ParsedModule -> r) where
toCodeAction :: CodeActionArgs -> (ParsedModule -> r) -> GhcideCodeActions
toCodeAction caa :: CodeActionArgs
caa@CodeActionArgs {caaParsedModule :: CodeActionArgs -> Maybe ParsedModule
caaParsedModule = Just ParsedModule
x} ParsedModule -> r
f =
CodeActionArgs -> r -> GhcideCodeActions
forall a.
ToCodeAction a =>
CodeActionArgs -> a -> GhcideCodeActions
toCodeAction CodeActionArgs
caa (r -> GhcideCodeActions) -> r -> GhcideCodeActions
forall a b. (a -> b) -> a -> b
$ ParsedModule -> r
f ParsedModule
x
toCodeAction CodeActionArgs
_ ParsedModule -> r
_ = []
instance ToCodeAction r => ToCodeAction (Maybe T.Text -> r) where
toCodeAction :: CodeActionArgs -> (Maybe Text -> r) -> GhcideCodeActions
toCodeAction caa :: CodeActionArgs
caa@CodeActionArgs {caaContents :: CodeActionArgs -> Maybe Text
caaContents = Maybe Text
x} Maybe Text -> r
f =
CodeActionArgs -> r -> GhcideCodeActions
forall a.
ToCodeAction a =>
CodeActionArgs -> a -> GhcideCodeActions
toCodeAction CodeActionArgs
caa (r -> GhcideCodeActions) -> r -> GhcideCodeActions
forall a b. (a -> b) -> a -> b
$ Maybe Text -> r
f Maybe Text
x
instance ToCodeAction r => ToCodeAction (T.Text -> r) where
toCodeAction :: CodeActionArgs -> (Text -> r) -> GhcideCodeActions
toCodeAction caa :: CodeActionArgs
caa@CodeActionArgs {caaContents :: CodeActionArgs -> Maybe Text
caaContents = Just Text
x} Text -> r
f =
CodeActionArgs -> r -> GhcideCodeActions
forall a.
ToCodeAction a =>
CodeActionArgs -> a -> GhcideCodeActions
toCodeAction CodeActionArgs
caa (r -> GhcideCodeActions) -> r -> GhcideCodeActions
forall a b. (a -> b) -> a -> b
$ Text -> r
f Text
x
toCodeAction CodeActionArgs
_ Text -> r
_ = []
instance ToCodeAction r => ToCodeAction (Maybe DynFlags -> r) where
toCodeAction :: CodeActionArgs -> (Maybe DynFlags -> r) -> GhcideCodeActions
toCodeAction caa :: CodeActionArgs
caa@CodeActionArgs {caaDf :: CodeActionArgs -> Maybe DynFlags
caaDf = Maybe DynFlags
x} Maybe DynFlags -> r
f =
CodeActionArgs -> r -> GhcideCodeActions
forall a.
ToCodeAction a =>
CodeActionArgs -> a -> GhcideCodeActions
toCodeAction CodeActionArgs
caa (r -> GhcideCodeActions) -> r -> GhcideCodeActions
forall a b. (a -> b) -> a -> b
$ Maybe DynFlags -> r
f Maybe DynFlags
x
instance ToCodeAction r => ToCodeAction (DynFlags -> r) where
toCodeAction :: CodeActionArgs -> (DynFlags -> r) -> GhcideCodeActions
toCodeAction caa :: CodeActionArgs
caa@CodeActionArgs {caaDf :: CodeActionArgs -> Maybe DynFlags
caaDf = Just DynFlags
x} DynFlags -> r
f =
CodeActionArgs -> r -> GhcideCodeActions
forall a.
ToCodeAction a =>
CodeActionArgs -> a -> GhcideCodeActions
toCodeAction CodeActionArgs
caa (r -> GhcideCodeActions) -> r -> GhcideCodeActions
forall a b. (a -> b) -> a -> b
$ DynFlags -> r
f DynFlags
x
toCodeAction CodeActionArgs
_ DynFlags -> r
_ = []
instance
ToCodeAction r =>
ToCodeAction (Maybe (Annotated ParsedSource) -> r)
where
toCodeAction :: CodeActionArgs
-> (Maybe (Annotated ParsedSource) -> r) -> GhcideCodeActions
toCodeAction caa :: CodeActionArgs
caa@CodeActionArgs {caaAnnSource :: CodeActionArgs -> Maybe (Annotated ParsedSource)
caaAnnSource = Maybe (Annotated ParsedSource)
x} Maybe (Annotated ParsedSource) -> r
f =
CodeActionArgs -> r -> GhcideCodeActions
forall a.
ToCodeAction a =>
CodeActionArgs -> a -> GhcideCodeActions
toCodeAction CodeActionArgs
caa (r -> GhcideCodeActions) -> r -> GhcideCodeActions
forall a b. (a -> b) -> a -> b
$ Maybe (Annotated ParsedSource) -> r
f Maybe (Annotated ParsedSource)
x
instance
ToCodeAction r =>
ToCodeAction (Annotated ParsedSource -> r)
where
toCodeAction :: CodeActionArgs
-> (Annotated ParsedSource -> r) -> GhcideCodeActions
toCodeAction caa :: CodeActionArgs
caa@CodeActionArgs {caaAnnSource :: CodeActionArgs -> Maybe (Annotated ParsedSource)
caaAnnSource = Just Annotated ParsedSource
x} Annotated ParsedSource -> r
f =
CodeActionArgs -> r -> GhcideCodeActions
forall a.
ToCodeAction a =>
CodeActionArgs -> a -> GhcideCodeActions
toCodeAction CodeActionArgs
caa (r -> GhcideCodeActions) -> r -> GhcideCodeActions
forall a b. (a -> b) -> a -> b
$ Annotated ParsedSource -> r
f Annotated ParsedSource
x
toCodeAction CodeActionArgs
_ Annotated ParsedSource -> r
_ = []
instance
ToCodeAction r =>
ToCodeAction (Maybe TcModuleResult -> r)
where
toCodeAction :: CodeActionArgs -> (Maybe TcModuleResult -> r) -> GhcideCodeActions
toCodeAction caa :: CodeActionArgs
caa@CodeActionArgs {caaTmr :: CodeActionArgs -> Maybe TcModuleResult
caaTmr = Maybe TcModuleResult
x} Maybe TcModuleResult -> r
f =
CodeActionArgs -> r -> GhcideCodeActions
forall a.
ToCodeAction a =>
CodeActionArgs -> a -> GhcideCodeActions
toCodeAction CodeActionArgs
caa (r -> GhcideCodeActions) -> r -> GhcideCodeActions
forall a b. (a -> b) -> a -> b
$ Maybe TcModuleResult -> r
f Maybe TcModuleResult
x
instance ToCodeAction r => ToCodeAction (TcModuleResult -> r) where
toCodeAction :: CodeActionArgs -> (TcModuleResult -> r) -> GhcideCodeActions
toCodeAction caa :: CodeActionArgs
caa@CodeActionArgs {caaTmr :: CodeActionArgs -> Maybe TcModuleResult
caaTmr = Just TcModuleResult
x} TcModuleResult -> r
f =
CodeActionArgs -> r -> GhcideCodeActions
forall a.
ToCodeAction a =>
CodeActionArgs -> a -> GhcideCodeActions
toCodeAction CodeActionArgs
caa (r -> GhcideCodeActions) -> r -> GhcideCodeActions
forall a b. (a -> b) -> a -> b
$ TcModuleResult -> r
f TcModuleResult
x
toCodeAction CodeActionArgs
_ TcModuleResult -> r
_ = []
instance
ToCodeAction r =>
ToCodeAction (Maybe HieAstResult -> r)
where
toCodeAction :: CodeActionArgs -> (Maybe HieAstResult -> r) -> GhcideCodeActions
toCodeAction caa :: CodeActionArgs
caa@CodeActionArgs {caaHar :: CodeActionArgs -> Maybe HieAstResult
caaHar = Maybe HieAstResult
x} Maybe HieAstResult -> r
f =
CodeActionArgs -> r -> GhcideCodeActions
forall a.
ToCodeAction a =>
CodeActionArgs -> a -> GhcideCodeActions
toCodeAction CodeActionArgs
caa (r -> GhcideCodeActions) -> r -> GhcideCodeActions
forall a b. (a -> b) -> a -> b
$ Maybe HieAstResult -> r
f Maybe HieAstResult
x
instance ToCodeAction r => ToCodeAction (HieAstResult -> r) where
toCodeAction :: CodeActionArgs -> (HieAstResult -> r) -> GhcideCodeActions
toCodeAction caa :: CodeActionArgs
caa@CodeActionArgs {caaHar :: CodeActionArgs -> Maybe HieAstResult
caaHar = Just HieAstResult
x} HieAstResult -> r
f =
CodeActionArgs -> r -> GhcideCodeActions
forall a.
ToCodeAction a =>
CodeActionArgs -> a -> GhcideCodeActions
toCodeAction CodeActionArgs
caa (r -> GhcideCodeActions) -> r -> GhcideCodeActions
forall a b. (a -> b) -> a -> b
$ HieAstResult -> r
f HieAstResult
x
toCodeAction CodeActionArgs
_ HieAstResult -> r
_ = []
instance ToCodeAction r => ToCodeAction (Maybe Bindings -> r) where
toCodeAction :: CodeActionArgs -> (Maybe Bindings -> r) -> GhcideCodeActions
toCodeAction caa :: CodeActionArgs
caa@CodeActionArgs {caaBindings :: CodeActionArgs -> Maybe Bindings
caaBindings = Maybe Bindings
x} Maybe Bindings -> r
f =
CodeActionArgs -> r -> GhcideCodeActions
forall a.
ToCodeAction a =>
CodeActionArgs -> a -> GhcideCodeActions
toCodeAction CodeActionArgs
caa (r -> GhcideCodeActions) -> r -> GhcideCodeActions
forall a b. (a -> b) -> a -> b
$ Maybe Bindings -> r
f Maybe Bindings
x
instance ToCodeAction r => ToCodeAction (Bindings -> r) where
toCodeAction :: CodeActionArgs -> (Bindings -> r) -> GhcideCodeActions
toCodeAction caa :: CodeActionArgs
caa@CodeActionArgs {caaBindings :: CodeActionArgs -> Maybe Bindings
caaBindings = Just Bindings
x} Bindings -> r
f =
CodeActionArgs -> r -> GhcideCodeActions
forall a.
ToCodeAction a =>
CodeActionArgs -> a -> GhcideCodeActions
toCodeAction CodeActionArgs
caa (r -> GhcideCodeActions) -> r -> GhcideCodeActions
forall a b. (a -> b) -> a -> b
$ Bindings -> r
f Bindings
x
toCodeAction CodeActionArgs
_ Bindings -> r
_ = []
instance
ToCodeAction r =>
ToCodeAction (Maybe GlobalBindingTypeSigsResult -> r)
where
toCodeAction :: CodeActionArgs
-> (Maybe GlobalBindingTypeSigsResult -> r) -> GhcideCodeActions
toCodeAction caa :: CodeActionArgs
caa@CodeActionArgs {caaGblSigs :: CodeActionArgs -> Maybe GlobalBindingTypeSigsResult
caaGblSigs = Maybe GlobalBindingTypeSigsResult
x} Maybe GlobalBindingTypeSigsResult -> r
f =
CodeActionArgs -> r -> GhcideCodeActions
forall a.
ToCodeAction a =>
CodeActionArgs -> a -> GhcideCodeActions
toCodeAction CodeActionArgs
caa (r -> GhcideCodeActions) -> r -> GhcideCodeActions
forall a b. (a -> b) -> a -> b
$ Maybe GlobalBindingTypeSigsResult -> r
f Maybe GlobalBindingTypeSigsResult
x
instance
ToCodeAction r =>
ToCodeAction (GlobalBindingTypeSigsResult -> r)
where
toCodeAction :: CodeActionArgs
-> (GlobalBindingTypeSigsResult -> r) -> GhcideCodeActions
toCodeAction caa :: CodeActionArgs
caa@CodeActionArgs {caaGblSigs :: CodeActionArgs -> Maybe GlobalBindingTypeSigsResult
caaGblSigs = Just GlobalBindingTypeSigsResult
x} GlobalBindingTypeSigsResult -> r
f =
CodeActionArgs -> r -> GhcideCodeActions
forall a.
ToCodeAction a =>
CodeActionArgs -> a -> GhcideCodeActions
toCodeAction CodeActionArgs
caa (r -> GhcideCodeActions) -> r -> GhcideCodeActions
forall a b. (a -> b) -> a -> b
$ GlobalBindingTypeSigsResult -> r
f GlobalBindingTypeSigsResult
x
toCodeAction CodeActionArgs
_ GlobalBindingTypeSigsResult -> r
_ = []
instance ToCodeAction r => ToCodeAction (Diagnostic -> r) where
toCodeAction :: CodeActionArgs -> (Diagnostic -> r) -> GhcideCodeActions
toCodeAction caa :: CodeActionArgs
caa@CodeActionArgs {caaDiagnostics :: CodeActionArgs -> Diagnostic
caaDiagnostics = Diagnostic
x} Diagnostic -> r
f =
CodeActionArgs -> r -> GhcideCodeActions
forall a.
ToCodeAction a =>
CodeActionArgs -> a -> GhcideCodeActions
toCodeAction CodeActionArgs
caa (r -> GhcideCodeActions) -> r -> GhcideCodeActions
forall a b. (a -> b) -> a -> b
$ Diagnostic -> r
f Diagnostic
x