Git Product home page Git Product logo

funky's Introduction

It smells a bit funky in here...

This is (for now) just ExpHP's personal project reimplementing some of the ideas in frunk, attempting to explore the design space a bit more.

This probably won't ever be published. Instead, I hope to use what I learn here to contribute ideas to another similar project (probably frunk?).

Features

(note: examples are most likely broken by the time you read this)

Reified indices, to improve ergonomics of working with multiple HLists in parallel

let list_a = hlist![A1, A2, A3];
let list_b = hlist![B1, B2, B3];

// Find the indices for sculpting
let sculptor = list_a.sculptor_of::<HList![A3, A1], _>();

// Apply them to both lists.
let (hlist_pat![A3, A1], hlist_pat![A2]) = list_a.sculpt_at(sculptor);
let (hlist_pat![B3, B1], hlist_pat![B2]) = list_b.sculpt_at(sculptor);

// Notice that the type of `list_b.sculpt_at(sculptor)` is always
// immediately known, without any help from type inference;
// the following does not produce a "Type annotations needed" error.
assert_eq!(list_b.sculpt_at(sculptor), list_b.sculpt_at(sculptor));

Coproduct subsetting (sculpt) and supersetting (embed)

sculpt can turn Coprod![A, B, C, D, E] into Either<Coprod![C, A, E]>, Coprod![B, D]>.
embed can turn Coprod![C, A, E] into Coprod![A, B, C, D, E].

(actually wait a second, isn't embed just a special case of sculpt where the remainder is void?)
(ehhhhhhh I'll do something about that later)

Documentation that very profusely apologies about the index type parameters

Yes, the indices on the type-directed lookup methods really do have to be type parameters.

No, they can't be turned into associated types. Try it, I dare you.

Usage

Don't.

If you just wanna try it out for kicks, you should use a git dependency with a rev tag: (this repo has no tags yet)

[dependencies]
funky = { rev = "777777777777", git = "https://github.com/ExpHP/funky" }

License

Licensed under either of

at your option.

Contribution

Wait, what?! You want to contribute... to this?!

Well... alrighty, then. Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

funky's People

Contributors

exphp avatar

Stargazers

 avatar

Watchers

 avatar  avatar

funky's Issues

Currying

A dumb idea I threw together but never ended up needing to use.

// NOTE: Experimental
pub trait Curry<A>: Sized {
    fn curry(self, a: A) -> Partial<Self, A>;
}

// NOTE: Unable to constrain F here; it will gladly
//       let you curry too many arguments or the wrong types.
//       You could try to write `F: FunOnce<HCons<A, Rest>>`,
//       but where would Rest come from?
impl<A, F> Curry<A> for F
{
    #[inline(always)]
    fn curry(self, a: A) -> Partial<Self, A>
    { Partial {
        function: self,
        arg: a,
    }}
}

#[derive(Debug, Copy, Clone)]
pub struct Partial<F, A> {
    function: F,
    arg: A,
}

impl<F, A, Rest: HList> FunOnce<Rest> for Partial<F, A>
    where F: FunOnce<HCons<A, Rest>>
{
    type Output = F::Output;

    #[inline(always)]
    fn call_once(self, list: Rest) -> Self::Output
    { self.function.call_once(list.prepend(self.arg)) }
}

Not sure how useful an idea along these lines would actually be. Might want to give it more thought later

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.