-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuickstart.hs
27 lines (22 loc) · 863 Bytes
/
Quickstart.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{-# LANGUAGE OverloadedStrings #-}
module Quickstart where
import qualified Data.ByteString.Char8 as B
import Data.Monoid ((<>))
import Pipes (runEffect, (>->))
import Pipes.HTTP (newManager, tlsManagerSettings)
import qualified Pipes.Prelude as P
import Network.Nylas
token :: AccessToken
token = AccessToken "_PUT_YOUR_ACCESS_TOKEN_HERE_"
main :: IO ()
main = do
mgr <- newManager tlsManagerSettings
let cursor = Nothing
res <- consumeDeltas mgr token cursor (P.map show >-> P.print)
case res of
Left (ParsingError err remainder) -> do
putStrLn $ "ERROR: " <> show err
putStrLn "next few items:"
runEffect $ remainder >-> P.take 3 >-> P.map B.unpack >-> P.stdoutLn
Left (ConsumerError _) -> error "not possible"
Right _ -> return ()