Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How many implicits are there in Scala?

If I haven't imported anything but Scala's usual defaults, how many implicits (implicit conversions) are in scope?

Is there a complete list of them somewhere, preferably organized by type that they could act upon?

like image 603
kittylyst Avatar asked Dec 01 '11 01:12

kittylyst


People also ask

What are Implicits in Scala?

Implicit parameters are the parameters that are passed to a function with implicit keyword in Scala, which means the values will be taken from the context in which they are called.

Does Scala 3 have Implicits?

As powerful as it may be, there are still many complaints regarding its complexities, even for experienced developers. Due to these problems, the Scala compiler team redesigned the implicit in the new Scala 3, making it more clear and easier to use.

Why does Scala have Implicits?

The implicit system in Scala allows the compiler to adjust code using a well-defined lookup mechanism. A programmer in Scala can leave out information that the compiler will attempt to infer at compile time. The Scala compiler can infer one of two situations: A method call or constructor with a missing parameter.

Where does Scala look for Implicits?

Unless the call site explicitly provides arguments for those parameters, Scala will look for implicitly available given (or implicit in Scala 2) values of the correct type. If it can find appropriate values, it automatically passes them.


3 Answers

Scala 2.9.1 has 96 implicits, most of them conversions, imported by default. Note that there are other implicits that do not show up, because they are defined on object companions for a particular class. For example, there's an implicit Ordering[T] => Ordering[Iterable[T]] which does not appear below, because it is defined on the object companion of Ordering.

Welcome to Scala version 2.9.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_26).
Type in expressions to have them evaluated.
Type :help for more information.

scala> :implicits
No implicits have been imported other than those in Predef.

scala> :implicits -v
/* 96 implicit members imported from scala.Predef */
  /* 66 inherited from scala.Predef */
  implicit def Double2double(x: jl.Double): Double
  implicit def byte2double(x: Byte): Double
  implicit def char2double(x: Char): Double
  implicit def float2double(x: Float): Double
  implicit def int2double(x: Int): Double
  implicit def long2double(x: Long): Double
  implicit def short2double(x: Short): Double

  implicit def Float2float(x: jl.Float): Float
  implicit def byte2float(x: Byte): Float
  implicit def char2float(x: Char): Float
  implicit def int2float(x: Int): Float
  implicit def long2float(x: Long): Float
  implicit def short2float(x: Short): Float

  implicit def Integer2int(x: jl.Integer): Int
  implicit def byte2int(x: Byte): Int
  implicit def char2int(x: Char): Int
  implicit def short2int(x: Short): Int

  implicit def Long2long(x: jl.Long): Long
  implicit def byte2long(x: Byte): Long
  implicit def char2long(x: Char): Long
  implicit def int2long(x: Int): Long
  implicit def short2long(x: Short): Long

  implicit def boolean2BooleanConflict(x: Boolean): jl.Object
  implicit def byte2ByteConflict(x: Byte): jl.Object
  implicit def char2CharacterConflict(x: Char): jl.Object
  implicit def double2DoubleConflict(x: Double): jl.Object
  implicit def float2FloatConflict(x: Float): jl.Object
  implicit def int2IntegerConflict(x: Int): jl.Object
  implicit def long2LongConflict(x: Long): jl.Object
  implicit def short2ShortConflict(x: Short): jl.Object

  implicit def booleanArrayOps(xs: Array[Boolean]): mutable.ArrayOps[Boolean]
  implicit def byteArrayOps(xs: Array[Byte]): mutable.ArrayOps[Byte]
  implicit def charArrayOps(xs: Array[Char]): mutable.ArrayOps[Char]
  implicit def doubleArrayOps(xs: Array[Double]): mutable.ArrayOps[Double]
  implicit def floatArrayOps(xs: Array[Float]): mutable.ArrayOps[Float]
  implicit def genericArrayOps[T](xs: Array[T]): mutable.ArrayOps[T]
  implicit def intArrayOps(xs: Array[Int]): mutable.ArrayOps[Int]
  implicit def longArrayOps(xs: Array[Long]): mutable.ArrayOps[Long]
  implicit def refArrayOps[T <: AnyRef](xs: Array[T]): mutable.ArrayOps[T]
  implicit def shortArrayOps(xs: Array[Short]): mutable.ArrayOps[Short]
  implicit def unitArrayOps(xs: Array[Unit]): mutable.ArrayOps[Unit]

  implicit def Boolean2boolean(x: jl.Boolean): Boolean
  implicit def Byte2byte(x: jl.Byte): Byte
  implicit def Character2char(x: jl.Character): Char
  implicit def Short2short(x: jl.Short): Short
  implicit def any2ArrowAssoc[A](x: A): ArrowAssoc[A]
  implicit def any2Ensuring[A](x: A): Ensuring[A]
  implicit def any2stringadd(x: Any): runtime.StringAdd
  implicit def arrayToCharSequence(xs: Array[Char]): jl.CharSequence
  implicit def augmentString(x: String): immutable.StringOps
  implicit def boolean2Boolean(x: Boolean): jl.Boolean
  implicit def byte2Byte(x: Byte): jl.Byte
  implicit def byte2short(x: Byte): Short
  implicit def char2Character(x: Char): jl.Character
  implicit def conforms[A]: <:<[A,A]
  implicit def double2Double(x: Double): jl.Double
  implicit def exceptionWrapper(exc: Throwable): runtime.RichException
  implicit def float2Float(x: Float): jl.Float
  implicit def int2Integer(x: Int): jl.Integer
  implicit def long2Long(x: Long): jl.Long
  implicit def seqToCharSequence(xs: IndexedSeq[Char]): jl.CharSequence
  implicit def short2Short(x: Short): jl.Short
  implicit def stringCanBuildFrom: generic.CanBuildFrom[String,Char,String]
  implicit def unaugmentString(x: immutable.StringOps): String
  implicit def zipped2ToTraversable[El1,El2](zz: (_$1, _$2)#Zipped[_, El1, _, El2]): Traversable[(El1, El2)]
  implicit def zipped3ToTraversable[El1,El2,El3](zz: (_$5, _$6, _$7)#Zipped[_, El1, _, El2, _, El3]): Traversable[(El1, El2, El3)]

  /* 30 inherited from scala.LowPriorityImplicits */
  implicit def genericWrapArray[T](xs: Array[T]): mutable.WrappedArray[T]
  implicit def wrapBooleanArray(xs: Array[Boolean]): mutable.WrappedArray[Boolean]
  implicit def wrapByteArray(xs: Array[Byte]): mutable.WrappedArray[Byte]
  implicit def wrapCharArray(xs: Array[Char]): mutable.WrappedArray[Char]
  implicit def wrapDoubleArray(xs: Array[Double]): mutable.WrappedArray[Double]
  implicit def wrapFloatArray(xs: Array[Float]): mutable.WrappedArray[Float]
  implicit def wrapIntArray(xs: Array[Int]): mutable.WrappedArray[Int]
  implicit def wrapLongArray(xs: Array[Long]): mutable.WrappedArray[Long]
  implicit def wrapRefArray[T <: AnyRef](xs: Array[T]): mutable.WrappedArray[T]
  implicit def wrapShortArray(xs: Array[Short]): mutable.WrappedArray[Short]
  implicit def wrapUnitArray(xs: Array[Unit]): mutable.WrappedArray[Unit]

  implicit def Boolean2booleanNullConflict(x: Null): Boolean
  implicit def Byte2byteNullConflict(x: Null): Byte
  implicit def Character2charNullConflict(x: Null): Char
  implicit def Double2doubleNullConflict(x: Null): Double
  implicit def Float2floatNullConflict(x: Null): Float
  implicit def Integer2intNullConflict(x: Null): Int
  implicit def Long2longNullConflict(x: Null): Long
  implicit def Short2shortNullConflict(x: Null): Short
  implicit def booleanWrapper(x: Boolean): runtime.RichBoolean
  implicit def byteWrapper(x: Byte): runtime.RichByte
  implicit def charWrapper(c: Char): runtime.RichChar
  implicit def doubleWrapper(x: Double): runtime.RichDouble
  implicit def fallbackStringCanBuildFrom[T]: generic.CanBuildFrom[String,T,immutable.IndexedSeq[T]]
  implicit def floatWrapper(x: Float): runtime.RichFloat
  implicit def intWrapper(x: Int): runtime.RichInt
  implicit def longWrapper(x: Long): runtime.RichLong
  implicit def shortWrapper(x: Short): runtime.RichShort
  implicit def unwrapString(ws: immutable.WrappedString): String
  implicit def wrapString(s: String): immutable.WrappedString

And, just for the fun of it, Scalaz adds another 144:

scala> import scalaz._
import scalaz._

scala> import Scalaz._
import Scalaz._

scala> :implicits
/* 144 implicit members imported from scalaz.Scalaz */
  /* 1 inherited from scalaz.ZipStreams */
  implicit def ZipStreamFrom[A](z: scalaz.ZipStream[A]): Stream[A]

  /* 11 inherited from scalaz.Tuples */
  implicit def ToTuple10W[A,B,C,D,E,F,G,H,I,J](t: (A, B, C, D, E, F, G, H, I, J)): Tuple10W[A,B,C,D,E,F,G,H,I,J]
  implicit def ToTuple11W[A,B,C,D,E,F,G,H,I,J,K](t: (A, B, C, D, E, F, G, H, I, J, K)): Tuple11W[A,B,C,D,E,F,G,H,I,J,K]
  implicit def ToTuple12W[A,B,C,D,E,F,G,H,I,J,K,L](t: (A, B, C, D, E, F, G, H, I, J, K, L)): Tuple12W[A,B,C,D,E,F,G,H,I,J,K,L]
  implicit def ToTuple2W[A,B](t: (A, B)): Tuple2W[A,B]
  implicit def ToTuple3W[A,B,C](t: (A, B, C)): Tuple3W[A,B,C]
  implicit def ToTuple4W[A,B,C,D](t: (A, B, C, D)): Tuple4W[A,B,C,D]
  implicit def ToTuple5W[A,B,C,D,E](t: (A, B, C, D, E)): Tuple5W[A,B,C,D,E]
  implicit def ToTuple6W[A,B,C,D,E,F](t: (A, B, C, D, E, F)): Tuple6W[A,B,C,D,E,F]
  implicit def ToTuple7W[A,B,C,D,E,F,G](t: (A, B, C, D, E, F, G)): Tuple7W[A,B,C,D,E,F,G]
  implicit def ToTuple8W[A,B,C,D,E,F,G,H](t: (A, B, C, D, E, F, G, H)): Tuple8W[A,B,C,D,E,F,G,H]
  implicit def ToTuple9W[A,B,C,D,E,F,G,H,I](t: (A, B, C, D, E, F, G, H, I)): Tuple9W[A,B,C,D,E,F,G,H,I]

  /* 1 inherited from scalaz.Strings */
  implicit def StringTo(ss: String): scalaz.StringW

  /* 1 inherited from scalaz.Streams */
  implicit def StreamTo[A](as: Stream[A]): scalaz.StreamW[A]

  /* 1 inherited from scalaz.Shorts */
  implicit def ShortTo(n: Short): scalaz.ShortW

  /* 3 inherited from scalaz.FingerTree$Ropes */
  implicit def unwrapRope[A](wrappedRope: Ropes.this.WrappedRope[A])(implicit evidence$13: ClassManifest[A]): Ropes.this.Rope[A]
  implicit def wrapRope[A](rope: Ropes.this.Rope[A])(implicit evidence$12: ClassManifest[A]): Ropes.this.WrappedRope[A]
  implicit def wrapRopeChar(rope: Ropes.this.Rope[Char]): Ropes.this.RopeCharW

  /* 1 inherited from scalaz.Reducers */
  implicit def ReducerMonoid[C,M](r: scalaz.Reducer[C,M]): scalaz.Monoid[M]

  /* 1 inherited from scalaz.Options */
  implicit def OptionTo[A](o: Option[A]): scalaz.OptionW[A]

  /* 55 inherited from scalaz.Names */
  implicit def nameToCallable[A]: scalaz.Name[A] => java.util.concurrent.Callable[A]
  implicit def nameToConst[A,B](implicit evidence$2: scalaz.Monoid[B]): scalaz.Name[A] => scalaz.Const[B,A]
  implicit def nameToEitherLeft[A,X]: scalaz.Name[A] => Either.LeftProjection[A,X]
  implicit def nameToEitherRight[A,X]: scalaz.Name[A] => Either.RightProjection[X,A]
  implicit def nameToEndo[A]: scalaz.Name[A] => scalaz.Endo[A]
  implicit def nameToEphemeralStream[A]: scalaz.Name[A] => scalaz.EphemeralStream[A]
  implicit def nameToFirstOption[A]: scalaz.Name[A] => scalaz.FirstOption[A]
  implicit def nameToFunction0[A]: scalaz.Name[A] => () => A
  implicit def nameToFunction1[A,R]: scalaz.Name[A] => R => A
  implicit def nameToFunction2[A,R,S]: scalaz.Name[A] => (R, S) => A
  implicit def nameToFunction3[A,R,S,T]: scalaz.Name[A] => (R, S, T) => A
  implicit def nameToFunction4[A,R,S,T,U]: scalaz.Name[A] => (R, S, T, U) => A
  implicit def nameToFunction5[A,R,S,T,U,V]: scalaz.Name[A] => (R, S, T, U, V) => A
  implicit def nameToFunction6[A,R,S,T,U,V,W]: scalaz.Name[A] => (R, S, T, U, V, W) => A
  implicit def nameToIdentity[A]: scalaz.Name[A] => scalaz.Identity[A]
  implicit def nameToIterV[A,E]: scalaz.Name[A] => scalaz.IterV[E,A]
  implicit def nameToJavaArrayBlockingQueue[A]: scalaz.Name[A] => java.util.concurrent.ArrayBlockingQueue[A]
  implicit def nameToJavaArrayList[A]: scalaz.Name[A] => java.util.ArrayList[A]
  implicit def nameToJavaConcurrentLinkedQueue[A]: scalaz.Name[A] => java.util.concurrent.ConcurrentLinkedQueue[A]
  implicit def nameToJavaCopyOnWriteArrayList[A]: scalaz.Name[A] => java.util.concurrent.CopyOnWriteArrayList[A]
  implicit def nameToJavaCopyOnWriteArraySet[A]: scalaz.Name[A] => java.util.concurrent.CopyOnWriteArraySet[A]
  implicit def nameToJavaHashSet[A]: scalaz.Name[A] => java.util.HashSet[A]
  implicit def nameToJavaLinkedBlockingQueue[A]: scalaz.Name[A] => java.util.concurrent.LinkedBlockingQueue[A]
  implicit def nameToJavaLinkedHashSet[A]: scalaz.Name[A] => java.util.LinkedHashSet[A]
  implicit def nameToJavaLinkedList[A]: scalaz.Name[A] => java.util.LinkedList[A]
  implicit def nameToJavaPriorityQueue[A]: scalaz.Name[A] => java.util.PriorityQueue[A]
  implicit def nameToJavaStack[A]: scalaz.Name[A] => java.util.Stack[A]
  implicit def nameToJavaSynchronousQueue[A]: scalaz.Name[A] => java.util.concurrent.SynchronousQueue[A]
  implicit def nameToJavaTreeSet[A]: scalaz.Name[A] => java.util.TreeSet[A]
  implicit def nameToJavaVector[A]: scalaz.Name[A] => java.util.Vector[A]
  implicit def nameToLastOption[A]: scalaz.Name[A] => scalaz.LastOption[A]
  implicit def nameToLazyOption[A]: scalaz.Name[A] => scalaz.LazyOption[A]
  implicit def nameToList[A]: scalaz.Name[A] => List[A]
  implicit def nameToMapEntry[A,X](implicit evidence$3: scalaz.Zero[X]): scalaz.Name[A] => java.util.Map.Entry[X,A]
  implicit def nameToNonEmptyList[A]: scalaz.Name[A] => scalaz.NonEmptyList[A]
  implicit def nameToOption[A]: scalaz.Name[A] => Option[A]
  implicit def nameToPromise[A](implicit s: scalaz.concurrent.Strategy): scalaz.Name[A] => scalaz.concurrent.Promise[A]
  implicit def nameToResponder[A]: scalaz.Name[A] => Responder[A]
  implicit def nameToState[A,S]: scalaz.Name[A] => scalaz.State[S,A]
  implicit def nameToStream[A]: scalaz.Name[A] => Stream[A]
  implicit def nameToTree[A]: scalaz.Name[A] => scalaz.Tree[A]
  implicit def nameToTreeLoc[A]: scalaz.Name[A] => scalaz.TreeLoc[A]
  implicit def nameToTuple1[A]: scalaz.Name[A] => (A,)
  implicit def nameToTuple2[A,R](implicit evidence$5: scalaz.Zero[R]): scalaz.Name[A] => (R, A)
  implicit def nameToTuple3[A,R,S](implicit evidence$6: scalaz.Zero[R],implicit evidence$7: scalaz.Zero[S]): scalaz.Name[A] => (R, S, A)
  implicit def nameToTuple4[A,R,S,T](implicit evidence$8: scalaz.Zero[R],implicit evidence$9: scalaz.Zero[S],implicit evidence$10: scalaz.Zero[T]): scalaz.Name[A] => (R, S, T, A)
  implicit def nameToTuple5[A,R,S,T,U](implicit evidence$11: scalaz.Zero[R],implicit evidence$12: scalaz.Zero[S],implicit evidence$13: scalaz.Zero[T],implicit evidence$14: scalaz.Zero[U]): scalaz.Name[A] => (R, S, T, U, A)
  implicit def nameToTuple6[A,R,S,T,U,V](implicit evidence$15: scalaz.Zero[R],implicit evidence$16: scalaz.Zero[S],implicit evidence$17: scalaz.Zero[T],implicit evidence$18: scalaz.Zero[U],implicit evidence$19: scalaz.Zero[V]): scalaz.Name[A] => (R, S, T, U, V, A)
  implicit def nameToTuple7[A,R,S,T,U,V,W](implicit evidence$20: scalaz.Zero[R],implicit evidence$21: scalaz.Zero[S],implicit evidence$22: scalaz.Zero[T],implicit evidence$23: scalaz.Zero[U],implicit evidence$24: scalaz.Zero[V],implicit evidence$25: scalaz.Zero[W]): scalaz.Name[A] => (R, S, T, U, V, W, A)
  implicit def nameToValidation[A,X]: scalaz.Name[A] => scalaz.Validation[X,A]
  implicit def nameToValidationFailure[A,X]: scalaz.Name[A] => scalaz.FailProjection[A,X]
  implicit def nameToZipStream[A]: scalaz.Name[A] => scalaz.ZipStream[A]
  implicit def nameToZipper[A]: scalaz.Name[A] => scalaz.Zipper[A]

  implicit def nameToStateT[M[_],S,A](a: scalaz.Name[A])(implicit evidence$4: scalaz.Pure[M]): scalaz.StateT[M,S,A]
  implicit def pureName[F[_],A](a: scalaz.Name[A])(implicit p: scalaz.Pure[F]): F[A]

  /* 1 inherited from scalaz.MetricSpaces */
  implicit def levenshteins: scalaz.MetricSpace[String]

  /* 3 inherited from scalaz.MABs */
  implicit def CokleisliMAB[M[_],A,B](k: scalaz.Cokleisli[M,A,B]): scalaz.MAB[[α, β]scalaz.Cokleisli[M,α,β],A,B]
  implicit def Const2MAB[M,A,B](k: scalaz.Const2[M,A,B]): scalaz.MAB[[α, β]scalaz.Const2[M,α,β],A,B]
  implicit def KleisliMAB[M[_],A,B](k: scalaz.Kleisli[M,A,B]): scalaz.MAB[[α, β]scalaz.Kleisli[M,α,β],A,B]

  /* 1 inherited from scalaz.MABLow */
  implicit def mab[M[_,_],A,B](a: M[A,B]): scalaz.MAB[M,A,B]

  /* 29 inherited from scalaz.MAs */
  implicit def ConstMA[B,A](c: scalaz.Const[B,A]): scalaz.MA[[α]scalaz.Const[B,α],A]
  implicit def EitherLeftMA[X,A](a: Either.LeftProjection[A,X]): scalaz.MA[[α]Either.LeftProjection[α,X],A]
  implicit def EitherRightMA[X,A](a: Either.RightProjection[X,A]): scalaz.MA[[α]Either.RightProjection[X,α],A]
  implicit def FingerMA[V,A](t: scalaz.Finger[V,A]): scalaz.MA[[α]scalaz.Finger[V,α],A]
  implicit def FingerTreeMA[V,A](t: scalaz.FingerTree[V,A]): scalaz.MA[[α]scalaz.FingerTree[V,α],A]
  implicit def Function1ApplyMA[A,R](f: A => R): scalaz.MA[[α]A => α,R]
  implicit def Function2MA[R,S,A](a: (R, S) => A): scalaz.MA[[α](R, S) => α,A]
  implicit def Function3MA[R,S,T,A](a: (R, S, T) => A): scalaz.MA[[α](R, S, T) => α,A]
  implicit def Function4MA[R,S,T,U,A](a: (R, S, T, U) => A): scalaz.MA[[α](R, S, T, U) => α,A]
  implicit def Function5MA[R,S,T,U,V,A](a: (R, S, T, U, V) => A): scalaz.MA[[α](R, S, T, U, V) => α,A]
  implicit def Function6MA[R,S,T,U,V,W,A](a: (R, S, T, U, V, W) => A): scalaz.MA[[α](R, S, T, U, V, W) => α,A]
  implicit def IterVMA[A,E](v: scalaz.IterV[E,A]): scalaz.MA[[α]scalaz.IterV[E,α],A]
  implicit def KleisliMA[M[_],A,B](k: scalaz.Kleisli[M,A,B]): scalaz.MA[[α]scalaz.Kleisli[M,A,α],B]
  implicit def MapEntryMA[X,A](e: java.util.Map.Entry[X,A]): scalaz.MA[[α]java.util.Map.Entry[X,α],A]
  implicit def MemoMA[V,A](m: scalaz.Memo[A,V]): scalaz.MA[[α]scalaz.Memo[α,V],A]
  implicit def NodeMA[V,A](t: scalaz.Node[V,A]): scalaz.MA[[α]scalaz.Node[V,α],A]
  implicit def STMA[S,A](s: scalaz.effects.ST[S,A]): scalaz.MA[[α]scalaz.effects.ST[S,α],A]
  implicit def SeqMA[M[X] <: Seq[X],A](l: M[A]): scalaz.MA[M,A]
  implicit def SetMA[M[X] <: Set[X],A](s: M[A]): scalaz.MA[M,A]
  implicit def StateMA[S,A](s: scalaz.State[S,A]): scalaz.MA[[α]scalaz.State[S,α],A]
  implicit def Tuple2MA[R,A](a: (R, A)): scalaz.MA[[α](R, α),A]
  implicit def Tuple3MA[R,S,A](a: (R, S, A)): scalaz.MA[[α](R, S, α),A]
  implicit def Tuple4MA[R,S,T,A](a: (R, S, T, A)): scalaz.MA[[α](R, S, T, α),A]
  implicit def Tuple5MA[R,S,T,U,A](a: (R, S, T, U, A)): scalaz.MA[[α](R, S, T, U, α),A]
  implicit def Tuple6MA[R,S,T,U,V,A](a: (R, S, T, U, V, A)): scalaz.MA[[α](R, S, T, U, V, α),A]
  implicit def Tuple7MA[R,S,T,U,V,W,A](a: (R, S, T, U, V, W, A)): scalaz.MA[[α](R, S, T, U, V, W, α),A]
  implicit def ValidationFailureMA[A,E](f: scalaz.FailProjection[E,A]): scalaz.MA[[α]scalaz.FailProjection[α,A],E]
  implicit def ValidationMA[A,E](v: scalaz.Validation[E,A]): scalaz.MA[[α]scalaz.Validation[E,α],A]

  implicit def Function1FlipMAContravariant[A,R](f: R => A): scalaz.MAContravariant[[α]α => A,R]

  /* 2 inherited from scalaz.MAsLow */
  implicit def maContravariantImplicit[M[_],A](a: M[A]): scalaz.MAContravariant[M,A]
  implicit def maImplicit[M[_],A](a: M[A]): scalaz.MA[M,A]

  /* 1 inherited from scalaz.Longs */
  implicit def LongTo(n: Long): scalaz.LongW

  /* 1 inherited from scalaz.Lists */
  implicit def ListTo[A](as: List[A]): scalaz.ListW[A]

  /* 1 inherited from scalaz.LastLazyOptions */
  implicit def LastLazyOptionTo[A](a: scalaz.LazyOption[A]): scalaz.LastLazyOption[A]

  /* 1 inherited from scalaz.LastOptions */
  implicit def LastOptionTo[A](a: Option[A]): scalaz.LastOption[A]

  /* 1 inherited from scalaz.Ints */
  implicit def IntTo(n: Int): scalaz.IntW

  /* 1 inherited from scalaz.InputStreams */
  implicit def InputStreamTo(v: java.io.InputStream): scalaz.InputStreamW

  /* 2 inherited from scalaz.Identitys */
  implicit def mkIdentity[A](x: => A): scalaz.Identity[A]
  implicit def unMkIdentity[A](x: scalaz.Identity[A]): A

  /* 2 inherited from scalaz.Kleislis */
  implicit def kleisliBind[M[_],R](implicit b: scalaz.Bind[M]): scalaz.Bind[[x]scalaz.Kleisli[M,R,x]]
  implicit def kleisliFn[M[_],A,B](k: scalaz.Kleisli[M,A,B]): A => M[B]

  /* 2 inherited from scalaz.Function2s */
  implicit def Function2From[T1,T2,R](f: scalaz.Function2W[T1,T2,R]): (T1, T2) => R
  implicit def Function2To[T1,T2,R](f: (T1, T2) => R): scalaz.Function2W[T1,T2,R]

  /* 2 inherited from scalaz.Function1s */
  implicit def Function1From[T,R](f: scalaz.Function1W[T,R]): T => R
  implicit def Function1To[T,R](f: T => R): scalaz.Function1W[T,R]

  /* 2 inherited from scalaz.Function0s */
  implicit def Function0From[T](f: scalaz.Function0W[T]): () => T
  implicit def Function0To[T](f: () => T): scalaz.Function0W[T]

  /* 1 inherited from scalaz.FirstLazyOptions */
  implicit def LazyFirstOptionTo[A](a: scalaz.LazyOption[A]): scalaz.FirstLazyOption[A]

  /* 1 inherited from scalaz.FirstOptions */
  implicit def FirstOptionTo[A](a: Option[A]): scalaz.FirstOption[A]

  /* 1 inherited from scalaz.Extras */
  implicit def natToFunction[F[_],G[_],A](f: scalaz.~>[F,G]): F[A] => G[A]

  /* 1 inherited from scalaz.Enumerations */
  implicit def EnumerationTo[A](v: java.util.Enumeration[A]): scalaz.EnumerationW[A]

  /* 1 inherited from scalaz.Duals */
  implicit def DualTo[A](a: A): scalaz.Dual[A]

  /* 2 inherited from scalaz.Digits */
  implicit def DigitLong(d: scalaz.Digit): Long
  implicit def LongDigit(n: Long): scalaz.Digit

  /* 1 inherited from scalaz.CharSets */
  implicit def CharSetFrom(charSet: scalaz.CharSet): String

  /* 1 inherited from scalaz.Chars */
  implicit def CharTo(c: Char): scalaz.CharW

  /* 1 inherited from scalaz.Bytes */
  implicit def ByteTo(n: Byte): scalaz.ByteW

  /* 2 inherited from scalaz.Booleans */
  implicit def BooleanFrom(b: scalaz.BooleanW): Boolean
  implicit def BooleanTo(b: Boolean): scalaz.BooleanW

  /* 1 inherited from scalaz.BigInts */
  implicit def BigIntTo(n: BigInt): scalaz.BigIntW

  /* 1 inherited from scalaz.BigIntegers */
  implicit def BigIntegerTo(n: java.math.BigInteger): scalaz.BigIntegerW

  /* 1 inherited from scalaz.ArrayBytes */
  implicit def ArrayByteTo(bs: Array[Byte]): scalaz.ArrayByte

  /* 1 inherited from scalaz.Alphas */
  implicit def AlphaChar(a: scalaz.Alpha): Char

  /* 1 inherited from scalaz.concurrent.Actors */
  implicit def ActorFrom[A](a: scalaz.concurrent.Actor[A]): A => Unit
like image 134
Daniel C. Sobral Avatar answered Oct 01 '22 23:10

Daniel C. Sobral


Interesting question. Just going to take some notes for my own benefit here...

LowPriorityImplicits has implicits to

  • WrappedArray
  • various enriched classes RichBoolean, RichByte, RichChar, ...
  • WrappedString and also to unwrap it

Predef has implicits to

  • ArrayOps which returns arrays when applying the usual methods from collections
  • to StringOps and back
  • to CharSequence from indexed seq of Char or Array[Char]

Predef also has implicits that provides functionality that you would think it's not provided by the library but the language:

  • widen primitive like Byte to Short
  • box and unbox
  • tuple creation 1 -> "a" using the right arrow
  • ensuring assertions

Then there is one CanBuildFrom for String so that if you manipulate Char with map/filter/... you can get back a String, as well as one that let's you get an IndexedSeq if you started from a string.

Then finally there are implicit related to type constraints like <:<, =:=.

like image 33
huynhjl Avatar answered Oct 01 '22 21:10

huynhjl


All default implicits can be found in the scala.Predef object and scala.LowPriorityImplicits which Predef extends. All other implicits provided by Scala are in the Companion classes of the Classes they convert, which are numerous and used in just about every library.

like image 32
Neil Essy Avatar answered Oct 01 '22 21:10

Neil Essy