DEV Community

Discussion on: How IHP uses Haskell's Type System to enforce good patterns

Collapse
 
codinghusi profile image
Gerrit Weiermann

Wow that sounds very interesting!
I'll take a look at your follow ups :)

If someone is interested in catching the most errors in compile time (without NullPointerException), you may be also interested in Rust.

Collapse
 
gabrielfallen profile image
Alexander Chichigin

Unfortunately Rust pretty much stops at "NullPointerExceptions". As long as Rust does not separate pure code from effectful one (on the type level) it's impossible to guarantee purity of view functions or any other functions. Thus the ability to "enforce proper patterns" at compile-time is limited.

Collapse
 
digitallyinduced profile image
digitallyinduced

You hit the nail on the head!

Collapse
 
digitallyinduced profile image
digitallyinduced

I agree that Rust is also a great language. Many of its features have been heavily influenced by functional languages. In my personal (limited) experience using Rust, it still caused more runtime errors than Haskell code. Mainly due to what dev.to/gabrielfallen said: not being able to declare on the type level which functions have side effects makes it a lot harder to reason about code than when that information is included in the type. It also means that Rust couldn't enforce the MVP pattern as well as Haskell can.