Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 26 2019 21:07
    scala-steward synchronize #139
  • Jan 26 2019 14:33

    mpilquist on v1.11.0

    (compare)

  • Jan 26 2019 14:32

    mpilquist on 1.11.x

    Setting version to 1.11.0 Updated version to 1.11.1-SNAPS… (compare)

  • Jan 25 2019 10:28
    billpcs starred scodec/scodec
  • Jan 22 2019 22:01
    benhanna starred scodec/scodec
  • Jan 21 2019 20:36
    scala-steward opened #139
  • Jan 21 2019 14:51
    mpilquist closed #130
  • Jan 21 2019 14:48
    mpilquist closed #119
  • Jan 21 2019 14:48
    mpilquist commented #119
  • Jan 21 2019 14:48

    mpilquist on 1.11.x

    Scala 2.13.0-M4 Merge branch 'series/1.10.x' in… Upgraded to latest scala-collec… and 2 more (compare)

  • Jan 21 2019 14:48
    mpilquist closed #138
  • Jan 21 2019 14:40
    mpilquist opened #138
  • Jan 21 2019 14:37

    mpilquist on 1.11.x

    Created 1.11 branch (compare)

  • Jan 21 2019 14:31

    mpilquist on xuwei-k

    Upgraded to 2.13.0-M5 (compare)

  • Jan 21 2019 14:19

    mpilquist on xuwei-k

    Scala 2.13.0-M4 Merge branch 'series/1.10.x' in… Upgraded to latest scala-collec… (compare)

  • Jan 21 2019 14:03

    mpilquist on 1.10.x

    Update sbt-scalajs, scalajs-com… Merge pull request #129 from sc… (compare)

  • Jan 21 2019 14:03
    mpilquist closed #129
  • Jan 21 2019 14:03
    mpilquist closed #126
  • Jan 21 2019 14:03

    mpilquist on 1.10.x

    Pad-left on pbcd codec. Fixes #… Using padLeft in pbcd instead o… Merge pull request #133 from lJ… (compare)

  • Jan 21 2019 14:03
    mpilquist closed #133
Gabor Dorcsinecz
@gabor-dorcsinecz
Why didn't I think of this :-) Thank you!
Alex Michael Berry
@almibe
Does anyone have any best practices for implementing Ordering for ByteVectors? I'm trying to store ByteVectors in a SortedMap.
Soren
@srnb_gitlab
You can write an Ordering that takes both bytevectors, gets an Iterable from them, and uses the Ordering for Iterables
Michael Pilquist
@mpilquist
There’s a PR open now that adds Ordered for Bit/ByteVector
Alex Michael Berry
@almibe
Okay nice, I'll check out that PR. Thanks both of you.
Alex Michael Berry
@almibe
That seems to work for now. Hopefully it'll get in the next release.
Although I can see the issue with trying to sort ByteVectors. In my case lexicographical ordering is what I want....not sure if that should be the default. For some context I'm trying to mimic what Xodus, RocksDB, FoundationDB, etc. do but with an in-memory model.
Alex Michael Berry
@almibe
Potentially off topic but does anyone have any favorite ways to debug code that does binary encoding/decoding? I can usually use testing frameworks + printlns to figure stuff out but I have a feeling for my current project I'm going to have to make a one off Swing/JavaFX app to help. Just wondering what other people do.
Soren
@srnb_gitlab
I usually am building codecs for formats that other tools generate and whenever I don't get expected behavior I compare my output to what the other tools generate
Lucas Satabin
@satabin
the logToStdOut codec operator is also quite handy when trying to understand exactly where it fails
Alex Michael Berry
@almibe
Thanks logToStdOut sounds useful. In my case I got bit by the old Byte + Byte = Int conversion.
Soren
@srnb_gitlab
@almibe One of the options in sbt-tpolecat will throw a warning on "implicit numeric widening" (which is what you experienced)
I do not remember which
Alex Michael Berry
@almibe
Okay thanks, looking into that plugin and the warnings from tpolecat's blog entries have been on my Scala TODO list, guess I should look into those sooner rather than later. Looks like "-Ywarn-numeric-widen" is what you were mentioning.
Damien O'Reilly
@DamienOReilly

