These are chat archives for got-lambda/expression

30th
Jun 2017
Marco Zocca
@ocramz
Jun 30 2017 08:42
def parseOperationJsReply(jso:JsObject)(implicit sys : ActorSystem) = {
    def parseStatus(opsbool : Boolean) = {
      val opStatus = opsbool match {
        case false => None
        case true => {
          val errField = Try{ jso.fields("error").toString }
          val responseField = Try{ jso.fields("response") }
          if (errField != "") {Some(Error(errField))} else {Some(Response( responseField ))}
        }
     }
      if (opId == "null") {
         log().error("Dataproc.start() : OP_ID = null")
         throw new Exception("Dataproc.start() : OP_ID = null")
      }
    }
    val opId = Try{ jso.getFields("name").toString  }
    val opStatusBoolean = Try { jso.fields("done").toString.toBoolean }
  }
I miss monad transformers
logging / backtracking parsers / IO
Marco Zocca
@ocramz
Jun 30 2017 09:08
def parseOperationStatusJS(jso:JsObject) = {
     val opStatusBoolean = Try { jso.fields("done").toString.toBoolean }
     val errField = Try{ jso.fields("error").toString }
     val responseField = Try{ jso.fields("response") }
     opStatusBoolean.flatMap{ s =>
      errField.flatMap{e =>
        responseField.map{resp => {
          s match {
            case false => None
            case true => if (errField != "") {Some(Error(e))} else {Some(Response( resp ))}
         }
        }
       }
      }
    }
  }
now, if only we had do notation..
Erik Svedäng
@eriksvedang
Jun 30 2017 10:38
=)
Marco Zocca
@ocramz
Jun 30 2017 10:43
There's a syntax called "for comprehension" which sort of behaves like a do block but it's super buggy and it desugars in an unpredictable way
jolod
@jolod
Jun 30 2017 17:08
So it finally happened, two PureScript packages provide a module (Data.Graph) with the same name, but the two Data.Graph modules are quite different, and I wouldn't want to commit to which one to use. :-/