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
8
8
9
9
import Control.Applicative (empty )
10
10
import Data.Aeson
11
+ import Data.Aeson.Types
11
12
import Data.Monoid
12
13
import qualified Data.ByteString.Lazy.Char8 as BL
13
14
@@ -28,9 +29,9 @@ instance ToJSON Coord where
28
29
-- should match the format used by the ToJSON instance.
29
30
30
31
instance 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" )
34
35
parseJSON _ = empty
35
36
36
37
main :: IO ()
@@ -39,3 +40,6 @@ main = do
39
40
print req
40
41
let reply = Coord 123.4 20
41
42
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