Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Servant.Client.Free #920

Merged
merged 2 commits into from
Mar 11, 2018
Merged

Add Servant.Client.Free #920

merged 2 commits into from
Mar 11, 2018

Conversation

phadej
Copy link
Contributor

@phadej phadej commented Mar 11, 2018

this is useful in testing, it nothing else.

@@ -48,3 +51,12 @@ decodedAs response contentType = do
Right val -> return val
where
accept = toList $ contentTypes contentType

instance ClientF ~ f => RunClient (Free f) where
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dunno if should rather have RunClientF f => RunClient (Free f)

runRequest req = liftF (RunRequest req id)
streamingRequest req = liftF (StreamingRequest req id)
throwServantError = liftF . Throw
catchServantError x h = go x where
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not particularly correct, as RunRequest could throw things catchable by catchServantError too.

@jkarni
Copy link
Member

jkarni commented Mar 11, 2018

Is this missing a file (ClientF)?

@phadej
Copy link
Contributor Author

phadej commented Mar 11, 2018

oops

Copy link
Member

@jkarni jkarni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've wanted this before!

data ClientF a
= RunRequest Request (Response -> a)
| StreamingRequest Request (StreamingResponse -> a)
| Throw ServantError
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe adding a Catch constructor would help fix the problem with catchServantError that you mention below?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

catch isn't an algebraic effect. So it won't really work out well.

@phadej
Copy link
Contributor Author

phadej commented Mar 11, 2018

@jkarni @alpmestan I'd rather remove catchServantError, we don't use it itself, and I doubt anyone else

@jkarni
Copy link
Member

jkarni commented Mar 11, 2018 via email

@alpmestan
Copy link
Contributor

LGTM, and I don't mind the removal of catchServantError as well.

@phadej phadej merged commit fe20b5a into haskell-servant:master Mar 11, 2018
@phadej phadej deleted the free-client branch March 11, 2018 19:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants