https://github.com/rootmos/ppx_useless
A useless ppx extension
https://github.com/rootmos/ppx_useless
joke ocaml ppx
Last synced: 12 months ago
JSON representation
A useless ppx extension
- Host: GitHub
- URL: https://github.com/rootmos/ppx_useless
- Owner: rootmos
- Created: 2017-06-03T14:15:40.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-06T06:18:55.000Z (about 9 years ago)
- Last Synced: 2025-03-21T21:28:40.415Z (about 1 year ago)
- Topics: joke, ocaml, ppx
- Language: OCaml
- Homepage:
- Size: 6.84 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
ppx_useless
===========
**Disclaimer** This project is a joke and should be taken seriously only by people without humor.
This project provides the `ppx_useless` [OCaml](https://ocaml.org/) compiler extension, that
replaces the code with the following statement:
```ocaml
let () = ()
```
Now this might seem controversial to the casual, but there are benefits to be had.
Useless features:
* Reduces compile errors
* Reduces runtime errors
* Reduces binary size
* Simplifies debugging
* Increases speed
* Decreases memory usage (both at compile-time and run-time)
Useful features:
* Wastes CPU cycles, which in turn heats your room
* There's at least a possibility that the program produces the
desired output, which means that any input would suffice as
a solution, which in turn saves time for the programmer.
However, some programs are not expected to terminate (e.g. server programs)
and for those kinds of programs the `ppx_diverge` is provided that replaces
every expression with:
```ocaml
let rec diverge () = diverge () in diverge ()
```
which provides the desired non-termination.
An added benefit here is that there's no longer any need for messing about
with configuration files!
Here the observant reader interjects: "But even a trivial but deterministic program can be useful (e.g. `/bin/true`)!"
True, `true` is a very useful program and to address that the `ppx_nondeterministic` extension is provided.
Here's a sample session from `utop`:
```
> 2+2;;
- : int = 4
> 2+2;;
- : int = 3
> 2+2;;
- : int = 5
```
Observe here that there is a possibility of obtaining the expected result.
And be honest, who doesn't what more [non-determinism](https://en.wikipedia.org/wiki/Heisenbug) in their lives?
Usage
-----
The provided `Makefile` contains instructions on how to build the
different useless extensions, but the impatient can invoke [utop](https://github.com/diml/utop)
like so:
* for useless programs: `make useless-utop`
* for non-terminating programs: `make diverge-utop`
* for non-deterministic programs: `make nondeterministic-utop`