{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedLabels #-}
{-# LANGUAGE OverloadedStrings #-}
module Ide.Plugin.Eval.Config
( properties
, getEvalConfig
, EvalConfig(..)
) where
import Ide.Plugin.Config (Config)
import Ide.Plugin.Properties
import Ide.PluginUtils (usePropertyLsp)
import Ide.Types (PluginId)
import Language.LSP.Server (MonadLsp)
data EvalConfig = EvalConfig
{ EvalConfig -> Bool
eval_cfg_diff :: Bool
, EvalConfig -> Bool
eval_cfg_exception :: Bool
}
deriving (EvalConfig -> EvalConfig -> Bool
(EvalConfig -> EvalConfig -> Bool)
-> (EvalConfig -> EvalConfig -> Bool) -> Eq EvalConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EvalConfig -> EvalConfig -> Bool
$c/= :: EvalConfig -> EvalConfig -> Bool
== :: EvalConfig -> EvalConfig -> Bool
$c== :: EvalConfig -> EvalConfig -> Bool
Eq, Eq EvalConfig
Eq EvalConfig
-> (EvalConfig -> EvalConfig -> Ordering)
-> (EvalConfig -> EvalConfig -> Bool)
-> (EvalConfig -> EvalConfig -> Bool)
-> (EvalConfig -> EvalConfig -> Bool)
-> (EvalConfig -> EvalConfig -> Bool)
-> (EvalConfig -> EvalConfig -> EvalConfig)
-> (EvalConfig -> EvalConfig -> EvalConfig)
-> Ord EvalConfig
EvalConfig -> EvalConfig -> Bool
EvalConfig -> EvalConfig -> Ordering
EvalConfig -> EvalConfig -> EvalConfig
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: EvalConfig -> EvalConfig -> EvalConfig
$cmin :: EvalConfig -> EvalConfig -> EvalConfig
max :: EvalConfig -> EvalConfig -> EvalConfig
$cmax :: EvalConfig -> EvalConfig -> EvalConfig
>= :: EvalConfig -> EvalConfig -> Bool
$c>= :: EvalConfig -> EvalConfig -> Bool
> :: EvalConfig -> EvalConfig -> Bool
$c> :: EvalConfig -> EvalConfig -> Bool
<= :: EvalConfig -> EvalConfig -> Bool
$c<= :: EvalConfig -> EvalConfig -> Bool
< :: EvalConfig -> EvalConfig -> Bool
$c< :: EvalConfig -> EvalConfig -> Bool
compare :: EvalConfig -> EvalConfig -> Ordering
$ccompare :: EvalConfig -> EvalConfig -> Ordering
$cp1Ord :: Eq EvalConfig
Ord, Int -> EvalConfig -> ShowS
[EvalConfig] -> ShowS
EvalConfig -> String
(Int -> EvalConfig -> ShowS)
-> (EvalConfig -> String)
-> ([EvalConfig] -> ShowS)
-> Show EvalConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EvalConfig] -> ShowS
$cshowList :: [EvalConfig] -> ShowS
show :: EvalConfig -> String
$cshow :: EvalConfig -> String
showsPrec :: Int -> EvalConfig -> ShowS
$cshowsPrec :: Int -> EvalConfig -> ShowS
Show)
properties :: Properties
'[ 'PropertyKey "exception" 'TBoolean
, 'PropertyKey "diff" 'TBoolean
]
properties :: Properties
'[ 'PropertyKey "exception" 'TBoolean,
'PropertyKey "diff" 'TBoolean]
properties = Properties '[]
emptyProperties
Properties '[]
-> (Properties '[] -> Properties '[ 'PropertyKey "diff" 'TBoolean])
-> Properties '[ 'PropertyKey "diff" 'TBoolean]
forall a b. a -> (a -> b) -> b
& KeyNameProxy "diff"
-> Text
-> Bool
-> Properties '[]
-> Properties '[ 'PropertyKey "diff" 'TBoolean]
forall (s :: Symbol) (r :: [PropertyKey]).
(KnownSymbol s, NotElem s r) =>
KeyNameProxy s
-> Text
-> Bool
-> Properties r
-> Properties ('PropertyKey s 'TBoolean : r)
defineBooleanProperty IsLabel "diff" (KeyNameProxy "diff")
KeyNameProxy "diff"
#diff
Text
"Enable the diff output (WAS/NOW) of eval lenses" Bool
True
Properties '[ 'PropertyKey "diff" 'TBoolean]
-> (Properties '[ 'PropertyKey "diff" 'TBoolean]
-> Properties
'[ 'PropertyKey "exception" 'TBoolean,
'PropertyKey "diff" 'TBoolean])
-> Properties
'[ 'PropertyKey "exception" 'TBoolean,
'PropertyKey "diff" 'TBoolean]
forall a b. a -> (a -> b) -> b
& KeyNameProxy "exception"
-> Text
-> Bool
-> Properties '[ 'PropertyKey "diff" 'TBoolean]
-> Properties
'[ 'PropertyKey "exception" 'TBoolean,
'PropertyKey "diff" 'TBoolean]
forall (s :: Symbol) (r :: [PropertyKey]).
(KnownSymbol s, NotElem s r) =>
KeyNameProxy s
-> Text
-> Bool
-> Properties r
-> Properties ('PropertyKey s 'TBoolean : r)
defineBooleanProperty IsLabel "exception" (KeyNameProxy "exception")
KeyNameProxy "exception"
#exception
Text
"Enable marking exceptions with `*** Exception:` similarly to doctest and GHCi." Bool
False
getEvalConfig :: (MonadLsp Config m) => PluginId -> m EvalConfig
getEvalConfig :: PluginId -> m EvalConfig
getEvalConfig PluginId
plId =
Bool -> Bool -> EvalConfig
EvalConfig
(Bool -> Bool -> EvalConfig) -> m Bool -> m (Bool -> EvalConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> KeyNameProxy "diff"
-> PluginId
-> Properties
'[ 'PropertyKey "exception" 'TBoolean,
'PropertyKey "diff" 'TBoolean]
-> m (ToHsType 'TBoolean)
forall (s :: Symbol) (k :: PropertyKey) (t :: PropertyType)
(r :: [PropertyKey]) (m :: * -> *).
(HasProperty s k t r, MonadLsp Config m) =>
KeyNameProxy s -> PluginId -> Properties r -> m (ToHsType t)
usePropertyLsp IsLabel "diff" (KeyNameProxy "diff")
KeyNameProxy "diff"
#diff PluginId
plId Properties
'[ 'PropertyKey "exception" 'TBoolean,
'PropertyKey "diff" 'TBoolean]
properties
m (Bool -> EvalConfig) -> m Bool -> m EvalConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> KeyNameProxy "exception"
-> PluginId
-> Properties
'[ 'PropertyKey "exception" 'TBoolean,
'PropertyKey "diff" 'TBoolean]
-> m (ToHsType 'TBoolean)
forall (s :: Symbol) (k :: PropertyKey) (t :: PropertyType)
(r :: [PropertyKey]) (m :: * -> *).
(HasProperty s k t r, MonadLsp Config m) =>
KeyNameProxy s -> PluginId -> Properties r -> m (ToHsType t)
usePropertyLsp IsLabel "exception" (KeyNameProxy "exception")
KeyNameProxy "exception"
#exception PluginId
plId Properties
'[ 'PropertyKey "exception" 'TBoolean,
'PropertyKey "diff" 'TBoolean]
properties