ProjectSeptemberInc / freek

Freek, a freaky simple Free to combine your DSL seamlessly
Other
198 stars 19 forks source link

A snippet that stopped compiling when updated 0.4.1 -> 0.4.3 #8

Open marcin-rzeznicki opened 8 years ago

marcin-rzeznicki commented 8 years ago

I think that this is how it is done in documentation BTW, so you might want to update docs to reflect incompatibilites between 0.4.1 and 0.4.3 (unless I'm doing something wrong).

Under 0.4.1 this code compiles fine:

import cats.free.Free
import freek._

sealed trait DSL[R]
case class Get(key: String) extends DSL[Option[Int]]
case class Put(key: String, value: Int) extends DSL[Int]

sealed trait Event[A]
case class GetSucceeded(key: String, found: Int) extends Event[Unit]
case class GetFailed(key: String) extends Event[Unit]

type Program = DSL :|: Event :|: FXNil
type Action[A] = Free[Program#Cop, A]

def get(key: String): Action[Option[Int]] = Get(key).freek[Program]

Under 0.4.3 the same code does not compile with error

Error:(15, 60) polymorphic expression cannot be instantiated to expected type;
 found   : [A]cats.free.Free[subfx.Cop,Option[Int]]
 required: A$A34.this.Action[Option[Int]]
(which expands to)  cats.free.Free[[t]freek.ConsK[A$A34.this.DSL,[t]freek.ConsK[A$A34.this.Event,[t]freek.CNilK[t],t],t],Option[Int]]
def get(key: String): Action[Option[Int]] = Get(key).freek[Program]
                                                          ^
mandubian commented 8 years ago

Have you tried on recent versions, that should work (with minor syntax evolutions)

Sorry for not answering, github never notified me on those issues :)