Hi, I’m using ppx_deriving to derive a show_foo for my type: type foo = A of int | B of string [@@deriving show]
Now I would like to have a show function for lists of foos, pairs of foos, etc.
Is this possible, similar to how we can derive a Show (a, b) instance from Show a, Show b in Haskell?
Perhaps this is simple but I couldn’t find any information on this. Thanks!
It’s also possible for many plugins to derive a function directly from a type, without declaring it first.
open OUnit2
let test_list_sort ctxt =
let sort = List.sort [%derive.ord: int * int] in
assert_equal ~printer:[%derive.show: (int * int) list]
[(1,1);(2,0);(3,5)] (sort [(2,0);(3,5);(1,1)])