diff options
author | tv <tv@krebsco.de> | 2021-02-23 21:48:55 +0100 |
---|---|---|
committer | tv <tv@krebsco.de> | 2021-02-23 21:59:29 +0100 |
commit | c0a70a62513baf2b437db4ebe3e5a32e3cfa5905 (patch) | |
tree | 8d0fa5513fcaa77624d9c0882c4c75aae42ad597 |
-rw-r--r-- | X11-aeson.cabal | 15 | ||||
-rw-r--r-- | src/Graphics/X11/Xlib/Aeson.hs | 24 |
2 files changed, 39 insertions, 0 deletions
diff --git a/X11-aeson.cabal b/X11-aeson.cabal new file mode 100644 index 0000000..28876df --- /dev/null +++ b/X11-aeson.cabal @@ -0,0 +1,15 @@ +name: X11-aeson +version: 1.0.0 +license: MIT +author: tv +maintainer: tv@krebsco.de +build-type: Simple +cabal-version: >=1.2 + +library + build-depends: base + , aeson + , X11 + exposed-modules: Graphics.X11.Xlib.Aeson + ghc-options: -O2 -Wall + hs-source-dirs: src diff --git a/src/Graphics/X11/Xlib/Aeson.hs b/src/Graphics/X11/Xlib/Aeson.hs new file mode 100644 index 0000000..62887ac --- /dev/null +++ b/src/Graphics/X11/Xlib/Aeson.hs @@ -0,0 +1,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" |