mirror of
https://github.com/zap-proto/haskell.git
synced 2026-10-30 15:05:00 +00:00
23 lines
613 B
Haskell
23 lines
613 B
Haskell
{-# LANGUAGE OverloadedLabels #-}
|
|
{-# LANGUAGE TypeApplications #-}
|
|
|
|
module Examples.Serialization.LowLevel.Read (main) where
|
|
|
|
import Zap.Gen.Addressbook
|
|
import qualified Zap as C
|
|
import Control.Monad (forM_)
|
|
import Control.Monad.Trans (lift)
|
|
import Data.Function ((&))
|
|
import qualified Data.Text as T
|
|
|
|
main :: IO ()
|
|
main = do
|
|
addressbook <- C.getRaw @AddressBook C.defaultLimit
|
|
C.evalLimitT C.defaultLimit $ do
|
|
people <- C.readField #people addressbook
|
|
forM_ [0 .. C.length people - 1] $ \i -> do
|
|
people
|
|
& C.index i
|
|
>>= C.parseField #name
|
|
>>= lift . putStrLn . T.unpack
|