NorfairKing / validity

Validity and validity-based testing
https://www.youtube.com/watch?v=eIs9qNh17SM
MIT License
156 stars 31 forks source link

Pass the validation to `MonadFail`? #112

Open KommuSoft opened 1 year ago

KommuSoft commented 1 year ago

A (simple) usecase could be to check if the item is valid, and if not fail with the (list) of errors.

So something as:

validateFail :: MonadFail m => a -> m a
validateFail = either fail pure . prettyValidate

A simple use case for this would be m ~ Q for example: a QuasiQuoter where we want to raise a compile error if the quasi quoted value has some invalid properties.

NorfairKing commented 1 year ago

LGTM, PR welcome