Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Haskell's type classes work fine, similar enough to multiple dispatch.


I think it would be great for Julia to have a mechanism to formalise/enforce interfaces.

I thought a bit about it lately and came to the conclusion, that something like C++ concepts (minus the clunky syntax) would be a better fit for Julia than Haskell's typeclasses or Rust traits. The main difference for me is, that typeclasses are a whitelist of allowed types, while concepts are a set of type constraints, that blacklist types, when the constraints are not fulfilled. Otherwise they are quite similar.

As a result, you don't have to explicitly create a instance with concepts like you would need to do for type classes and packages can happily interoperate without knowing of each other.


I think type classes and packages can happily interoperate without knowing of each other, just like abstract types and packages do currently...well I guess the concepts idea would make it so you'd need even less coordination. But yeah, would be nice if Julia had formal interfaces.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: