Skip to content

Commit

Permalink
change unnaply return types. use Some instead of Option if possible
Browse files Browse the repository at this point in the history
  • Loading branch information
xuwei-k committed Nov 27, 2020
1 parent d6c520e commit 85eb584
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion core/src/main/scala/scalaz/Cofree.scala
Expand Up @@ -83,7 +83,7 @@ object Cofree extends CofreeInstances {

def delay[S[_], A](h: A, t: => S[Cofree[S, A]]): Cofree[S,A] = applyT(h, Trampoline.delay(t))

def unapply[S[_], A](c: Cofree[S, A]): Option[(A, S[Cofree[S,A]])] = Some( (c.head, c.tail) )
def unapply[S[_], A](c: Cofree[S, A]): Some[(A, S[Cofree[S,A]])] = Some( (c.head, c.tail) )

//creates an instance of Cofree that trampolines all of the calls to the tail so we get stack safety
def applyT[S[_],A](a: A, tf: Free[Function0,S[Cofree[S,A]]])(implicit T: Functor[λ[a => Free[Function0, a]]]): Cofree[S, A] =
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/scala/scalaz/Name.scala
Expand Up @@ -23,7 +23,7 @@ object Name {
def apply[A](a: => A): Name[A] = new Name[A] {
def value = a
}
def unapply[A](v: Name[A]): Option[A] = Some(v.value)
def unapply[A](v: Name[A]): Some[A] = Some(v.value)

implicit val name: Monad[Name] with BindRec[Name] with Comonad[Name] with Distributive[Name] with Traverse1[Name] with Zip[Name] with Unzip[Name] with Align[Name] with Cozip[Name] =
new Monad[Name] with BindRec[Name] with Comonad[Name] with Distributive[Name] with Traverse1[Name] with Zip[Name] with Unzip[Name] with Align[Name] with Cozip[Name] {
Expand Down Expand Up @@ -62,7 +62,7 @@ object Name {
object Need {
def apply[A](a: => A): Need[A] = new Need(() => a)

def unapply[A](x: Need[A]): Option[A] = Some(x.value)
def unapply[A](x: Need[A]): Some[A] = Some(x.value)

implicit val need: Monad[Need] with BindRec[Need] with Comonad[Need] with Distributive[Need] with Traverse1[Need] with Zip[Need] with Unzip[Need] with Align[Need] with Cozip[Need] =
new Monad[Need] with BindRec[Need] with Comonad[Need] with Distributive[Need] with Traverse1[Need] with Zip[Need] with Unzip[Need] with Align[Need] with Cozip[Need] {
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/scalaz/NonEmptyList.scala
Expand Up @@ -152,7 +152,7 @@ object NonEmptyList extends NonEmptyListInstances {
def fromSeq[A](h: A, t: Seq[A]): NonEmptyList[A] =
nel(h, IList.fromSeq(t))

def unapply[A](v: NonEmptyList[A]): Option[(A, IList[A])] =
def unapply[A](v: NonEmptyList[A]): Some[(A, IList[A])] =
Some((v.head, v.tail))

def nel[A](h: A, t: IList[A]): NonEmptyList[A] =
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/scalaz/StrictTree.scala
Expand Up @@ -256,7 +256,7 @@ object StrictTree extends StrictTreeInstances {
StrictTree[A](root, forest)
}

def unapply[A](t: StrictTree[A]): Option[(A, Vector[StrictTree[A]])] = Some((t.rootLabel, t.subForest))
def unapply[A](t: StrictTree[A]): Some[(A, Vector[StrictTree[A]])] = Some((t.rootLabel, t.subForest))
}

/**
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/scalaz/Tag.scala
Expand Up @@ -80,7 +80,7 @@ object Tag {
def unsubst[F[_], A](fa: F[A @@ T]): F[A] = Tag.unsubst(fa)

/** Pattern match on a tagged value */
def unapply[A](a: A @@ T): Option[A] = Some(unwrap(a))
def unapply[A](a: A @@ T): Some[A] = Some(unwrap(a))
}

/** Variants of `apply`, `subst`, and `unsubst` that require
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/scala/scalaz/Tree.scala
Expand Up @@ -245,7 +245,7 @@ object Tree extends TreeInstances {
}
}

def unapply[A](t: Tree[A]): Option[(A, EStream[Tree[A]])] = Some((t.rootLabel, t.subForest))
def unapply[A](t: Tree[A]): Some[(A, EStream[Tree[A]])] = Some((t.rootLabel, t.subForest))
}

/**
Expand Down

1 comment on commit 85eb584

@xuwei-k
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.