Skip to content

Commit

Permalink
Either Bimonad and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefanos Stefanou committed Nov 16, 2023
1 parent a4d26c2 commit cdb88e7
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 14 deletions.
2 changes: 1 addition & 1 deletion diagram.drawio
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<mxfile host="Electron" modified="2023-11-10T09:00:49.425Z" agent="5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/18.0.0 Chrome/100.0.4896.143 Electron/18.2.0 Safari/537.36" etag="0HwG-3LoDtaVi8Qi3jfV" version="18.0.0" type="device" pages="2"><diagram id="tPDxc9v9lSpUtl4Dx5MV" name="Initial Big Picture">7V1bd5u4Fv4t58Gr6QNd3G0/2k7SW3Km0+RMm7zMkkG21QCiQo7j+fVHAoEByY4bY2N38pAEJCHEty/a2tpb6Vij8Ok9AfHsGvsw6Ji6/9SxzjumaRqmw/7wkqUo0XtuVjIlyM/KjFXBDfoHikJdlM6RD5NKQ4pxQFFcLfRwFEGPVsoAIXhRbTbBQfWtMZhCqeDGA4Fc+g35dJaV9szuqvwDRNNZ/mbD7Wc1Icgbiy9JZsDHi1KRddGxRgRjml2FTyMYcPRyXLLnLtfUFgMjMKLbPHD7+fO3u5/JzU//m75I8PDmsnulWVkvjyCYiw8Wg6XLHAGC55EPeSdGxxouZojCmxh4vHbBiM7KZjQMRLU8KDHOR0gofCoViUG+hziElCxZE1GrOZZgGsEzmisQXKwIYPRd0WhWRt8RLYGg+rTofQUMuxDYqHG6v126d6OuF3rwC/kcP4xmg7lm9E4BKKenREqXkTLtfSHlnAJQlr0tS5m9BoC6ufs6vx+9f7iwv9+55vj+Gs16mtFvGKkJjqhQoIbZDHJWzjsCOMeRcbN6Kv7KFX/zsDUtiXuATTOPD7buCcBWl9P+tlJqN6HOlLj1JJSgzwwEcYsJneEpjkBwsSodrnDU2d2qzRXGsUDvB6R0KeADc4qr2M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xLF4z4Rf5hSxnNb/7M8ses4enK+qTs+IsK0iXxYJ7wKHyfONQdjlB3prBdJGWsjx/1VOKSVuY87Yi59VGbXmITQlZ4PX2kiKiUjBlMxWcLfCEUcalErNYjhz7hNKWlCbQI3EgBbs6mrFECmeShzXOQiLwVOr5pTLpUamxFeY+3cYiJAjhWGqcLWOEc1TGyx3W2ZagMJc3W5MK1leYRVjwjRxS9DpF2Avfm1ZxnFUuMoeFFtYdVPoFFs4NXk5dBVc2ivj+R6yBEuvzHGI7GBUJcw+/WpwOAGrQBAW6QIEOUM6xOFkKp584RrnLdKMC9kdj1VdYzRhi2kH1rY8GylZATXFEAgkmgXT7rCJi8zZu9fTYAxaysYv6Si6VPS6YW45zlH9vXztoRwF9C4MIHhSt7/vA87rQImfu2AdC65hNthbQzXaw38Snb11Lu3Vd1bosZnLK6Xu3r927QwXu93glsy6UawTGDZSFwgliBk3MpjHUzbkMfA305TL2hFz+6WJuudkxtFNWC7fm+wQ9OGnXw92k567dtw9VNbVI26Z20mrZNEoSuvlEbtafM9SSK2dMPCjICn8e0gP9pNWCrUb6gvOTTtOtp6Hrasetln0PkBIEhQQJjBEN8JzDo6RrLcSH+omr9d8YegvK9O/etLPBu25K3M9/DEckMXyyvk+eB/zv5vGpY/d3SqKE4oY1ZzgVh/WmlvLOfs8K5PJ6NH5OfWORBDPAQrS8u8k6aI92mz4l4vbe+ZcIJnLGJOEMLT0BvurJEAryjsC8vkIx3/MZ2BkH9YWuXgnuicU3IoPxGfgD7fzVl71bFkN0iPz8JlTt3fVjbgjJw+rL37av9v3UuvgH</diagram></mxfile>
<mxfile host="Electron" modified="2023-11-16T11:43:56.111Z" agent="5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) draw.io/18.0.0 Chrome/100.0.4896.143 Electron/18.2.0 Safari/537.36" etag="444dfJYiJO0FIwbymHir" version="18.0.0" type="device" pages="2"><diagram id="tPDxc9v9lSpUtl4Dx5MV" name="Initial Big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6oLT5Z82Rf1Cp5veLZvqilneiLprvMpV3L4y0IBOm+dbW+aIk3gF6YpDVHLvRekcmMfreTuj9P8Nw4MV8DmV0NgOLrMEav3+n3u7bdt4y+bYO+WY3YiCMCejai/R0XtAMwStCIa9JjCzmRIAd1pfKTyuyr/FxAfswu5/LcvypEyewaHbu7E6UeuIwomX1hcOZpYmVpJ9KLplbj487RW6fRS5NTaL8i6SsTDKjVtc4e1mjOM16mvAB/pspqvCLJ7OEZIiimdbSuiiMoprwKf5Bn8CVGUGLWvOYIiilHA0ZNU1mmwOB1RwNMORowbhhmklKoHTN5B/SZSr52v/RoBCXl2+Nvg5mNM1B2kX+eHkERpbeyCApIX2MvG98AgowcjaAAYJ7YgkBwkQiK+RPsm9cmF2xRoZzRJ7httl5+zVdV+EQazolrPtMWJeJEelE5nLjmE+nrWPNZ8vIlukc5+LddvMfLL9zFV8n4tSvx17F8cTm6vJXd6GOJkXw2VKQZijSyZyJfrDqnE84f9gzjNz5PubN1DqeHKVzhnK9V9l7HOfyeh/H9l/vhwt06H6Z3f/53uEU/1orXl6X5uPQZirb4+JTytlBlj1QrYZJlqEmPVLeltxnLHjs5xztwSsCAbNN/iid68063EhiFz60s1y3NBGd/ovdQv5t7kqENxLNXCrVR1VuISsh+1pfaj8qA/UJloPGnpCUZMBUOxkVlQF7sNfKd6rYh7DuYiteNLwqcfN/29aHqsnO55xh0FQ8asOTuv82Ll2y7/3wQ3Pwf</diagram></mxfile>
20 changes: 9 additions & 11 deletions src/main/scala/mycats/instances/Either.scala
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
package mycats.instances
import mycats.lib.morphisms.bi.BiFunctor
import mycats.lib.morphisms.error.MonadError
import mycats.lib.obj.Semigroup

