# Using Base (or other stdlib replacements) with Menhir

**URL:** <https://discuss.ocaml.org/t/using-base-or-other-stdlib-replacements-with-menhir/1257>\
**Category:** Ecosystem\
**Tags:** core, menhir\
**Created:** [December 8, 2017, 11:54pm UTC](https://discuss.ocaml.org/t/using-base-or-other-stdlib-replacements-with-menhir/1257 "2017-12-08T23:54:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Levi\_Roth](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/levi_roth/32/2268_2.png) [@Levi\_Roth](https://discuss.ocaml.org/u/Levi_Roth)\
**Post date:** [December 8, 2017, 11:54pm UTC](https://discuss.ocaml.org/t/using-base-or-other-stdlib-replacements-with-menhir/1257/1 "2017-12-08T23:54:35Z")

</div>

I’ve been using Menhir a bit recently with Jane Street’s libraries. With Core\_kernel, things work as I want them to. However, if I instead use Base, I run into the following dilemma:

1. If I `open Base` at the top of a .mly file, I can use Base throughout the code that I write. However, having `Base` opened breaks things in the generated code, because Menhir uses functions like `Printf.printf` that no longer exist. I can get around this with stuff like `module Printf = struct include Printf let fprintf = Stdio.Out_channel.fprintf`, but that’s ugly and requires manually catching the missing functions.

2. I can instead just open Base locally in the expressions where I actually want to use it, but having `let open Base in` spread around is a bit clunky, given that Base is supposed to be functioning as a standard library.

I’m curious to know if anyone else has dealt with this issue, and how they’ve solved it.

---

<div class="post-metadata">

**Author:** ![lpw25](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/lpw25/32/144_2.png) [@lpw25](https://discuss.ocaml.org/u/lpw25)\
**Post date:** [December 9, 2017, 8:10am UTC](https://discuss.ocaml.org/t/using-base-or-other-stdlib-replacements-with-menhir/1257/2 "2017-12-09T08:10:20Z")

</div>

This won’t help you directly, but I suggest raising an issue wherever Menhir tracks bugs, because generated code should always go through a uniquely named module (e.g. `MenhirRuntime`) to access the external things so that it at least gets some semblance of hygiene.

---

<div class="post-metadata">

**Author:** ![loxs](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/loxs/32/961_2.png) [@loxs](https://discuss.ocaml.org/u/loxs)\
**Post date:** [March 19, 2018, 4:08pm UTC](https://discuss.ocaml.org/t/using-base-or-other-stdlib-replacements-with-menhir/1257/3 "2018-03-19T16:08:08Z")

</div>

Is this issue already raised? According to Opam, Menhir uses an email address as a tracker, so one can’t know: [https://opam.ocaml.org/packages/menhir/](https://opam.ocaml.org/packages/menhir/)
