Skip to content

Commit

Permalink
Merge pull request #20 from benhutchison/master
Browse files Browse the repository at this point in the history
	 Change type tags to a trait
  • Loading branch information
milessabin committed Feb 21, 2013
2 parents 54e138d + 1ce29c9 commit defe6fc
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/src/main/scala/shapeless/typeoperators.scala
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ object TypeOperators {
type [P[_]] = ¬[[({ type λ[X] = ¬[P[X]]})#λ]]

// Tags
type Tagged[U] = { type Tag = U }
trait Tagged[U]
type @@[T, U] = T with Tagged[U]

class Tagger[U] {
Expand Down
40 changes: 40 additions & 0 deletions core/src/test/scala/shapeless/typeoperators.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2011 Miles Sabin
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package shapeless

import TypeOperators._

class TypeOperatorTests {
import org.junit.Test
import org.junit.Assert._


@Test
def testImplicitScopeForTaggedType {
val x = tag[ATag](1)
val s: String = x
assertEquals(ATag.message, s)
}
}

trait ATag
object ATag {

val message = "This object has ATag tag type"

implicit def taggedToString[T](value: T with Tagged[ATag]): String = message
}

0 comments on commit defe6fc

Please sign in to comment.