I think we should change the default semantics of Checked. This thread is intended for that discussion. To provide more detail...
The semantics of Ior allow the user to map on the right hand side, regardless of what values are on the left hand side. Most rules in checklist allow the user to signal errors and retain a value on the right. This gives slightly odd semantics where error handling doesn't fail fast when the programmer expects it to.
@Jacoby6000 provided a workaround for this in #9 by adding "strict mode" checks that return an Ior.left on failure instead of an Ior.both. However, I still think this is too fiddly. IMO a developer should be able to choose failure semantics up front and not have to worry about them afterwards. See #2 for thoughts on allowing abstraction of the Checked type.
Regardless of whether we can abstract over different implementations of Checked, we still need to choose a default failure semantics. These are the properties I believe most developers (myself included) will expect:
- errors cause fast failure under
map and flatMap;
- errors accumulate (no fast failure) under
field and fieldWith
(and possibly ap and mapN);
- warnings always accumulate and never cause fast failure;
- values are retained on the right hand side as long as possible.
The problem with this is that flatMap and ap have inconsistent semantics. This is something that Cats and Scalaz fundamentally avoid. However, I believe that in the case of checklist, a non-rules-compliant custom Checked monad will be a reasonable thing to create.
What do people think? Is this an ok idea? Is it an ok idea if we allow users to swap out Checked for Either or Ior as suggested in #2?
I think we should change the default semantics of
Checked. This thread is intended for that discussion. To provide more detail...The semantics of
Iorallow the user to map on the right hand side, regardless of what values are on the left hand side. Most rules in checklist allow the user to signal errors and retain a value on the right. This gives slightly odd semantics where error handling doesn't fail fast when the programmer expects it to.@Jacoby6000 provided a workaround for this in #9 by adding "strict mode" checks that return an
Ior.lefton failure instead of anIor.both. However, I still think this is too fiddly. IMO a developer should be able to choose failure semantics up front and not have to worry about them afterwards. See #2 for thoughts on allowing abstraction of theCheckedtype.Regardless of whether we can abstract over different implementations of
Checked, we still need to choose a default failure semantics. These are the properties I believe most developers (myself included) will expect:mapandflatMap;fieldandfieldWith(and possibly
apandmapN);The problem with this is that
flatMapandaphave inconsistent semantics. This is something that Cats and Scalaz fundamentally avoid. However, I believe that in the case of checklist, a non-rules-compliant customCheckedmonad will be a reasonable thing to create.What do people think? Is this an ok idea? Is it an ok idea if we allow users to swap out
CheckedforEitherorIoras suggested in #2?