Skip to content

Commit

Permalink
Merge pull request #50 from ahrefs/melange3-support
Browse files Browse the repository at this point in the history
Melange v3 long-lived branch
  • Loading branch information
jchavarri authored Feb 6, 2024
2 parents 5c5dda2 + 52ba32d commit 0975b20
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- macos-latest
- ubuntu-latest
ocaml-compiler:
- 5.1.x
- 5.1.1

fail-fast: false
runs-on: ${{ matrix.system }}
Expand Down
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Unreleased

- Expose `DecodeErrorPath`, [#51](https://github.com/ahrefs/melange-atdgen-codec-runtime/pull/51)
- Migrated to Melange v3, [#50](https://github.com/ahrefs/melange-atdgen-codec-runtime/pull/50)

## 1.0.0 (2023-10-19)

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ help: ## Print this help message

.PHONY: create-switch
create-switch: ## Create opam switch
opam switch create . 5.1.0 -y --deps-only
opam switch create . 5.1.1 -y --deps-only

.PHONY: init
init: create-switch install ## Configure everything to develop this repository in local
Expand Down
2 changes: 1 addition & 1 deletion melange-atdgen-codec-runtime.opam
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ bug-reports: "https://github.com/ahrefs/melange-atdgen-codec-runtime/issues"
depends: [
"dune" {>= "3.8"}
"ocaml"
"melange" {>= "2.0.0"}
"melange" {>= "3.0.0"}
"atd"
"atdgen"
"melange-json"
Expand Down
12 changes: 8 additions & 4 deletions src/atdgen_codec_decode.ml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,10 @@ let pair decodeA decodeB json =
with_segment "1" decodeB (Array.unsafe_get source 1) )
with DecodeError msg -> raise @@ DecodeError (msg ^ "\n\tin pair/tuple2")
else
let length_str = string_of_int length in
raise
@@ DecodeError
{j|Expected array of length 2, got array of length $length|j}
{j|Expected array of length 2, got array of length $length_str|j}
else raise @@ DecodeError ("Expected array, got " ^ Js.Json.stringify json)

let tuple2 = pair
Expand All @@ -74,9 +75,10 @@ let tuple3 decodeA decodeB decodeC json =
with_segment "2" decodeC (Array.unsafe_get source 2) )
with DecodeError msg -> raise @@ DecodeError (msg ^ "\n\tin tuple3")
else
let length_str = string_of_int length in
raise
@@ DecodeError
{j|Expected array of length 3, got array of length $length|j}
{j|Expected array of length 3, got array of length $length_str|j}
else raise @@ DecodeError ("Expected array, got " ^ Js.Json.stringify json)

let tuple4 decodeA decodeB decodeC decodeD json =
Expand All @@ -91,9 +93,10 @@ let tuple4 decodeA decodeB decodeC decodeD json =
with_segment "4" decodeD (Array.unsafe_get source 3) )
with DecodeError msg -> raise @@ DecodeError (msg ^ "\n\tin tuple4")
else
let length_str = string_of_int length in
raise
@@ DecodeError
{j|Expected array of length 4, got array of length $length|j}
{j|Expected array of length 4, got array of length $length_str|j}
else raise @@ DecodeError ("Expected array, got " ^ Js.Json.stringify json)

let dict decode json =
Expand Down Expand Up @@ -156,9 +159,10 @@ let tuple1 f x =
try with_segment "0" f (Array.unsafe_get source 0)
with DecodeError msg -> raise @@ DecodeError (msg ^ "\n\tin tuple1")
else
let length_str = string_of_int length in
raise
@@ DecodeError
{j|Expected array of length 1, got array of length $length|j}
{j|Expected array of length 1, got array of length $length_str|j}
else raise @@ DecodeError ("Expected array, got " ^ Js.Json.stringify x)

let enum l json =
Expand Down
2 changes: 1 addition & 1 deletion src/dune
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
(public_name melange-atdgen-codec-runtime)
(modes melange)
(wrapped false)
(libraries melange-json)
(libraries melange.belt melange-json)
(preprocess
(pps melange.ppx)))

0 comments on commit 0975b20

Please sign in to comment.