Top 1,000 Features Creators Resources Blog Explorer Download
GitHub icon

Haskell

< >

Haskell is a programming language created in 1990 by Paul Hudak and John Hughes.

#36on PLDB 34Years Old 127kRepos

Try now: Riju ยท TIO ยท Replit

Haskell is a standardized, general-purpose purely functional programming language, with non-strict semantics and strong static typing. It is named after logician Haskell Curry. The latest standard of Haskell is Haskell 2010. Read more on Wikipedia...


Example from Compiler Explorer:
module Example where sumOverArray :: [Int] -> Int sumOverArray (x:xs) = x + sumOverArray xs sumOverArray [] = 0
Example from Riju:
module Main where main :: IO () main = putStrLn "Hello, world!"
Example from hello-world:
module Main where main = putStrLn "Hello World"
-- Hello World in Haskell main = putStrLn "Hello World"
Example from Linguist:
import Data.Char main :: IO () main = do let hello = "hello world" putStrLn $ map toUpper hello
Example from Wikipedia:
$ ghci Prelude> import Data.Int Prelude Data.Int> fromIntegral (32767 :: Int16) :: Int8 -1 Prelude Data.Int> fromInteger (2^64 :: Integer) :: Int32 0
Haskell Keywords
! ' '' - -< -<< -> :: ; <- , = => > ? # \* @ [|, |] \ \_ ` {, } {-, -} | ~ as case of class data family instance default deriving do forall foreign hiding if then else import infix infixl infixr let in mdo module newtype proc qualified rec type where

Language features

Feature Supported Token Example
Binary Literals โœ“
-- 0[bB]_*[01](_*[01])*
Integers โœ“
-- \d(_*\d)*
Floats โœ“
-- 0[xX]_*[\da-fA-F](_*[\da-fA-F])*_*[pP][+-]?\d(_*\d)*
Hexadecimals โœ“
-- 0[xX]_*[\da-fA-F](_*[\da-fA-F])*
Octals โœ“
-- 0[oO]_*[0-7](_*[0-7])*
Conditionals โœ“
Classes โœ“
Case Sensitivity โœ“
Print() Debugging โœ“ putStrLn
Range Operator โœ“
Function Composition โœ“
foo = f . g
Line Comments โœ“ --
-- A comment
Type Inference โœ“
Semantic Indentation โœ“
Operator Overloading โœ“
File Imports โœ“
import Data.Maybe
import Mod as Foo
import Mod (x,y, (+++))
import qualified Mod
import Mod hiding (x,y,(+++))
import qualified Mod hiding (x,y)
Directives โœ“
{-# INLINE foo #-}
Garbage Collection โœ“
Pattern Matching โœ“
fib 0 = 1
fib 1 = 1
fib n | n >= 2
      = fib (n-1) + fib (n-2)
Zippers โœ“
-- https://wiki.haskell.org/Zipper_monad/TravelTree
MultiLine Comments โœ“ {- -}
Comments โœ“
 -- a single line comment
 {- A multiline comment
    which can continue for many lines
 -}
Map Functions โœ“
class Functor f where
   fmap :: (a -> b) -> f a -> f b
   (<$) :: a -> f b -> f a
Monad โœ“
-- https://stackoverflow.com/questions/44965/what-is-a-monad
parseExpr = parseString <|> parseNumber

parseString = do
        char '"'
        x <- many (noneOf "\"")
        char '"'
        return (StringValue x)

parseNumber = do
    num <- many1 digit
    return (NumberValue (read num))
Typed Holes โœ“
-- Found hole `_' with type f (Free f b)
Runtime Guards โœ“
f x
 | x > 0 = 1
 | otherwise = 0
Strings โœ“ "
"hello world"
Case Insensitive Identifiers X

View source

- Build the next great programming language ยท About ยท Acknowledgements ยท Extensions ยท Day 625 ยท feedback@pldb.io