object Either {
implicit def eitherMonadErrorInstance[E](implicit semiOfE:Semigroup[E]) = new MonadError[({type F[C] = Either[E,C]})#F,E] {

override def ensure[A](fa: Either[E, A])(error: =>E)(predicate: A => Boolean): Either[E, A] = ensureOr(fa)(_=>error)(predicate)

override def ensureOr[A](fa: Either[E, A])(error: A => E)(predicate: A => Boolean): Either[E, A] = fa match {
case p@Right(value) if predicate(value) => p
case Right(value) => Left(error(value))
case p=>p
}
implicit def eitherMonadErrorInstance[E] = new MonadError[({type F[C] = Either[E,C]})#F,E] with BiFunctor[Either] {

override def adaptError[A](fa: Either[E, A])(pf: PartialFunction[E, E]): Either[E, A] = fa match {
case Left(value) => Left(pf.orElse[E,E]({case e=>e})(value))
Expand All @@ -36,10 +29,15 @@ object Either {
case (Right(f),Right(a))=>Right(f(a))
case (Left(f),_)=>Left(f)
case (_,Left(a))=>Left(a)
case (Left(f),Left(a))=>Left(semiOfE.combine(f,a))

}

override def map[A, B](fa: Either[E, A])(f: A => B): Either[E, B] = flatMap(fa)(f andThen pure)
}

override def bimap[A, B, C, D](fab: Either[A, B])(fac: A => C)(fbd: B => D): Either[C, D] =
fab match {
case Left(value) => Left(fac(value))
case Right(value) => Right(fbd(value))
}
}
}
5 changes: 3 additions & 2 deletions src/main/scala/mycats/lib/morphisms/error/MonadError.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package mycats.lib.morphisms.error
import mycats.lib.morphisms.Monad

trait MonadError[F[_],E] extends ApplicativeError[F,E] with Monad[F]{
def ensure[A](fa:F[A])(error: =>E)(predicate:A=>Boolean):F[A]
def ensureOr[A](fa:F[A])(error: A=>E)(predicate:A=>Boolean):F[A]
def ensure[A](fa:F[A])(error: =>E)(predicate:A=>Boolean):F[A] = ???
def ensureOr[A](fa:F[A])(error: A=>E)(predicate:A=>Boolean):F[A] =
flatMap[A,A](fa)(v => if(predicate(v)) pure(v) else raiseError[A](error(v)))

def adaptError[A](fa:F[A])(pf:PartialFunction[E,E]):F[A]
def rethrow[A,EE<:E](fa:F[Either[EE,A]]):F[A]
Expand Down
Loading

0 comments on commit cdb88e7

Please sign in to comment.