# Module strange behavior

**URL:** <https://discuss.ocaml.org/t/module-strange-behavior/10628>\
**Category:** Community\
**Tags:** module\
**Created:** [October 12, 2022, 10:55pm UTC](https://discuss.ocaml.org/t/module-strange-behavior/10628 "2022-10-12T22:55:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Doug\_Telford](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/doug_telford/32/3994_2.png) [@Doug\_Telford](https://discuss.ocaml.org/u/Doug_Telford)\
**Post date:** [October 12, 2022, 10:55pm UTC](https://discuss.ocaml.org/t/module-strange-behavior/10628/1 "2022-10-12T22:55:52Z")

</div>

I am using linux mint 21 and ocaml 4.14.0.

My utility module has the structure:  
module type UtilsMType = sig  
…  
end  
module UtilsM : UtilsMType = struct  
…  
end

My test program is:  
open Printf  
(\*  
open UtilsM  
let \_ = printf “pi’ = %f\n” pi’  
\*)  
let \_ = printf “Utils.pi’ = %f\n” (UtilsM.pi’)

When I run:  
ocamlfind ocamlopt -o test -linkpkg -package zarith UtilsM.ml testModule1.ml

I get:  
let \_ = printf “Utils.pi’ = %f\n” (UtilsM.pi’)  
Error: Unbound value UtilsM.pi’

which is not what I was expecting. On a mac m1 with ocaml 4.14.0, I get the correct printout.  
If I uncomment  
open UtilsM

then the program runs ok. If I uncomment the line  
let \_ = printf “pi’ = %f\n” pi’

then I get the unbound error for pi’. However if I add a SECOND  
open UtilsM  
statement, the program runs ok.

The module runs as expected using utop and on the mac m1. Am I missing something??

---

<div class="post-metadata">

**Author:** ![bcc32](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/bcc32/32/203_2.png) [@bcc32](https://discuss.ocaml.org/u/bcc32)\
**Post date:** [October 12, 2022, 11:40pm UTC](https://discuss.ocaml.org/t/module-strange-behavior/10628/2 "2022-10-12T23:40:29Z")

</div>

Can you use code blocks to format the code so that it’s easier to read?

It sounds like this is the contents of your UtilsM.ml file:

```ocaml
module type UtilsMType = sig
  val pi' : float
  ...
end
module UtilsM : UtilsMType = struct
...
end

```

Is that correct? If so, the “fully-qualified” module path to the value is `UtilsM.UtilsM.pi'`, not `UtilsM.pi'`. That might explain why the second `open` was necessary.

Since you mentioned macOS, it’s possible that the case-insensitive filesystem made a difference here, but I don’t have a good idea of how exactly that happened. What happens if you name the file `utilsM.ml` instead of `UtilsM.ml`?

---

<div class="post-metadata">

**Author:** ![Doug\_Telford](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/doug_telford/32/3994_2.png) [@Doug\_Telford](https://discuss.ocaml.org/u/Doug_Telford)\
**Post date:** [October 13, 2022, 2:42am UTC](https://discuss.ocaml.org/t/module-strange-behavior/10628/3 "2022-10-13T02:42:07Z")

</div>

You are correct about the contents of the UtilsM.ml file. I used the “fully-qualified” path that you mentioned, and it worked fine. Problem solved.

By the way, what is the simplest way to create code blocks for use in the forum? I looked at markdown editors and nothing seemed easy.

---

<div class="post-metadata">

**Author:** ![Leonidas](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/leonidas/32/4039_2.png) [@Leonidas](https://discuss.ocaml.org/u/Leonidas)\
**Post date:** [October 13, 2022, 9:00am UTC](https://discuss.ocaml.org/t/module-strange-behavior/10628/4 "2022-10-13T09:00:38Z")

</div>

> [@Doug\_Telford](#):
>
> By the way, what is the simplest way to create code blocks for use in the forum? I looked at markdown editors and nothing seemed easy.

Just enclose code in triple backticks, the highlighting is automatic.
