armanbilge/calico

Iterate on `Codec`

armanbilge opened this issue · 3 comments

trait Codec[ScalaType, DomType] {

  • error handling for failed decoding
  • flatten package structure
  • reduce footprint (?)

error handling for failed decoding

I think these Double and Int impls shouldn't exist. Just replace them by Option[Double] and Option[Int]? The other ones look ok.

flatten package structure

Do you want to put this into html.scala as well?

reduce footprint (?)

What do you mean by this, footprint of the Scala Code or of the resulting JS?

Just replace them by Option[Double] and Option[Int]?

That's an interesting idea. You think this is better than using Either for decode ?


Do you want to put this into html.scala as well?

Yes, I think the flat structure is fine. Edit: to clarify, I think it should go in the html package, not html.scala. I think we should consider splitting that file, like you did in your PR.


What do you mean by this, footprint of the Scala Code or of the resulting JS?

  • reduce API footprint: I wonder if it should be mostly private
  • reduce JS footprint: it's using far too many classes e.g. for the as-is codec. That can be one (erased) instance.

You think this is better than using Either for decode

If we've already seen all instances there is, then I think yes. That'd mean the majority of them doesn't need to express failure/non existence at all.

to clarify, I think it should go in the html package

👍

reduce API footprint
reduce JS footprint

Thanks for clarifying 👍