mirror of
https://github.com/zap-proto/haskell.git
synced 2026-10-30 15:05:00 +00:00
This will be more handy, and it also makes sure they actually build (provided we remember to sync them -- it would be good to automate that). This caught the regressions fixed in the previous two commits.
47 lines
1.4 KiB
Haskell
47 lines
1.4 KiB
Haskell
{-# LANGUAGE OverloadedStrings #-}
|
|
-- Note that DuplicateRecordFields is usually needed, as the generated
|
|
-- code relys on it to resolve collisions in capnproto struct field
|
|
-- names:
|
|
{-# LANGUAGE DuplicateRecordFields #-}
|
|
module Examples.Serialization.HighLevel.Write (main) where
|
|
import Capnp.Gen.Addressbook.Pure
|
|
|
|
-- Note that Capnp re-exports `def`, as a convienence
|
|
import Capnp (def, putValue)
|
|
|
|
import qualified Data.Vector as V
|
|
|
|
main :: IO ()
|
|
main = putValue AddressBook
|
|
{ people = V.fromList
|
|
[ Person
|
|
{ id = 123
|
|
, name = "Alice"
|
|
, email = "[email protected]"
|
|
, phones = V.fromList
|
|
[ def
|
|
{ number = "555-1212"
|
|
, type_ = Person'PhoneNumber'Type'mobile
|
|
}
|
|
]
|
|
, employment = Person'employment'school "MIT"
|
|
}
|
|
, Person
|
|
{ id = 456
|
|
, name = "Bob"
|
|
, email = "[email protected]"
|
|
, phones = V.fromList
|
|
[ def
|
|
{ number = "555-4567"
|
|
, type_ = Person'PhoneNumber'Type'home
|
|
}
|
|
, def
|
|
{ number = "555-7654"
|
|
, type_ = Person'PhoneNumber'Type'work
|
|
}
|
|
]
|
|
, employment = Person'employment'selfEmployed
|
|
}
|
|
]
|
|
}
|