Skip to content
This repository was archived by the owner on Aug 17, 2019. It is now read-only.

Commit 4d6367f

Browse files
committed
Add maybe as a synonym to the virtual constructor Maybe
1 parent 324e359 commit 4d6367f

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

src/main/scala/com/ckkloverdos/package.scala

+7-4
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,24 @@ package object maybe {
3333
}
3434

3535
@inline
36-
def safeUnit[A](f: => A): Unit = {
36+
def maybe[A](f: A) = Maybe(f)
37+
38+
@inline
39+
def safeUnit[A](f: A): Unit = {
3740
try f
3841
catch { case _ }
3942
}
4043

4144
implicit def optionToMaybe[T](x: Option[T]): MaybeOption[T] = x match {
42-
case Some(c) => Just(c)
43-
case None => NoVal
45+
case Some(c) Just(c)
46+
case None NoVal
4447
}
4548

4649
implicit def eitherToMaybe[A <: Throwable, B](x: Either[A, B]): MaybeEither[B] = x match {
4750
case Left(left) Failed(left)
4851
case Right(right) Just(right)
4952
}
50-
53+
5154
def sameThrowables(a: Throwable, b: Throwable): Boolean = {
5255
(a, b) match {
5356
case (null, null) true

0 commit comments

Comments
 (0)