Port of the code from Typing Haskell in Haskell to Rust