git.iko.soy/typeable/servant
on master help sign in
examples: tweak GS3
f3002b3Alp Mestanogullari
servant-examples/getting-started/GS3.hs+4−4
@@ -51,7 +51,7 @@ emailForClient c = Email from' to' subject' body'
51 ++ "Since you've recently turned " ++ show (age c)
51 ++ "Since you've recently turned " ++ show (age c)
52 ++ ", have you checked out our latest "
52 ++ ", have you checked out our latest "
53 ++ intercalate ", " (interested_in c)
53 ++ intercalate ", " (interested_in c)
54− ++ " ? Give us a visit!"
54+ ++ " products? Give us a visit!"
55
55
56type API = "position" :> Capture "x" Int :> Capture "y" Int :> Get '[JSON] Position
56type API = "position" :> Capture "x" Int :> Capture "y" Int :> Get '[JSON] Position
57 :<|> "hello" :> QueryParam "name" String :> Get '[JSON] HelloMessage
57 :<|> "hello" :> QueryParam "name" String :> Get '[JSON] HelloMessage
@@ -65,15 +65,15 @@ server = position
65 :<|> hello
65 :<|> hello
66 :<|> marketing
66 :<|> marketing
67
67
68− where position :: Int -> Int -> EitherT Int IO Position
68+ where position :: Int -> Int -> EitherT ServantErr IO Position
69 position x y = return (Position x y)
69 position x y = return (Position x y)
70
70
71− hello :: Maybe String -> EitherT Int IO HelloMessage
71+ hello :: Maybe String -> EitherT ServantErr IO HelloMessage
72 hello mname = return . HelloMessage $ case mname of
72 hello mname = return . HelloMessage $ case mname of
73 Nothing -> "Hello, anonymous coward"
73 Nothing -> "Hello, anonymous coward"
74 Just n -> "Hello, " ++ n
74 Just n -> "Hello, " ++ n
75
75
76− marketing :: ClientInfo -> EitherT Int IO Email
76+ marketing :: ClientInfo -> EitherT ServantErr IO Email
77 marketing clientinfo = return (emailForClient clientinfo)
77 marketing clientinfo = return (emailForClient clientinfo)
78
78
79app :: Application
79app :: Application