Haskell is an open source programming language created in 1990 by Paul Hudak and John Hughes.
#26on PLDB | 34Years Old | 127kRepos |
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...
module Example where
sumOverArray :: [Int] -> Int
sumOverArray (x:xs) = x + sumOverArray xs
sumOverArray [] = 0
module Main where
main :: IO ()
main = putStrLn "Hello, world!"
module Main where
main = putStrLn "Hello World"
-- Hello World in Haskell
main = putStrLn "Hello World"
import Data.Char
main :: IO ()
main = do
let hello = "hello world"
putStrLn $ map toUpper hello
$ ghci
Prelude> import Data.Int
Prelude Data.Int> fromIntegral (32767 :: Int16) :: Int8
-1
Prelude Data.Int> fromInteger (2^64 :: Integer) :: Int32
0
! ' '' - -< -<< -> :: ; <- , = => > ? # \* @ [|, |] \ \_ ` {, } {-, -} | ~ 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
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 |