Skip to content
This repository was archived by the owner on Oct 29, 2021. It is now read-only.

Add an error parameter to the ThrowAll typeclass#152

Open
AJChapman wants to merge 1 commit into
haskell-servant:masterfrom
AJChapman:throw-all-error-param
Open

Add an error parameter to the ThrowAll typeclass#152
AJChapman wants to merge 1 commit into
haskell-servant:masterfrom
AJChapman:throw-all-error-param

Conversation

@AJChapman

Copy link
Copy Markdown

This is so that an application can use its own custom error type and still call throwAll.

This is so that an application can use its own custom error type and still call `throwAll`.
@domenkozar

Copy link
Copy Markdown
Collaborator

Could you define type ThrowAll = ThrowAll' ServerError to avoid a major breaking change?

@AJChapman

Copy link
Copy Markdown
Author

@domenkozar I have tried your suggestion but I can't get it to work. For example, with the type alias we still get errors like this:

src/Servant/Auth/Server.hs:128:5-22: error:
    • The type constructor ‘ThrowAll’ is not the parent of the identifier ‘throwAll’.
      Identifiers can only be exported with their parent type constructor.
      Parent: ThrowAll'
    • In the export: ThrowAll(throwAll)
    |
128 |   , ThrowAll(throwAll)
    |     ^^^^^^^^^^^^^^^^^^

I think to avoid a breaking change I would have to create typeclass ThrowAll', with function throwAll', and leave the existing ThrowAll typeclass, function throwAll, and instances all in place. Should I do it that way?

@domenkozar

Copy link
Copy Markdown
Collaborator

Maybe that's a good candidate for servant then: haskell-servant/servant#765

@phadej @alpmestan what do you think?

@phadej

phadej commented Aug 12, 2019

Copy link
Copy Markdown
Contributor

@alpmestan

Copy link
Copy Markdown
Contributor

servant-generate was inspired by -auth's venerable ThrowAll :-)

And I think it should cover this use case, indeed.

@domenkozar

Copy link
Copy Markdown
Collaborator

See #168

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants