# \[ANN\] Ppx\_untype: An end to type errors in OCaml

**URL:** https://discuss.ocaml.org/t/ann-ppx-untype-an-end-to-type-errors-in-ocaml/16410
**Category:** Community
**Created:** [April 1, 2025, 2:07pm UTC](https://discuss.ocaml.org/t/ann-ppx-untype-an-end-to-type-errors-in-ocaml/16410 "2025-04-01T14:07:24Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![panglesd](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/panglesd/32/3931_2.png) [@panglesd](https://discuss.ocaml.org/u/panglesd)
#### Post date: [April 1, 2025, 2:07pm UTC](https://discuss.ocaml.org/t/ann-ppx-untype-an-end-to-type-errors-in-ocaml/16410/1 "2025-04-01T14:07:24Z")

</div>

Hello dear people reading this!

Today, I am overly excited to announce one of the greatest and simplest tool, that will fix the biggest of all OCaml flaws.

Consider Javascript:

```auto
$ node
Welcome to Node.js v22.14.0.
Type ".help" for more information.
> 1 + 3.5
4.5

```

Simple and elegant, don’t we all agree?

Now, the same with OCaml:

```auto
$ ocaml
OCaml version 5.3.0
Enter #help;; for help.
# 1 + 3.5 ;;
Error: The constant 3.5 has type float but an expression was expected of type
         int

```

What does this even mean?

* * *

The PPX that I lovingly share with you all is `ppx_untype`. It finally fully removes the OCaml type system that has plagued it since its inception.

The PPX can be used very simply. Add it to your opam switch:

```auto
$ opam pin add ppx_untype https://github.com/panglesd/ppx_untype.git\#main

```

and then add it to your `dune` (or other build system) file:

```auto
(...
 (preprocess (pps ppx_untype))
 ...)

```

And you can now enjoy OCaml!

```auto
$ cat bin.main.ml
let () = print_float (1 + 3.5)
$ dune exec bin/main.exe
3.47922429887e-310

```

### Pros:

- All programs that was working before, still works.
- Blazingly fast!
- Finally integers and floats can be added.
- All warnings are also removed.

### Cons:

- None (apart from some unexpected behaviour at runtime)

---

<div class="post-metadata">

### Author: ![octachron](https://avatars.discourse-cdn.com/v4/letter/o/49beb7/32.png) [@octachron](https://discuss.ocaml.org/u/octachron)
#### Post date: [April 1, 2025, 2:27pm UTC](https://discuss.ocaml.org/t/ann-ppx-untype-an-end-to-type-errors-in-ocaml/16410/2 "2025-04-01T14:27:26Z")

</div>

I see that a cheat engine for roguetype has been published on the very first day of the release!

---

<div class="post-metadata">

### Author: ![SebHash](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/sebhash/32/4882_2.png) [@SebHash](https://discuss.ocaml.org/u/SebHash)
#### Post date: [April 1, 2025, 2:29pm UTC](https://discuss.ocaml.org/t/ann-ppx-untype-an-end-to-type-errors-in-ocaml/16410/3 "2025-04-01T14:29:48Z")

</div>

Thank you, this looks lovely!

Once this has been proved useful, and although I do not see how this  
could be not happening, I would like to encourage you to go one step  
further in this direction by opening a PR to the compiler itself to  
basically get rid of its `typiing/` subdirectory, which will, by your  
magic, contain only dead code.

How many headaches will we save…

---

<div class="post-metadata">

### Author: ![dbuenzli](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dbuenzli/32/18_2.png) [@dbuenzli](https://discuss.ocaml.org/u/dbuenzli)
#### Post date: [April 1, 2025, 2:44pm UTC](https://discuss.ocaml.org/t/ann-ppx-untype-an-end-to-type-errors-in-ocaml/16410/4 "2025-04-01T14:44:02Z")

</div>

Very nice! I often use the `ocaml` REPL as a calculator.

It’s totally improductive because of the number of type errors I make but remains faster than using a calculator app with hidden state or another language that is not as hardwired in my brain as OCaml is.

So I actually contemplated more than once adding a [`Down.calculator ()`](https://erratique.ch/software/down) mode that would do exactly that:

1. Redefine integer operators to work on floats (easy)
2. Transforms integer literals into floating point ones (unclear).

Just never got the time to get to it yet. No joke. (PR’s welcome as they say)

:–)

---

<div class="post-metadata">

### Author: ![dinosaure](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dinosaure/32/16_2.png) [@dinosaure](https://discuss.ocaml.org/u/dinosaure)
#### Post date: [April 1, 2025, 3:11pm UTC](https://discuss.ocaml.org/t/ann-ppx-untype-an-end-to-type-errors-in-ocaml/16410/5 "2025-04-01T15:11:14Z")

</div>

> [@dbuenzli](#):
>
> Very nice! I often use the `ocaml` REPL as a calculator.

`bc` is old but it still a good friend for that (in my opinion).

---

<div class="post-metadata">

### Author: ![dbuenzli](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dbuenzli/32/18_2.png) [@dbuenzli](https://discuss.ocaml.org/u/dbuenzli)
#### Post date: [April 1, 2025, 3:14pm UTC](https://discuss.ocaml.org/t/ann-ppx-untype-an-end-to-type-errors-in-ocaml/16410/6 "2025-04-01T15:14:51Z")

</div>

`bc` has not `let` 😱

---

<div class="post-metadata">

### Author: ![panglesd](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/panglesd/32/3931_2.png) [@panglesd](https://discuss.ocaml.org/u/panglesd)
#### Post date: [April 1, 2025, 3:35pm UTC](https://discuss.ocaml.org/t/ann-ppx-untype-an-end-to-type-errors-in-ocaml/16410/7 "2025-04-01T15:35:01Z")

</div>

I just wanted to clarify that `ppx_untype` allows much more than computing with ints and floats. You can easily add _functions_ together!

```auto
$ cat bin/main.ml
let () =
  let x = (fun x -> x + 1) + (fun x -> x - 1) in
  print_int x
$ dune exec bin/main.exe
109934791872403

```

---

<div class="post-metadata">

### Author: ![dbuenzli](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/dbuenzli/32/18_2.png) [@dbuenzli](https://discuss.ocaml.org/u/dbuenzli)
#### Post date: [April 1, 2025, 3:43pm UTC](https://discuss.ocaml.org/t/ann-ppx-untype-an-end-to-type-errors-in-ocaml/16410/8 "2025-04-01T15:43:38Z")

</div>

Now that makes sense!

---

<div class="post-metadata">

### Author: ![mobileink](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/mobileink/32/3295_2.png) [@mobileink](https://discuss.ocaml.org/u/mobileink)
#### Post date: [April 1, 2025, 4:51pm UTC](https://discuss.ocaml.org/t/ann-ppx-untype-an-end-to-type-errors-in-ocaml/16410/9 "2025-04-01T16:51:42Z")

</div>

Very nice. I’m so sick of warnings!

---

<div class="post-metadata">

### Author: ![Frederic\_Loyer](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/frederic_loyer/32/3472_2.png) [@Frederic\_Loyer](https://discuss.ocaml.org/u/Frederic_Loyer)
#### Post date: [April 4, 2025, 11:27am UTC](https://discuss.ocaml.org/t/ann-ppx-untype-an-end-to-type-errors-in-ocaml/16410/10 "2025-04-04T11:27:18Z")

</div>

> [@panglesd](#):
>
> flaws

It is funny… Ada is even more picky about types (we do have many Integer types and need explicit conversion when doing something with 2 different types). It is seen as a feature, not a flaw.

But sure REPL inputs and code saved in a file have different constraints.

Being to extreme with implicit type conversion make “11”+1 = “111” and “11”-1 = 10 in JavaScript. We just need to get the good compromise.

---

<div class="post-metadata">

### Author: ![panglesd](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/panglesd/32/3931_2.png) [@panglesd](https://discuss.ocaml.org/u/panglesd)
#### Post date: [April 5, 2025, 3:28pm UTC](https://discuss.ocaml.org/t/ann-ppx-untype-an-end-to-type-errors-in-ocaml/16410/11 "2025-04-05T15:28:50Z")

</div>

Conclusion: After using OCaml without type system for the whole of _April 1st_, facing multiple runtime bugs, I realized that the type system is actually helpful! I’ll train my skills playing roguetype instead of writing not-serious PPXes…

@SebHash thanks for the support! I may open a PR for that at the anniversary of the `ppx_untype` release, be prepared to merge it before anyone realize!

As a technical note, this PPX bypass the type system by wrapping every expression in a call to `Obj.magic`. So please, do not use this joke in production 🙂

---

<div class="post-metadata">

### Author: ![ninjaaron](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/ninjaaron/32/1885_2.png) [@ninjaaron](https://discuss.ocaml.org/u/ninjaaron)
#### Post date: [April 8, 2025, 1:07pm UTC](https://discuss.ocaml.org/t/ann-ppx-untype-an-end-to-type-errors-in-ocaml/16410/12 "2025-04-08T13:07:09Z")

</div>

I was honestly wondering what the point of this library was when I already wrap all my code in `Obj.magic`
