Hacker News new | past | comments | ask | show | jobs | submit login

faq in the documentation is mostly useless. but the wikipedia entry on it is quite succinct and good. but still after reading that wikipedia article and skimming through the website, i, as a typical average code monkey with a some grasp of python/js/whateva else among these lines, have no clear idea what and where mercurylang is useful for. can someone eli5-explain that to me in a few sentences?



Mercury is the love child of Haskell and Prolog: that is, a very strongly typed logic language. However, it's not quite as flexible a logic language as Prolog (owing mostly to its strong typechecking and modality system), so in practice it's closer to a Haskell with a different I/O containment mechanism (uniqueness types instead of monads) and the ability to sometimes write reversible functions if you bang your head against the modality system hard enough.

Its compiler is impressive, and is capable of acts such as compiling certain non-tail-recursive functions in a tail-recursive manner, or even transforming them into tail-recursive equivalents, given the right hints.

All this capability comes at a cost. At least as of ~4 years ago, the error messages the compiler can spit out over modality errors dwarf even those from C++ templates. And compiler bugs/unimplemented features are not unheard of.


I want to point out that Mercury is an eager language, so it's more like ML than Haskell. It does have the ability to backtrack and execute in reverse, which is kind of magical in the way people think Haskell is.

I wanted to learn it recently, but couldn't find enough example programs.


Yes, uniquenes types for IO (with proper syntactic sugar) really felt powerful, elegant and correct all at the same time.


As Mike says in a sibling comment, we use it quite heavily for implementing our HTML-to-PDF browser engine, https://www.princexml.com

It's a pretty handy general purpose language, kind of a combination of Prolog and Haskell. It's much easier to maintain a long-lived project in Mercury than one in Prolog due to the static typing, and it also generates much more efficient code. That said, it doesn't have the greatest documentation, so you might have to reach out on IRC, or the mailing list if you run into some challenges with it.


I agree with bjz_ - the documentation isn't great, and may have deterred more than a few curious individuals.

That aside, it's a pretty nifty language and I found learning it worthwhile.


The e-mail client I use (bower) is written in mercury.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: