-
Notifications
You must be signed in to change notification settings - Fork 117
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
econstruct, like scalaz.MonadError.emap #120
Conversation
try { | ||
val bits = parameters.map { p => | ||
makeParam(p) match { | ||
case Left(e) => throw EarlyExit(e) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return Left(err.asInstanceOf[E])
, and remove the try
/catch
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't work, because the nearest method seems to be the map closure (I tried it)
final def econstruct[E <: AnyRef, Return](makeParam: Param[Typeclass, Type] => Either[E, Return]): Either[E, Type] = { | ||
// poor man's scalaz.Traverse | ||
try { | ||
val bits = parameters.map { p => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bits
is misleading, I think. How about writing it as a point-free expression as a way to avoid coming up with a unique name? ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also don't think the name econstruct
is clear enough. The e
could stand for "either" or "exception". Let's go with eitherConstruct
, unless you can suggest anything better...
@@ -248,3 +268,5 @@ final case class TypeName(owner: String, short: String) { | |||
* whose full name contains the given [[String]] | |||
*/ | |||
final class debug(typeNamePart: String = "") extends scala.annotation.StaticAnnotation | |||
|
|||
private[magnolia] final case class EarlyExit[E](e: E) extends Exception with util.control.NoStackTrace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that using return
will avoid the stacktrace being generated too.
@propensive changes made. Note my comments about |
close #118