Hi, just for fun and learning, I decided to try solve https://challenge.synacor.com/ (more info https://0bin.net/paste/OSEoQufPgve59sIf#FUukdNbypvDb6XWIFZd+96-3aXeenQ8/thDf4QcsTxp) using Scala, and though scodec would be good to parse the binary file into an instruction-set within my program. I am not sure I am going about decoding the raw byte array in the correct manner. For example some instructions contain pointers, or other data, while other instructions only one 16bit opcode which indicates what to do e.g. HALT, NOOP etc... Therefore I am using case classes and objects as an ADT to model this.

  sealed trait Instruction
  case object Halt extends Instruction
  case class Out(char: Char) extends Instruction
  case class In(char: Char) extends Instruction
  case object Noop extends Instruction

  private val inCodec: Codec[In] = uint16L.as[In]
  private val outCodec: Codec[Out] = uint16L.as[Out]

  private val instructionsCodec: Codec[Instruction] = discriminated[Instruction]
    .by(uint16L)
    .typecase[Out](19, outCodec)
    .typecase[In](20, inCodec)

However I cannot use .typecase with the case objects. Is there any pointers how I should go about this?

Damien O'Reilly
@DamienOReilly
.typecase(21, provide(Noop)) seems to do the trick
Christopher Davenport
@ChristopherDavenport
So... indexOfSlice is quite the gotcha. I think, I assume if I was using scodec proper it does less backtracking. I realized the hard way how often I was iterating over bytevectors byte by byte.
Christopher Davenport
@ChristopherDavenport
@mpilquist Is there any easier way other than me building custom state machines iterating index in this regard?
Alex Michael Berry
@almibe
Is there a good way to override how Codec.encode handles Options when passed a case class? I want it to output nothing if the Option is None and to just output the actual value if it is a Some. I'll never have to decode the resulting value.
1 reply
Artem Nikiforov
@nikiforo

scodec/scodec-stream#74

I've also run scalafmt on projects to pass some CI checks.

Himanshu Gupta
@gupta-himanshu
Is there a migration guide for scodec-core v1.11.4 to v1.11.7?
I need an alternative for Codec.encode().
It was removed in v1.11.5.
Himanshu Gupta
@gupta-himanshu
Found the solution.
Nevermind
:)
Billzabob
@Billzabob
There isn't a ScalaJS 0.6 build for scodec-bits 1.1.19 or 1.1.20. Is there going to be or is support for 0.6 dropped?
Michael Pilquist
@mpilquist
Dropped support now that 0.6 is EOL
Billzabob
@Billzabob
:thumbsup:
cranst0n
@cranst0n
I'm running into an Insufficient number of elements error from a listOfN decoder when using a StreamDecoder on a file. However, if I bump up the chunkSize passed to fs2.io.file.readAll enough (~8MB), then the error seems to go away. Is this behavior expected?
cranst0n
@cranst0n
I think I solved this issue by using a StreamDecoder.isolate in the middle of my decoder to ensure enough data is available to parse the messages I'm working with. I guess my mental model wasn't expecting to need to do that but adjustment made.
Michael Pilquist
@mpilquist
@cranst0n Do you need a release of scodec-core with that fix? I thought I saw a request somewhere but can’t find it now
Lucas Satabin
@satabin
@mpilquist do you mean, this one: scodec/scodec-stream#58
?
cranst0n
@cranst0n
@mpilquist Sorry for not seeing this before. Yes a scodec-core release would be greatly appreciated. A scodec-stream release would also be great with the inclusion of the fix to choice decoder.
Michael Pilquist
@mpilquist
Okay cool, I’ll try to get those done this weekend
elyphas
@elyphas
Hi, is it possible to do something like in shapeless's record:
val updated = book + ("price" ->> (currentPrice+2.0))
with scodec?
I am reading about scodec, but many things in scodec are new for me,
by the way I tried shapeless super cool, but too much advance for me, at this moment, :)
I want to get the value from a field from a case class using the field's name and make some operations over it, and update the case class.
elyphas
@elyphas
I have to use the field's name because I don't know in advance what field I am going to use for the operation.
At this moment I am using Map[String, Any].
Paul Snively
@paul-snively
You want a lens-building function that implicitly takes a MkFieldLens for the Witness.Lt[Symbol] that needs to be your “field name” argument.
elyphas
@elyphas
@paul-snively , thank you.
@paul-snively , is shapeless, am I right?
Paul Snively
@paul-snively
Yes.
But keep in mind that when you say “don’t know in advance,” that might mean “polymorphic function” or might mean “runtime reflection.” It means the latter if, e.g. the field name is not known until runtime.
But as you already indicated, a case class is the wrong type to use for that case.
elyphas
@elyphas

@paul-snively ;

“don’t know in advance,” that might mean “polymorphic function”

ah

@paul-snively , thank you,
Antonio Gelameris
@toniogela_twitter
Hi guys, can I kindly ask you which is the best resource to begin using scodec? I saw a couple of Micheal talks online and the underlying machinery is pretty clear to me and I took a look at the guide here: http://scodec.org/guide/ but I was wandering whether some more complete resources exist