summaryrefslogtreecommitdiffstats
path: root/src/Graphics/X11/Xlib/Aeson.hs
blob: 62887ac0338cf1594fdcf58236005fb66d4b86e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Graphics.X11.Xlib.Aeson () where

import Data.Aeson
import Graphics.X11.Xlib.Types


instance ToJSON Rectangle where
    toJSON Rectangle{..} =
          object
            [ "x" .= toJSON rect_x
            , "y" .= toJSON rect_y
            , "width" .= toJSON rect_width
            , "height" .= toJSON rect_height
            ]

instance FromJSON Rectangle where
    parseJSON = withObject "Rectangle" $ \v -> Rectangle
      <$> v .: "x"
      <*> v .: "y"
      <*> v .: "width"
      <*> v .: "height"