module QuickPlot.IPC.Protocol (
QPMessage (..)
, Library (..)
, Procedure (..)
, encode
) where
import Data.ByteString.Lazy.Internal
import Data.Text
import QuickPlot.IPC.QQ
import qualified Data.Aeson as JSON
encode :: QPMessage
-> ByteString
encode (QPMessage library procedure content) = JSON.encode message
where message :: JSON.Value
message = [json|{
library : #{ library },
procedure : #{ procedure },
content : #{ content }
}|]
data QPMessage = QPMessage Library Procedure JSON.Value
data Procedure = NewPlot
| Clear
data Library = QuickPlot
| Plotly
| Vis
instance JSON.ToJSON Procedure where
toJSON NewPlot = JSON.String "newPlot"
toJSON Clear = JSON.String "clear"
instance JSON.ToJSON Library where
toJSON QuickPlot = JSON.String "QuickPlot"
toJSON Plotly = JSON.String "plotly"
toJSON Vis = JSON.String "vis"