# Cap'N Proto Elm Implementation

**URL:** https://discourse.elm-lang.org/t/capn-proto-elm-implementation/3766
**Category:** Request Feedback
**Created:** [June 7, 2019, 4:14pm UTC](https://discourse.elm-lang.org/t/capn-proto-elm-implementation/3766 "2019-06-07T16:14:27Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![mezuzza](https://avatars.discourse-cdn.com/v4/letter/m/aca169/32.png) [@mezuzza](https://discourse.elm-lang.org/u/mezuzza)
#### Post date: [June 7, 2019, 4:14pm UTC](https://discourse.elm-lang.org/t/capn-proto-elm-implementation/3766/1 "2019-06-07T16:14:27Z")

</div>

Hey Everyone,  
I’m designing and building an Elm implementation for [Cap’N Proto](https://capnproto.org/). It’s a binary data interchange format similar to [Protocol Buffers](https://developers.google.com/protocol-buffers/), but with a few very interesting properties - the major one being a lack of a parsing step that Protobufs require.

I’ve written [a design](https://docs.google.com/document/d/12qMVyQPOWTXviFKIpjKLXgusKZ95miuRmu9AxacyGOA/edit?usp=sharing) and would love some feedback.

Understand that the API inherently has to be a little more complex than the Protobuf API as we are lazily decoding the bytes.

I don’t expect to be done with an MVP in the next month or two, but hopefully it ends up being useful to more than just me once I’m done.

---

<div class="post-metadata">

### Author: ![Warry](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/warry/32/3998_2.png) [@Warry](https://discourse.elm-lang.org/u/Warry)
#### Post date: [June 7, 2019, 6:48pm UTC](https://discourse.elm-lang.org/t/capn-proto-elm-implementation/3766/2 "2019-06-07T18:48:25Z")

</div>

Very interesting ! What’s the reason why you need to wrap the fields when generating decoder/encoder ? Is it to do updates ?

I still haven’t jumped on board with bytes yet. The fact that it’s not possible to make Bytes without a Http request and exclusion from ports makes it very impracticle to debug, but in your case you’ll need a server anyways !

---

<div class="post-metadata">

### Author: ![ianmackenzie](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/ianmackenzie/32/86_2.png) [@ianmackenzie](https://discourse.elm-lang.org/u/ianmackenzie)
#### Post date: [June 8, 2019, 11:02pm UTC](https://discourse.elm-lang.org/t/capn-proto-elm-implementation/3766/3 "2019-06-08T23:02:50Z")

</div>

Great to see someone working on this, you’ve clearly put a lot of thought into it! I think it would be useful to see a couple high level examples of use, though - perhaps something like:

- Get a `Person` Cap’n Proto message as bytes from an HTTP request, decode it and render the person as HTML
- Construct a `Person` Cap’n Proto message from an Elm record or similar, and then construct an HTTP request using it

---

<div class="post-metadata">

### Author: ![mezuzza](https://avatars.discourse-cdn.com/v4/letter/m/aca169/32.png) [@mezuzza](https://discourse.elm-lang.org/u/mezuzza)
#### Post date: [June 9, 2019, 6:54am UTC](https://discourse.elm-lang.org/t/capn-proto-elm-implementation/3766/4 "2019-06-09T06:54:16Z")

</div>

@Warry, not sure if I understand the question. Are you asking why `Capnp.Struct` exists? If so, it’s because we lazily read the bytes from the data and I want a way to hide that detail in a way that feels somewhat reasonable in Elm.

@ianmackenzie thanks for the complement. I’m looking to add a few right now. It’ll take me a few days due to my schedule (it basically requires that I implement some parts of the API code so I can provide a good example).

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/1X/50a05e53677a2c3b47776d7abd0f113eb50193a1.png) [@system](https://discourse.elm-lang.org/u/system)
#### Post date: [June 19, 2019, 6:54am UTC](https://discourse.elm-lang.org/t/capn-proto-elm-implementation/3766/5 "2019-06-19T06:54:17Z")

</div>

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
