Hey guys,
I've updated the 
doc<https://docs.google.com/document/d/12qMVyQPOWTXviFKIpjKLXgusKZ95miuRmu9AxacyGOA/edit?usp=sharing>
 with a new write API suggestion. The gist is that writes never happen to the 
byte array. Instead, we build a virtual proto on top of the byte array that's 
accessed first for any modifications. It's built using `Maybe` all the way 
down. `Nothing` implies that there are no changes from the byte array. When you 
transmit/convert it into bytes, the framework performs a "merge" operation 
before sending over the wire. We will also provide this merge operation to 
advanced users who wish to manually do this compaction at some points.

This is clearly complicated and worrying, but it's the best API for inplace 
writes over immutable data that I could think of. There are alternatives, but I 
wasn't too fond of them. You can read about a few that I thought of in the doc.

As for random-access on gets, it seems that we can use the 
bytes<https://package.elm-lang.org/packages/elm/bytes/latest/Bytes-Decode#bytes>
 function. Its 
implementation<https://github.com/elm/bytes/blob/master/src/Elm/Kernel/Bytes.js#L149>
 simply creates a new DataView and updates the index, so it should be a 
constant time operation. No changes to elm/bytes required 😂

There are also a few small details around the types that have changed in order 
to support the write operations. They've become more complex, but I'm going to 
live with that for now and see if I can reduce their complexity later.

I'm publishing this doc to Elm discourse soon to get feedback from the Elm side 
of things as well. Thanks again for all the feedback; It's been super helpful.

--Prasanth

________________________________
From: capnproto@googlegroups.com <capnproto@googlegroups.com> on behalf of 
Prasanth Somasundar <mezu...@live.com>
Sent: Saturday, June 1, 2019 11:48 PM
To: Ian Denhardt; 'Kenton Varda' via Cap'n Proto; David Renshaw; Kenton Varda
Subject: RE: [capnproto] Cap'n Proto for Elm

> I like this
Cool

> I toyed at one point with the idea of having the code generator automatically 
> chop off as many layers of nesting as it could without causing collisions, 
> though that's a bit more complicated to implement.

I thought about this myself, but the biggest issue I have with it isn't the 
technical challenge, but the UX challenge. This would mean that if you ever 
added the wrong name to a schema file, you could end up changing most if not 
all of the names in the file. That sounds really rough to impose and is 
basically a showstopper for me.

--Prasanth

-----Original Message-----
From: Ian Denhardt <i...@zenhack.net>
Sent: Saturday, June 1, 2019 8:25 PM
To: 'Kenton Varda' via Cap'n Proto <capnproto@googlegroups.com>; David Renshaw 
<dwrens...@gmail.com>; Kenton Varda <ken...@cloudflare.com>; Prasanth 
Somasundar <mezu...@live.com>; Prasanth Somasundar <mezu...@live.com>
Subject: RE: [capnproto] Cap'n Proto for Elm

Quoting Prasanth Somasundar (2019-06-01 23:12:20)

> What about just dumping everything into the same module, but without
> the prefixed namespace for every value/type/type constructor. The
> reason that we're prefixing everything with underscores is to avoid
> name collisions, but we can simply error on those while still giving
> users `$Elm.overrideName` to allow a user to manually resolve
> collisions.

I like this, though I might suggest still prefixing data constructors (at least 
with the type name, not necessarily the whole path), as it's pretty common to 
have overlapping names for union members, which would cause reasonably frequent 
conflicts.  I've found having *one* level of name spacing like this for the 
Haskell implementation isn't too bad.

I toyed at one point with the idea of having the code generator automatically 
chop off as many layers of nesting as it could without causing collisions, 
though that's a bit more complicated to implement.

-Ian

--
You received this message because you are subscribed to the Google Groups 
"Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to capnproto+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/capnproto.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/capnproto/BYAPR11MB259904C8B85E0B51169A7816C51B0%40BYAPR11MB2599.namprd11.prod.outlook.com.

-- 
You received this message because you are subscribed to the Google Groups 
"Cap'n Proto" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to capnproto+unsubscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/capnproto.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/capnproto/BYAPR11MB25997E49486C9F5F7622CCAAC5100%40BYAPR11MB2599.namprd11.prod.outlook.com.

Reply via email to