@@ -1,7 +1,8 @@
1−{-# LANGUAGE OverloadedStrings #-}
1+{-# LANGUAGE OverloadedStrings, RecordWildCards #-}
22
33import Control.Applicative ((<$>), (<*>), empty)
44import Data.Aeson
5+import Data.Monoid
56import qualified Data.ByteString.Lazy.Char8 as BL
67
78data Coord = Coord { x :: Double, y :: Double }
@@ -13,6 +14,10 @@ instance ToJSON Coord where
1314 toJSON (Coord xV yV) = object [ "x" .= xV,
1415 "y" .= yV ]
1516
17+ toEncoding Coord{..} = series $
18+ "x" .= x <>
19+ "y" .= y
20+
1621-- A FromJSON instance allows us to decode a value from JSON. This
1722-- should match the format used by the ToJSON instance.
1823