haskell-servant / haskell-servant/servant

How to get access to client functions when passing params to hoistClient

Open
#1,019 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
2k
Forks
427
Avg merge
2d 23h
Merged PRs (30d)
5

Description

following the documentation here: https://haskell-servant.readthedocs.io/en/stable/tutorial/Client.html#changing-the-monad-the-client-functions-live-in

you end up with
```
-- our conversion function has type: forall a. ClientM a -> IO a
-- the result has type:
-- Client IO HoistClientAPI = IO Int :<|> (Int -> IO Int)
getClients :: ClientEnv -> Client IO HoistClientAPI
getClients clientEnv
= hoistClient hoistClientAPI
( fmap (either (error . show) id)
. flip runClientM clientEnv
)
(client hoistClientAPI)
```
How do you access the client functions?
I tried something like this, but I get a parse error.
```
(clientEnv (getInt :<|> postInt)) = hoistClient hoistClientAPI
( fmap (either (error . show) id)
. flip runClientM clientEnv
)
(client hoistClientAPI)
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.