Try it

An open source community effort for over 20 years

Features

Statically typed

Every expression in Haskell has a type which is determined at compile time. All the types composed together by function application have to match up. If they don't, the program will be rejected by the compiler. Types become not only a form of guarantee, but a language for expressing the construction of programs.

But you cannot decode Text, which is already a vector of Unicode points:

Type error

doubleDecode=decodeUtf8(decodeUtf8bytes)

Purely functional

Every function in Haskell is a function in the mathematical sense (i.e., "pure"). Even side-effecting IO operations are but a description of what to do, produced by pure code. There are no statements or instructions, only expressions which cannot mutate variables (local or global) nor access state like time or random numbers.

The following function takes an integer and returns an integer. By the type it cannot do any side-effects whatsoever, it cannot mutate any of its arguments.

square::Int->Intsquarex=x*x

The following string concatenation is okay:

"Hello: "++"World!"

The following string concatenation is a type error:

Type error

"Name: "++getLine

Because getLine has type IO String and not String, like "Name: " is. So by the type system you cannot mix and match purity with impurity.

Type inference

You don't have to explicitly write out every type in a Haskell program. Types will be inferred by unifying every type bidirectionally. However, you can write out types if you choose, or ask the compiler to write them for you for handy documentation.

Concurrent

Haskell lends itself well to concurrent programming due to its explicit handling of effects. Its flagship compiler, GHC, comes with a high-performance parallel garbage collector and light-weight concurrency library containing a number of useful concurrency primitives and abstractions.

Atomic transactions must be repeatable, so arbitrary IO is disabled in the type system:

Type error

main=atomically(putStrLn"Hello!")

Lazy

Functions don't evaluate their arguments. This means that programs can compose together very well, with the ability to write control constructs (such as if/else) just by writing normal functions. The purity of Haskell code makes it easy to fuse chains of functions together, allowing for performance benefits.