packages feed

tricorder-0.1.0.0: src/Tricorder/Socket/Protocol.hs

module Tricorder.Socket.Protocol
    ( Query (..)
    , StatusQuery (..)
    , DiagnosticQuery (..)
    , ErrorResponse (..)
    , ClientMessage (..)
    ) where

import Data.Aeson (FromJSON, ToJSON)

import Tricorder.GhcPkg.Types (SourceQuery)


data StatusQuery = StatusQuery {awaitDone :: Bool}
    deriving stock (Eq, Generic, Show)
    deriving anyclass (FromJSON, ToJSON)


newtype DiagnosticQuery = DiagnosticQuery {index :: Int}
    deriving stock (Eq, Generic, Show)
    deriving anyclass (FromJSON, ToJSON)


data Query
    = Status StatusQuery
    | Watch
    | Source [SourceQuery]
    | DiagnosticAt DiagnosticQuery
    | Quit
    deriving stock (Eq, Generic, Show)
    deriving anyclass (FromJSON, ToJSON)


newtype ErrorResponse = ErrorResponse {message :: Text}
    deriving stock (Eq, Generic, Show)
    deriving anyclass (ToJSON)


data ClientMessage = ClientMessage
    { clientVersion :: Text
    , payload :: Query
    }
    deriving stock (Eq, Generic, Show)
    deriving anyclass (FromJSON, ToJSON)