tcr / corollary

Cross-compiler from Haskell to Rust, plus parser-haskell.
73 stars 5 forks source link

Translate into pointful function #64

Open tcr opened 7 years ago

tcr commented 7 years ago

This translates incorrectly. We should look at the type signature, and if there are extra arguments in its type that are not in the function arguments, it should be rewritten as pointful.

Save this as test.hs:

module Test()
where

-- error.hs:49
isHardError :: (Error ex) => ex -> Bool
isHardError = ( > LevelWarn) . errorLevel

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 isHardError() -> bool {
    ((() > LevelWarn(errorLevel)))
}

Expected output:

pub fn isHardError(ex: Error) -> bool {
   errorLevel(ex) > LevelWarn
}