packages feed

phoityne-vscode-0.0.1.0: app/Phoityne/IO/GUI/VSCode/TH/PauseResponseJSON.hs

{-# LANGUAGE TemplateHaskell     #-}


module Phoityne.IO.GUI.VSCode.TH.PauseResponseJSON where

import Data.Aeson.TH

import Phoityne.Utility
import Phoityne.IO.GUI.VSCode.TH.PauseRequestJSON

-- |
--  Response to "pause" request. This is just an acknowledgement, so no body field is required.
--
data PauseResponse =
  PauseResponse {
    seqPauseResponse         :: Int     -- Sequence number
  , typePauseResponse        :: String  -- One of "request", "response", or "event"
  , request_seqPauseResponse :: Int     -- Sequence number of the corresponding request
  , successPauseResponse     :: Bool    -- Outcome of the request
  , commandPauseResponse     :: String  -- The command requested 
  , messagePauseResponse     :: String  -- Contains error message if success == false.
  } deriving (Show, Read, Eq)

$(deriveJSON defaultOptions { fieldLabelModifier = rdrop (length "PauseResponse") } ''PauseResponse)

-- |
--
defaultPauseResponse :: Int -> PauseRequest -> PauseResponse
defaultPauseResponse seq (PauseRequest reqSeq _ _ _) =
  PauseResponse seq "response" reqSeq True "pause" ""