https://github.com/EduardoRFS/ppx_implicits
https://github.com/EduardoRFS/ppx_implicits
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/EduardoRFS/ppx_implicits
- Owner: EduardoRFS
- License: mit
- Created: 2021-03-25T19:27:30.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-06-24T14:18:44.000Z (over 4 years ago)
- Last Synced: 2024-11-14T03:48:09.666Z (about 1 year ago)
- Language: OCaml
- Size: 1.05 MB
- Stars: 25
- Watchers: 5
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-list - ppx_implicits
README
# ppx_implicits
Only explicits implemented, for now.
## How to use
### Requirements
- ocaml@4.12.x
### esy
```sh
esy add ppx_implicits@EduardoRFS/ppx_implicits#HASH_HERE
```
### opam
```sh
opam pin ppx_implicits https://github.com/EduardoRFS/ppx_implicits.git#HASH_HERE
```
### dune
Add it as `(preprocess (staged_pps ppx_implicits))`, like:
```dune
(executable
(name test)
(preprocess
(staged_pps ppx_implicits)))
```
### How it works?
A typer hacked and some fancy elaboration, you will be able to notice by hovering over declarations with merlin.
### Examples
For more examples you can look on [test/test.re](https://github.com/EduardoRFS/ppx_implicits/blob/branch-private-please-dont-look-here/test/test.re)
```ocaml
module type Monad = sig
type 'a t
val return : 'a -> 'a t
val bind : 'a t -> ('a -> 'b t) -> 'b t
end
module Option = struct
include Option
let return = some
end
let bind (module M : Monad) v f = M.bind v f
let bind_option v f = bind (module Option) v f
let some_6 =
bind
(module Option)
(Some 5)
(fun v -> Some (v + 1))
```