Skip to content

reynir/let-if

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

let%if is if let backwards

This ppx adds a construct similar to if let in Rust. The following two snippets are equivalent:

let%if Some x = Sys.getenv_opt "HELLO" in
print_endline x
match Sys.getenv_opt "HELLO" with
| Some x -> print_endline x
| _ -> ()

New: if%true then do

Do you often want to perform side effects if an expression is true while still returning the boolean value? Then if%true is for you! Simply write:

if%true cond then something else otherwise

... and your code is automagically transformed into:

let c = cond in (if c then something else otherwise); c

The else branch is optional!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages