scalaz/scalaz — pull request #257 by eed3si9n (2013-01-18 09:55:46+00:00)
Title: remove inheritance from HListFunc to Func

Refactors HListFunc to be a stand-alone trait by moving type parameter `T < TCList` to type variable `L`.

This allows "HNilFunc" and "HConsFunc" to have common trait so they can be folded from a `List[Int]`. See the tests:

```scala
"traverse" in {
val test = List(1, 2, 3).:\(AppFunc.HNil[Int, Int]) ({ (n, acc) =>
AppFuncU { (x: Int) => (Some(x + n): Option[Int]) } :: acc })
val result = test traverse List(1, 2)
result match {
case x :: y :: z :: HNil =>
(x must_== Some(List(2, 3))) and
(y must_== Some(List(3, 4))) and
(z must_== Some(List(4, 5)))
}
}
```

I discovered that the above was not possible with the old implementation when I implemented [sudoku solver](http://eed3si9n.com/sudoku-using-func):

```scala
scala> emptyCells.foldLeft[HListFunc[TCList, Applicative, Cell, List[Vector[Int]]]](AppFunc.HNil[Cell, List[Vector[Int]]]) { (acc, cell) => Solver.cellMachine(cell.pos, game.sqrtn) :: acc }
:22: error: type mismatch;
found : scalaz.typelevel.HListFunc[scalaz.typelevel.TCNil,scalaz.Applicative,com.eed3si9n.sudoku.Cell,List[Vector[Int]]]
required: scalaz.typelevel.HListFunc[scalaz.typelevel.TCList,scalaz.Applicative,com.eed3si9n.sudoku.Cell,List[Vector[Int]]]
Note: scalaz.typelevel.TCNil <: scalaz.typelevel.TCList, but trait HListFunc is invariant in type T.
You may wish to define T as +T instead. (SLS 4.5)
emptyCells.foldLeft[HListFunc[TCList, Applicative, Cell, List[Vector[Int]]]](AppFunc.HNil[Cell, List[Vector[Int]]]) { (acc, cell) => Solver.cellMachine(cell.pos, game.sqrtn) :: acc }
^
```