Top 1K Features Creators Events Podcasts Books Extensions Interviews Blog Explorer CSV

Haskell

< >

Haskell is an open source programming language created in 1990 by Paul Hudak and John Hughes.

#26on PLDB 34Years Old 127kRepos
Homepage · REPL · Try It Online · Download · Wikipedia · FAQ · Docs · Mailing List

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 Example Token
Standard Library main = putStrLn "Hello, World!"
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

- Build the next great programming language · Add · Issues · About · Search · Keywords · Livestreams · Labs · Resources · Acknowledgements

Built with Scroll v164.7.0