Hacker News new | ask | show | jobs
by yccs27 25 days ago
Thank you for the detailed answers!

I think purity is something the programmer just has to annotate themselves. Any boundary between languages with different type system guarantees will always have this kind of friction - Rust to C/C++ FFI also has to deal with ownership, lifetimes and aliasing manually.

Regarding type classes, monomorphisation indeed seems like a difficult obstacle for polymorphic function. But just translating type classes and impls might not be as difficult? So going from:

    trait Foo {
      fn foo(&self);
    }
    
    impl Foo for Bar {
      fn foo(&self) {...}
    }
to

    class Foo a where
      foo :: a -> IO ()
    
    instance Foo Bar where
      foo :: Bar -> IO ()
      foo self = ...