All Downloads are FREE. Search and download functionalities are using the official Maven repository.

axle.algebra.Vec.scala Maven / Gradle / Ivy

There is a newer version: 0.6.6
Show newest version
package axle.algebra

import scala.annotation.implicitNotFound

/**
 *
 * Vec is the Vector typeclass
 */

@implicitNotFound("Witness not found for Vec[${V}]")
trait Vec[V[_]] {

  def from[N](v: V[N]): N

  def to[N](v: V[N]): N
}

object Vec {

  final def apply[V[_]: Vec]: Vec[V] = implicitly[Vec[V]]

  type TV[N] = (N, N)

  implicit def tuple2Vec: Vec[TV] =
    new Vec[TV] {

      def from[N](v: (N, N)): N = v._1

      def to[N](v: (N, N)): N = v._2
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy