Skip to content

johnyob/ppx-matches

Repository files navigation

🔥 ppx-matches

A syntax extension for Rust's matches! in OCaml 🐪

Install

This library has not yet been released to opam. To install it, first

opam install ppx_matches

Users of dune can then use this PPX on their libraries and executables by adding the appropriate stanza field:

(library
 ...
 (preprocess (pps ppx_matches)))

Syntax

In short:

  • [%matches? pat [when cond]] expands to

    function
    | pat [when cond] -> true
    | _ -> false
    
  • [%matches? pat [when cond]] matchee expands to the inlined version:

    match matchee with
    | pat [when cond] -> true
    | _ -> false
    

About

PPX syntax for Rust's `matches!` in OCaml 🐪

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Generated from johnyob/ppx-template