TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Advanced programming languages

2 pointsby Arun2009almost 12 years ago

2 comments

mooism2almost 12 years ago
The author includes a perfect (if unintentional) example of why Haskell programs <i>shouldn&#x27;t</i> use `error`. (If you&#x27;re writing a quick-and-dirty program? Fair enough. But not in larger programs.)<p>He defines a `Lattice` class, and explains that if a type implements the `Lattice` class, it supports all the operations within the `Lattice` class.<p>He then presents an implementation of the `Lattice` class that <i>doesn&#x27;t</i> support all the `Lattice` operations (`top` punts to `error`). It breaks the promise, breaks the contract, <i>undermines the guarantees</i> the type system gives you.<p>So don&#x27;t use `error` in Haskell. (And for that matter, don&#x27;t use other partial functions such as `head` and `tail`.)
frozenportalmost 12 years ago
Weather or not you code in it, C++ is a must for understanding how a program works.
评论 #5927153 未加载