corollary
corollary copied to clipboard
let-defined lambdas aren't combined.
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(())
}
}
};
}
}