mirror of
https://github.com/zap-proto/haskell.git
synced 2026-10-30 15:05:00 +00:00
48 lines
1.4 KiB
Haskell
48 lines
1.4 KiB
Haskell
-- Note that DuplicateRecordFields is usually needed, as the generated
|
|
-- code relys on it to resolve collisions in zap struct field
|
|
-- names:
|
|
{-# LANGUAGE DuplicateRecordFields #-}
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
module Examples.Serialization.HighLevel.Write (main) where
|
|
|
|
-- Note that Zap re-exports `def`, as a convienence
|
|
import Zap (def, putParsed)
|
|
import Zap.Gen.Addressbook
|
|
|
|
main :: IO ()
|
|
main =
|
|
putParsed
|
|
AddressBook
|
|
{ people =
|
|
[ Person
|
|
{ id = 123,
|
|
name = "Alice",
|
|
email = "[email protected]",
|
|
phones =
|
|
[ def
|
|
{ number = "555-1212",
|
|
type_ = Person'PhoneNumber'Type'mobile
|
|
}
|
|
],
|
|
employment = Person'employment' $ Person'employment'school "MIT"
|
|
},
|
|
Person
|
|
{ id = 456,
|
|
name = "Bob",
|
|
email = "[email protected]",
|
|
phones =
|
|
[ def
|
|
{ number = "555-4567",
|
|
type_ = Person'PhoneNumber'Type'home
|
|
},
|
|
def
|
|
{ number = "555-7654",
|
|
type_ = Person'PhoneNumber'Type'work
|
|
}
|
|
],
|
|
employment = Person'employment' Person'employment'selfEmployed
|
|
}
|
|
]
|
|
}
|