File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import Prelude.Compat
88
99import Control.Applicative (empty )
1010import Data.Aeson
11+ import Data.Aeson.Types
1112import Data.Monoid
1213import qualified Data.ByteString.Lazy.Char8 as BL
1314
@@ -28,9 +29,9 @@ instance ToJSON Coord where
2829-- should match the format used by the ToJSON instance.
2930
3031instance FromJSON Coord where
31- parseJSON (Object v) = Coord <$>
32- v .: " x" <*>
33- v .: " y"
32+ parseJSON (Object v) = liftP2 Coord
33+ ( v .: " x" )
34+ ( v .: " y" )
3435 parseJSON _ = empty
3536
3637main :: IO ()
@@ -39,3 +40,6 @@ main = do
3940 print req
4041 let reply = Coord 123.4 20
4142 BL. putStrLn (encode reply)
43+ let asCoord :: f Coord -> f Coord
44+ asCoord = id
45+ print (asCoord (verboseDecode " {}" ))
You can’t perform that action at this time.
0 commit comments