Re:Cthulhu.jl – show type-inferred Julia code
by kelipso on Thursday September 07, 2023 @09:19PM
(#37428078)
Haskell's type classes work fine, similar enough to multiple dispatch.
[ Parent
| on HN ]
Re:Cthulhu.jl – show type-inferred Julia code
by majoe on Friday September 08, 2023 @02:21AM
(#37430101)
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.
Re:Cthulhu.jl – show type-inferred Julia code
by kelipso on Friday September 08, 2023 @12:58PM
(#37436207)
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.