title: How do I declare a scala case class to be an instance of Scalaz's Semigroup?
body: <p>I have a type, defined as follows:</p>
  
  <pre><code>import scalaz._, Scalaz._
  case class MyInt(i : Int)
  </code></pre>
  
  <p>I want to make an instance of <code>Semigroup</code>. I tried this:</p>
  
  <pre><code>object MyInt {
    implicit def myIntSemigroup: Semigroup[MyInt] = new Semigroup[MyInt] {                                                                                                                                                                       
      def append(a: MyInt, b: MyInt) : MyInt = MyInt(a.i + b.i)
    }
  }
  </code></pre>
  
  <p>When I run <code>sbt console</code>, I get this error:</p>
  
  <pre><code>[info] Set current project to hello (in build file:/home/mp/code/scala/examples/semigroup/)
  [info] Compiling 1 Scala source to /home/mp/code/scala/examples/semigroup/target/scala-2.10/classes...
  [error] /home/mp/code/scala/examples/semigroup/src/main/scala/Main.scala:6: object creation impossible, since method append in trait Semigroup of type (f1: MyInt, f2: =&gt; MyInt)MyInt is not defined
  [error]   implicit def myIntSemigroup: Semigroup[MyInt] = new Semigroup[MyInt] {                                                                                                                                                               
  [error]                                                       ^   
  [error] one error found
  [error] (compile:compile) Compilation failed
  [error] Total time: 5 s, completed 25-Jun-2015 08:15:37
  </code></pre>
  
  <p>How do I make <code>MyInt</code> a <code>Semigroup</code> so I can use <code>|+|</code> on it?</p>
  
  <p>For completeness, here is my <code>build.sbt</code> file:</p>
  
  <pre><code>name := "hello"
  version := "1.0"
  scalaVersion := "2.10.5"
  libraryDependencies += "org.scalaz" %% "scalaz-core" % "7.1.3"
  </code></pre>