Skip to content

Extra coders seem to be getting recognized, but their results aren't used #17

Description

@reinux

I have a couple coders for single-case unions:

let itemIDEnc (ItemID id) =
  Encode.string id
let itemIDDec : Decoder<ItemID> =
  Decode.map ItemID Decode.string

let extras =
  Extra.empty
    |> Extra.withCustom itemIDEnc itemIDDec
    |> Extra.withInt64

And I receive it fairly straightforwardly:

  let cmd = promise {
    return! Fetch.tryPost(Routes.query, q, extra = JsonCodecs.extras)
  }
  m, Cmd.OfPromise.perform
      (fun () -> cmd :?> JS.Promise<Result<QueryResult, FetchError>>) ()
      (fun r -> QueryResultReceived (TabID 1, r))

QueryResult has a couple int64s in there, so it'll complain if I don't have the withInt64 in there, but it still loses precision, and the other ItemID just takes on a raw string value, which causes an invalid access exception later on when I try to retrieve the value.

The same coders work fine on the encoder side.

What could be going on here?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions