Closed
Description
Prompted by
Validators are working directly in the server monad, e.g.:
hackage-server/src/Distribution/Server/Util/Validators.hs
Lines 23 to 30 in 1c35e03
This makes it hard to test them cheaply.
There is a purely functional core that struggles to get out here: the actual validation does not need IO
etc., it is pure logic.
Suggested restructuring:
data FooError = FooProblem1 | FooProblem2 | ...
checkFoo :: Foo -> Either FooError ()
does the actual check, indicating the violation by aLeft FooProblem...
guardFoo :: Foo -> ServerPartE ()
callscheckFoo
and handles the exceptionLeft ...
by escalating the problem to the user.- Add unit tests for
checkFoo