1{-# LANGUAGE OverloadedStrings, RecordWildCards #-}
3import Control.Applicative ((<$>), (<*>), empty)
6import qualified Data.ByteString.Lazy.Char8 as BL
8data Coord = Coord { x :: Double, y :: Double }
11-- A ToJSON instance allows us to encode a value as JSON.
13instance ToJSON Coord where
14 toJSON (Coord xV yV) = object [ "x" .= xV,
17 toEncoding Coord{..} = pairs $
21-- A FromJSON instance allows us to decode a value from JSON. This
22-- should match the format used by the ToJSON instance.
24instance FromJSON Coord where
25 parseJSON (Object v) = Coord <$>
32 let req = decode "{\"x\":3.0,\"y\":-1.0}" :: Maybe Coord
34 let reply = Coord 123.4 20
35 BL.putStrLn (encode reply)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list