Hacker Monthly #3 by Netizens Media
Author:Netizens Media [Media, Netizens]
Language: eng
Format: epub, mobi
Tags: Technology
Publisher: Fifobooks.com
Haskell
Haskell excels as a language for writing a compiler, an interpreter or a static analyzer. I don't do a lot of artificial intelligence, natural-language processing or machine-learning research, but if I did, Haskell would be my first pick there too. (Scheme would be a strong second.) Haskell is the only widely used pure, lazy functional programming language.
Like Standard ML and oCaml, Haskell uses an extension of Hindley-Milner-style type inference, which means that the programmer doesn't have to write down (most) types, because the compiler can infer them. It has been my experience that it is difficult to get a bug through the Hindley-Milner type system. In fact, experienced programmers become adept at encoding correctness constraints directly into the Haskell type system. A common remark after programming in Haskell (or ML) for the first time is that once the program compiles, it's almost certainly correct.
As a pure language, side effects (mutations of variables or data structures and I/o) are prohibited in the language proper. This has forced the language's designers to think seriously about how to provide such functionality. Their answer, monads, enables one to perform side effects and I/o inside a safely constrained framework. Naturally, Haskell lets users define their own monads, and now the programmer has access to monads for continuations, transducers, exceptions, logic programming and more.
Aside from being pure, Haskell is also lazy. That is, an expression in Haskell is not evaluated until (and unless) its result is required to make forward computational progress. Some have argued that the promised efficiency gains from laziness haven't materialized, but that's not of concern for me. I appreciate laziness for the increase in expressiveness. In Haskell, it is trivial to describe data structures of infinite extent. Where other languages permit mutually recursive functions, Haskell permits mutually recursive values.
More pragmatically, I have found laziness useful in encoding option types, where utilizing the empty case should always nuke the program. In Haskell, you can avoid creating an option type and instead use error to produce the empty value. Because of laziness, every type in Haskell automatically has two additional values: non-termination and error. Used well, this eliminates much tedious pattern matching. My favorite feature of Haskell is type classes. Haskell's type system allows the compiler to infer the correct code to run based on its type context, even when that type context is also inferred. The example of type classes that got me excited was bounded lattices. A bounded lattice is a mathematical structure that has a least element (bot), a greatest element (top), a partially ordered less than relation (<:), a join operation (join) and a meet operation (meet).
In Haskell, one can define a bounded lattice as a type class:
class Lattice a where top :: a bot :: a (<:) :: a -> a -> Bool join :: a -> a -> a meet :: a -> a -> a
This says that if type a is a Lattice, then a supports the expected operations. What I really love about Haskell is that
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
The Brazilian Economy since the Great Financial Crisis of 20072008 by Philip Arestis Carolina Troncoso Baltar & Daniela Magalhães Prates(360865)
International Integration of the Brazilian Economy by Elias C. Grivoyannis(111585)
The Art of Coaching by Elena Aguilar(53640)
Flexible Working by Dale Gemma;(23358)
How to Stop Living Paycheck to Paycheck by Avery Breyer(19834)
Thinking, Fast and Slow by Kahneman Daniel(12526)
The Acquirer's Multiple: How the Billionaire Contrarians of Deep Value Beat the Market by Tobias Carlisle(12428)
The Radium Girls by Kate Moore(12177)
The Art of Thinking Clearly by Rolf Dobelli(10713)
Hit Refresh by Satya Nadella(9253)
The Compound Effect by Darren Hardy(9146)
Tools of Titans by Timothy Ferriss(8591)
Atomic Habits: Tiny Changes, Remarkable Results by James Clear(8515)
Turbulence by E. J. Noyes(8200)
A Court of Wings and Ruin by Sarah J. Maas(8107)
Change Your Questions, Change Your Life by Marilee Adams(7929)
Nudge - Improving Decisions about Health, Wealth, and Happiness by Thaler Sunstein(7850)
How to Be a Bawse: A Guide to Conquering Life by Lilly Singh(7613)
Win Bigly by Scott Adams(7343)