Skip to content

jonathanrlouie/env-io

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Env-IO

What is Env-IO?

Env-IO is a highly experimental, work-in-progress, functional effect system for Rust that is inspired by the ZIO library for Scala. Specifically, it is based on ZIO environments, as described in this article.

What is the point of this?

I wrote this for fun and because I wanted to learn more about Rust's traits. It also allows me experiment with the various properties of functional effect systems in Rust.

Usage with the mdo crate

The following code snippet shows an example of how to use Env-IO with the mdo crate.

use mdo::mdo;
use env_io::{FlatMap, eff, EnvIO, IntoEnvIO};

fn bind<Env, OutEnv, F>(envio: Env, f: F) -> FlatMap<Env, F>
    where Env: EnvIO, OutEnv: EnvIO, F: Fn(Env::Out) -> OutEnv,
{
    envio.flat_map(f)
}

let program = mdo! {
    _ =<< eff!(println!("Enter your name: "));
    name =<< eff!({
        let mut name = String::new();
        io::stdin().read_line(&mut name).expect("Failed to read name.");
        name
    });
    ret eff!(println!("Hello, {}", name))
};
program.run();

About

A highly experimental, work-in-progress, functional effect system for Rust that is inspired by the ZIO library for Scala

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages