Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

let-defined lambdas aren't combined. #65

Open
tcr opened this issue Jun 3, 2017 · 0 comments
Open

let-defined lambdas aren't combined. #65

tcr opened this issue Jun 3, 2017 · 0 comments

Comments

@tcr
Copy link
Owner

tcr commented Jun 3, 2017

Similar to how top-level functions with multiple definitions are folded into a match statement (see the comment "There are multiple impls of this function, so expand this into a case statement" in convert.rs for code that can be reused) lambdas with multiple definitions should be folded into one match statement also.

To repro, save this as test.hs:

module Test()
where

example :: ()
example = do
    let isDefault (Just condition) = Left condition
        isDefault Nothing = Right ()

Running cargo run --manifest-path corollary/Cargo.toml -- test.hs currently outputs this:

// Original file: "test.hs"
// File auto-generated using Corollary.

#[macro_use] use corollary_support::*;


pub fn example() -> () {
    /*do*/ {
        let isDefault = |Some(condition)| {
            Left(condition)
        };

        let isDefault = |None| {
            Right(())
        };
    }
}

Expected output:

pub fn example() -> () {
    /*do*/ {
        let isDefault = |_0| {
            match _0 {
                Some(condition) {
                    Left(condition)
                }
                None {
                    Right(())
                }
            }
        };
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant