33 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
0
votes
1
answer
51
views
Metaquot: recognize a list pattern and store the resulting list
I have the following attribute attached to nodes [@profiling.mark [ "label1"; "label2"; "label3" ]] which gives me this AST:
[{attr_name = {txt = "profiling.mark&...
Lhooq's user avatar
- 4,461
0
votes
1
answer
80
views
Metaquot examples or documentation to generate code
I'm trying to write simple rewriters with ppxlib to get an idea of how to do more complex things.
I'm currently struggling with metaquot. The documenation I found is this one but it just touches the ...
Lhooq's user avatar
- 4,461
0
votes
2
answers
236
views
Why can't dune recognize ppx_jane?
I am now writing a project in OCaml v4.06, and I have installed ppx_jane v0.11.0. Actually the environment is based on a docker image.
Now here is the dune file
(menhir
(modules parser))
(ocamllex ...
5
votes
2
answers
177
views
Is this possible to create an operator that evaluates argument left-to-right in OCaml
When you define an operator such as
let (++) a b = a :: b
When you do
let v = foo a ++ bar b
bar is evaluated before foo.
A workaround is to use let expression, i.e.
let e1 = foo a in let e2 = bar ...
5
votes
1
answer
120
views
How to handle different OCaml versions when generating AST with ppxlib
I am making a ppx extension rewriter as part of a code library
Ideally the library will be usable with some range of OCaml versions
I have noticed that when building AST nodes to output from my ...
1
vote
1
answer
106
views
How do I output a non-polymorphic variant using ppxlib Ast_builder?
I am trying to make a PPX extension rewriter that dynamically builds (among other things) a variant type, based on some config in a JSON file...
I have got reasonably far but I am confused whether it ...
1
vote
0
answers
85
views
OCaml variant augmentation boilerplates
Is there a way to efficiently "augment" or attach some more information without much boilerplate?
That is, given types
type orig =
| A
| B of orig
| C of orig * orig
and type dat = int
...
0
votes
2
answers
184
views
How official / stable is the whole 'ppx' mechanic in Ocaml language? [closed]
For context (skip to question if you like): I am learning ocaml and started reading the Real World Ocaml.
So far, really (really!) liking the language and the book.
One thing I'm starting to not like ...
Kris's user avatar
- 4,007
4
votes
0
answers
96
views
Incomplete expression in ppx extension
I want to try to write my own ppx to allow named arguments in formatting strings:
From Format.printf [%fmt "!(abc) !(qsd)"] to Format.printf "%s %s" abc qsd
When dumping with ...
Lhooq's user avatar
- 4,461
1
vote
1
answer
231
views
How to force ppx to use an OCaml version?
I have the below OCaml file which compiles correctly without ppx and fails with this dune file
(library
(name so_proj)
(preprocess
(pps
ppx_inline_test
ppx_deriving.show
ppx_deriving.ord
...
nicolas's user avatar
- 9,855
0
votes
2
answers
1k
views
How to apply [@@deriving show] to a type from module parameter of my functor?
I have a functor that takes a Set type like:
module type MySet = functor (S : Set.S) -> sig
val my_method : S.t -> S.elt -> S.elt list option
end
module MySet_Make : MySet = functor (S : ...
2
votes
1
answer
722
views
How to use ppx derive in utop?
How can I use ppx derive (https://github.com/ocaml-ppx/ppx_deriving) in my utop?
For example, I have to following code:
module A = struct
module T = struct
type t = int [@@deriving hash, sexp, ...
0
votes
2
answers
621
views
OCaml serializing a (no args) variant as a "string enum" (via Yojson)
Say I am building a record type:
type thing {
fruit: string;
}
But I want the possible values of fruit to be constrained to a fixed set of strings.
It seems natural to model this in OCaml as a ...
1
vote
1
answer
76
views
OCaml - Access Derived Functions from Another Module
If a record is defined in a module in lib and it contains a deriving annotation that generates functions, how can those functions be used in another module?
For example, the yaml/ppx_deriving_yaml ...
Greg's user avatar
- 3,169
3
votes
1
answer
851
views
How to write custom ppx decorator to rescript?
I need to generate a value with a different type from my passed type. This is the first time I write on ocaml-like, and for example, in a familiar me haskell I would use Data.Generics.
How I have ...