back

by layer8·7y ago·view on hn ↗
> And if a type system can not guard against run-time errors, what’s the merit of having one?

The type annotations would document the programmer's assumptions and lead to fail-fast behavior. In the presented use case, it would be immediately clear from the run-time type error that the input data isn't in the expected format (as opposed to a typing bug somewhere else in the program).

1 comments
Second, as aid in design. I had the pleasure to use languages capable of deriving implementations from types directly (where otherwise you'd use reflection) and ones with type-directed search and typed-holes (even though unsafeCoerce fitting every hole is a bit annoying :)
What language was this?
Sounds very much like Haskell. The search engine is Hoogle.

https://www.haskell.org/hoogle/

Haskell and Purescript (a close-relative compiled to Javascript). Have yet to 'use it in anger', though :)