module Language.LSP.Protocol.Types.Progress (
  _workDoneProgressBegin,
  _workDoneProgressEnd,
  _workDoneProgressReport,
)
where

import Control.Lens
import Data.Aeson

import Language.LSP.Protocol.Internal.Types.WorkDoneProgressBegin
import Language.LSP.Protocol.Internal.Types.WorkDoneProgressEnd
import Language.LSP.Protocol.Internal.Types.WorkDoneProgressReport

-- From lens-aeson
_JSON :: (ToJSON a, FromJSON a) => Prism' Value a
_JSON :: forall a. (ToJSON a, FromJSON a) => Prism' Value a
_JSON = (a -> Value)
-> (Value -> Either Value a)
-> forall {p :: * -> * -> *} {f :: * -> *}.
   (Choice p, Applicative f) =>
   p a (f a) -> p Value (f Value)
forall b t s a. (b -> t) -> (s -> Either t a) -> Prism s t a b
prism a -> Value
forall a. ToJSON a => a -> Value
toJSON ((Value -> Either Value a)
 -> forall {p :: * -> * -> *} {f :: * -> *}.
    (Choice p, Applicative f) =>
    p a (f a) -> p Value (f Value))
-> (Value -> Either Value a)
-> forall {p :: * -> * -> *} {f :: * -> *}.
   (Choice p, Applicative f) =>
   p a (f a) -> p Value (f Value)
forall a b. (a -> b) -> a -> b
$ \Value
x -> case Value -> Result a
forall a. FromJSON a => Value -> Result a
fromJSON Value
x of
  Success a
y -> a -> Either Value a
forall a b. b -> Either a b
Right a
y
  Result a
_ -> Value -> Either Value a
forall a b. a -> Either a b
Left Value
x

-- | Prism for extracting the 'WorkDoneProgressBegin' case from the unstructured 'value' field of 'ProgressParams'.
_workDoneProgressBegin :: Prism' Value WorkDoneProgressBegin
_workDoneProgressBegin :: Prism' Value WorkDoneProgressBegin
_workDoneProgressBegin = p WorkDoneProgressBegin (f WorkDoneProgressBegin)
-> p Value (f Value)
forall a. (ToJSON a, FromJSON a) => Prism' Value a
Prism' Value WorkDoneProgressBegin
_JSON

-- | Prism for extracting the 'WorkDoneProgressEnd' case from the unstructured 'value' field of 'ProgressParams'.
_workDoneProgressEnd :: Prism' Value WorkDoneProgressEnd
_workDoneProgressEnd :: Prism' Value WorkDoneProgressEnd
_workDoneProgressEnd = p WorkDoneProgressEnd (f WorkDoneProgressEnd) -> p Value (f Value)
forall a. (ToJSON a, FromJSON a) => Prism' Value a
Prism' Value WorkDoneProgressEnd
_JSON

-- | Prism for extracting the 'WorkDoneProgressReport' case from the unstructured 'value' field of 'ProgressParams'.
_workDoneProgressReport :: Prism' Value WorkDoneProgressReport
_workDoneProgressReport :: Prism' Value WorkDoneProgressReport
_workDoneProgressReport = p WorkDoneProgressReport (f WorkDoneProgressReport)
-> p Value (f Value)
forall a. (ToJSON a, FromJSON a) => Prism' Value a
Prism' Value WorkDoneProgressReport
_JSON