These are chat archives for read-write-web/chat

13th
Feb 2015
Henry Story
@bblfish
Feb 13 2015 06:38
Alex officially becomes a ScalaJS supporter: http://bertails.org/2015/02/01/scala-js-prediction
Anton Kulaga
@antonkulaga
Feb 13 2015 12:29
It's great because some time ago he was a bit skeptical
Justas Ažna
@reederz
Feb 13 2015 14:08
here's a problem: I have a pointed graph (PointedGraph[Plantain]) with a foaf profile in it. How do I make another graph out of it with a single triple changed (e.g. changing foaf givenname) ?
Henry Story
@bblfish
Feb 13 2015 14:31
I think you take the graph out of the pointed graph, remove the given triple, and then add a new one
( It may be something that would be worth having a short notation )
Justas Ažna
@reederz
Feb 13 2015 15:33
thanks. This seems to work:
  def getModifiedCopy(pg: PointedGraph[Plantain], matcher: Plantain#URI, node: Plantain#Node): PointedGraph[Plantain] = {
    val p = pg.pointer
    val trip = pg.graph.triples.map {
      case (s, p, _) if p == matcher => (s, matcher, node)
      case t                         => t
    }
    PointedGraph[Plantain](p, makeGraph(trip))
  }
Justas Ažna
@reederz
Feb 13 2015 15:44
I guess pointed graph should be wrapped into Option
Justas Ažna
@reederz
Feb 13 2015 21:18

I have this piece of code for updating foaf profiles:

  def putProfile(newGraph: PointedGraph[Plantain])(implicit ec: ExecutionContext): Future[PointedGraph[Plantain]] = {
    var os = new ByteArrayOutputStream()
    val writeTry = Plantain.ntriplesWriter.write(newGraph.graph, os, "")
    writeTry match {
      case Success(u) => {
        val profileUri = URI(newGraph.pointer.toString)
        val res = Ajax.put(profileUri.fragmentLess.toString, os.toString, headers = Map("Accept" -> "application/n-triples"))
        readResponse(profileUri, profileUri.fragmentLess)(res)
      }
      case Failure(t) => Future.failed(t)
    }
  }

Is it against Pure FP philosophy to have mutable OutputStream?

Should I even bother making this a pure function?