ProjectSeptemberInc / freek

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

in readme mention .expand function under 'combine programs'? #27

Closed rubenpieters closed 7 years ago

rubenpieters commented 7 years ago

In this part (under 'combine programs') in the readme

  type PRG = Log :|: KVS :|: File :|: DBService.PRG
  val PRG = DSL.Make[PRG]

  // Here the type is indicated for doc but you can omit it, Scala can infer things
  def program2(id: String): Free[PRG.Cop, File] = 
    for {
      _     <- Log.debug(s"Searching for value id: $id").freek[PRG]
      name  <- KVS.Get(id).freek[PRG]
      e     <- DB.findById(id).freek[PRG]
      file  <- File.Get(e.file).freek[PRG]
      _     <- Log.debug(s"Found file:$file").freek[PRG]
    } yield (file)

shouldn't it be:

  type PRG = Log :|: KVS :|: File :|: DBService.PRG
  val PRG = DSL.Make[PRG]

  // Here the type is indicated for doc but you can omit it, Scala can infer things
  def program2(id: String): Free[PRG.Cop, File] = 
    for {
      _     <- Log.debug(s"Searching for value id: $id").freek[PRG]
      name  <- KVS.Get(id).freek[PRG]
      e     <- DB.findById(id).expand[PRG]
      file  <- File.Get(e.file).freek[PRG]
      _     <- Log.debug(s"Found file:$file").freek[PRG]
    } yield (file)

(note the line e <- DB.findById(id).expand[PRG])

In any case I think it might be interesting to mention the expand function.

mandubian commented 7 years ago

Yes I think so... Can you make a simple PR for that? Thanks

rubenpieters commented 7 years ago

The PR has been created btw ( #28 ). I also see that someone else had spotted it as well #25 .

mandubian commented 7 years ago

thanks for effort! and you're right about this PR, I had forgotten to take care of it