Skip to content

Commit

Permalink
Fix all unimplementeds
Browse files Browse the repository at this point in the history
  • Loading branch information
danslapman committed Jul 28, 2024
1 parent 97a9138 commit 5bc3124
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
val scala3Version = "3.3.1"
val scala3Version = "3.3.3"

name := "shalter"
version := "0.0.7"
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala-3/tc/Representable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ trait RepresentableK[U[_[_]]] extends ApplicativeK[U]:
tabulate([A] => (rep: Rep[U, A]) => f[A](rep(left) , rep(right)))

object RepresentableK:
inline def derived[U[_[_]] <: Product]: RepresentableK[U] = deriveRepresentable
inline def derived[U[_[_]] <: Product : ApplyK]: RepresentableK[U] = deriveRepresentable

trait TraversableK[U[_[_]]] extends FunctorK[U]:
extension[F[_], G[+_], H[_]](uf: U[F])
Expand All @@ -43,4 +43,4 @@ trait Craft[U[_[_]]] extends RepresentableK[U] with TraversableK[U]:
craft[G, H]([A] => (frep: Rep[U, A]) => f(frep(uf)))

object Craft:
inline def derived[U[f[_]] <: Product]: Craft[U] = deriveCraft
inline def derived[U[f[_]] <: Product: ApplyK]: Craft[U] = deriveCraft
12 changes: 7 additions & 5 deletions src/main/scala-3/tc/derived/craft.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ package tc.derived
import tc.*
import cats.*
import cats.data.Tuple2K
import cats.tagless.ApplyK
import cats.tagless.syntax.all.*
import cats.syntax.all.*
import hkd.*

import scala.compiletime.*
import scala.deriving.*

inline def deriveCraft[U[f[_]] <: Product]: Craft[U] =
inline def deriveCraft[U[f[_]] <: Product: ApplyK]: Craft[U] =
val pack = craftPack[U].toArray
new Craft[U] {
def craft[F[+_]: Applicative, G[_]](gain: [A] => Rep[U, A] => F[G[A]]): F[U[G]] = summonFrom {
Expand All @@ -30,9 +32,9 @@ inline def deriveCraft[U[f[_]] <: Product]: Craft[U] =
case _ => error("can handle only case classes at the moment")
}

override def productK[F[_], G[_]](af: U[F], ag: U[G]): U[[Z] =>> Tuple2K[F, G, Z]] = ???
override def productK[F[_], G[_]](af: U[F], ag: U[G]): U[[Z] =>> Tuple2K[F, G, Z]] = af.productK(ag)

override def mapK[F[_], G[_]](af: U[F])(fk: F ~> G): U[G] = ???
override def mapK[F[_], G[_]](af: U[F])(fk: F ~> G): U[G] = af.mapK(fk)
}


Expand Down Expand Up @@ -76,9 +78,9 @@ given monoCraft[X]: Craft[[F[_]] =>> F[X]] with

//def craft[F[+_] : Applicative, G[_]](gain: [A] => Rep[[F] =>> F[X], A] => F[G[A]]): F[G[X]] = ???

def productK[F[_], G[_]](af: F[X], ag: G[X]): Tuple2K[F, G, X] = ???
def productK[F[_], G[_]](af: F[X], ag: G[X]): Tuple2K[F, G, X] = Tuple2K(af, ag)

def mapK[F[_], G[_]](af: F[X])(fk: F ~> G): G[X] = ???
def mapK[F[_], G[_]](af: F[X])(fk: F ~> G): G[X] = fk.apply(af)



12 changes: 7 additions & 5 deletions src/main/scala-3/tc/derived/representable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ package tc.derived

import cats.arrow.FunctionK
import cats.data.Tuple2K
import cats.tagless.ApplyK
import cats.tagless.syntax.all.*
import tc.*
import hkd.*

import scala.compiletime.*
import scala.deriving.*

inline def deriveRepresentable[U[_[_]] <: Product]: RepresentableK[U] =
inline def deriveRepresentable[U[_[_]] <: Product : ApplyK]: RepresentableK[U] =
val pack = repPack[U].toArray
new RepresentableK[U] {
def tabulate[F[_]](gain: [A] => Rep[U, A] => F[A]) = summonFrom {
Expand All @@ -25,9 +27,9 @@ inline def deriveRepresentable[U[_[_]] <: Product]: RepresentableK[U] =
case _ => error("can handle only case classes at the moment")
}

def mapK[F[_], G[_]](af: U[F])(fk: FunctionK[F, G]): U[G] = ???
override def mapK[F[_], G[_]](af: U[F])(fk: FunctionK[F, G]): U[G] = af.mapK(fk)

override def productK[F[_], G[_]](af: U[F], ag: U[G]): U[[Z] =>> Tuple2K[F, G, Z]] = ???
override def productK[F[_], G[_]](af: U[F], ag: U[G]): U[[Z] =>> Tuple2K[F, G, Z]] = af.productK(ag)
}


Expand Down Expand Up @@ -70,6 +72,6 @@ given monoRepresentable[X]: RepresentableK[[F[_]] =>> F[X]] with
def tabulate[G[_]](gain: [A] => ([F[_]] => F[X] => F[A]) => G[A]): G[X] =
gain([G[_]] => (x: G[X]) => x)

def mapK[F[_], G[_]](af: F[X])(fk: FunctionK[F, G]): G[X] = ???
def mapK[F[_], G[_]](af: F[X])(fk: FunctionK[F, G]): G[X] = fk.apply(af)

def productK[F[_], G[_]](af: F[X], ag: G[X]): Tuple2K[F, G, X] = ???
def productK[F[_], G[_]](af: F[X], ag: G[X]): Tuple2K[F, G, X] = Tuple2K(af, ag)

0 comments on commit 5bc3124

Please sign in to comment.