From ed7721bb7d5c87e91aaf79b2f1882dbdb4c89d92 Mon Sep 17 00:00:00 2001 From: Mark Harrah Date: Sat, 16 Apr 2011 11:24:58 -0400 Subject: [PATCH] add Types.idFun to replace Predef.identity, replace a :== overload idFun[T]: T => T instead of identity[T](t: T): T doesn't require a new class file when used as a function value replaced overloads of :== that assigned the Scoped reference on the right to the Scoped on the left with <<= scoped.identity --- util/collection/TypeFunctions.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/util/collection/TypeFunctions.scala b/util/collection/TypeFunctions.scala index 93e44154a..8f542fb99 100644 --- a/util/collection/TypeFunctions.scala +++ b/util/collection/TypeFunctions.scala @@ -14,6 +14,7 @@ trait TypeFunctions final val left = new (Id ~> P1of2[Left, Nothing]#Flip) { def apply[T](t: T) = Left(t) } final val right = new (Id ~> P1of2[Right, Nothing]#Apply) { def apply[T](t: T) = Right(t) } final val some = new (Id ~> Some) { def apply[T](t: T) = Some(t) } + final def idFun[T] = (t: T) => t def nestCon[M[_], N[_], G[_]](f: M ~> N): (M ∙ G)#l ~> (N ∙ G)#l = f.asInstanceOf[(M ∙ G)#l ~> (N ∙ G)#l] // implemented with a cast to avoid extra object+method call. castless version: