Lifted

Higher-kinded types for Rust. Implementation based on modifications to [Liebow-Feeser]'s method, winding up at the same scheme described by [Yallop & White].

Quickstart

Say you'd like to write a higher-kinded trait such as Functor. We can imagine it might someday look a bit like this:

trait Functor<A> { fn fmap<B, F: Fn(A) -> B>(me: Self<A>, f: F) -> Self<B>; }

This isn't valid today, but with some minor changes we can write it:

``` use lifted::K1;

trait Functor { fn fmap B>(me: K1, f: F) -> K1; } ```

There are two key visible changes, and one hidden one:

(Note that, while the term HKT form is borrowed from generic_std, the use of them here was discovered independently. On further review, the concept closely matches the brand from [Yallop & White].)

The first two are more or less self-explanatory, but the third could use an illustration to clarify. Let's implement it!

``` use lifted::Kind1;

// Define the higher-kinded form of Vec pub struct VecC;

// Specify how to construct a type instance impl Kind1 for VecC { type Inner = Vec; }

impl Functor for VecC { fn fmap B>(me: K1, f: F) -> K1 { let me = me.into_inner(); // unwrap the Vec

    let you = me.map(f);        // map the Vec<A> to a Vec<B>

    K1::new(you)                // rewrap the Vec<B>
}

} ```

For more details, please consult the [API Documentation].

Documentation

API Docs

API docs are hosted on docs.rs:

[API Documentation]

Minimum Supported Rust Version

This crate makes use of no exotic language features, and so can support even very old versions of stable Rust. It has been tested successfully with Rust 1.35. (Once we get around to setting up CI, we will verify this MSRV with CI testing).

Comparison to other crates

Contributing

I'm happy to see any and all contributions, including bug reports, usability suggestions, patches, or angry yet well-intentioned rants. You are encouraged to report issues to the official [issue tracker] and send any questions or patches to the [mailing list]. Pull requests to the GitHub mirror are also acceptable.