File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,7 +10,16 @@ and you get a de/serializer for the whole structure. The type system ensures tha
1010every record exactly once. It also includes a library for general record construction in an Applicative context,
1111of which creating codecs is just one application.
1212
13- JSON!
13+ JSON! ([ full example] ( https://github.com/chpatrick/codec/blob/master/Examples/JSON.hs ) )
14+
15+ data User = User
16+ { username :: Text
17+ , userEmail :: Text
18+ , userLanguages :: [ Text ]
19+ , userReferrer :: Maybe User
20+ } deriving Show
21+
22+ genFields ''User
1423
1524 userCodec :: JSONCodec User
1625 userCodec = obj "user object" $
2635 instance ToJSON User where
2736 toJSON = produceVal userCodec
2837
29- Bit fields!
38+ Bit fields! ( [ full example ] ( https://github.com/chpatrick/codec/blob/master/Examples/IP.hs ) )
3039
3140 ipv4Codec :: BinaryCodec IPv4
3241 ipv4Codec = toBytes $
@@ -49,7 +58,7 @@ Bit fields!
4958 get = parse ipv4Codec
5059 put = produce ipv4Codec
5160
52- Storable!
61+ Storable! ( [ full example ] ( https://github.com/chpatrick/codec/blob/master/Examples/Foreign.hsc ) )
5362
5463 timeSpecCodec :: ForeignCodec TimeSpec
5564 timeSpecCodec =
You can’t perform that action at this time.
0 commit comments