Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7543349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:24:11+00:00 2026-05-30T08:24:11+00:00

I’m using the Yojson library and one of the constructors used is called `Bool

  • 0

I’m using the Yojson library and one of the constructors used is called `Bool (with a backtick). I’m working with OCaml source where camlp5 is used so that text surrounded by backticks is interpreted differently (e.g. the text is converted to an OCaml data structure).

The problem I’m having is that when `Bool appears in my source code, camlp5/OCaml is seeing the backtick and thinking it is the start of the quote, causing an error. How can I make sure this is interpreted as an `Bool OCaml term instead? Is there some way to temporarily turn off what campl5 does? Some kind of escape character I can use?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T08:24:12+00:00Added an answer on May 30, 2026 at 8:24 am

    Since you are using a syntax extension that overrides the behavior of backquotes, you cannot use polymorphic variants like `Bool in the same file.

    I would advise you first to change the syntax extension to use a different character than backquotes. Why not %% for example ?

    The other solution is simple, but more verbose: use two different files, one where you don’t use the syntax extension, and another one where you use the syntax extension.

    In the first file (without the syntax extension), you define a type with normal variants that are similar to the ones use in Yojson, and functions to translate from and to polymorphic variants:

    type t = 
     | Bool of ...
     | ...
    
    let to_yojson x = 
      match x with
       | Bool v -> `Bool v
       | ...
    
    let from_yojson x =
      match x with
       | `Bool v -> Bool v
       | ...
    

    This way, you can manipulate this new type in your code with the syntax extension without using backquotes, and then use the translation functions to call Yojson. There is a cost to the translation, but if it is your case, you should choose to modify the syntax extension.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am reading a book about Javascript and jQuery and using one of the
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.