3 ms·
Serious question which language doesn't have this 'escape hatch'? AFAIK even Haskell has unsafePerformIO to allow this..
by renox 4y ago
Serious question which language doesn't have this 'escape hatch'?
AFAIK even Haskell has unsafePerformIO to allow this..
- wk_end 4y agoMost languages don't encode purity in the type system, so they don't need an "escape hatch" - there's nothing to escape from. Unlike `unsafePerformIO`, Koka's approach isn't really an "escape hatch" - effects are a safe, principled part of the language. And, if I understand them correctly, even though they're more ergonomic than monads, they also come with friction of their own (maybe needless to say, otherwise they couldn't be enforcing anything) - adding logging to a function will add the `console` effect to the function's type, which bubbles up to callers and might cause issues if any callers are declared as `total` (and indeed, that's the default for function type annotations). But at least, unlike Haskell, you wouldn't need to add `return` and `lift`s everywhere to fix things; and the changes you'll need to make to your signatures are usually quite a bit more straightforward I think.