Files
website/src/content/spotlights/what-is-haskell.md
T
2021-10-24 16:35:05 +01:00

2.3 KiB

authors, created_at, title
authors created_at title
Fox#0001
Cronokirby#0753
2018/04/10 What is Haskell?

What is Haskell?

"Haskell is a computer programming language. In particular, it is a polymorphically statically typed, lazy, purely functional language, quite different from most other programming languages. The language is named for Haskell Brooks Curry, whose work in mathematical logic serves as a foundation for functional languages. Haskell is based on the lambda calculus, hence the lambda we use as a logo." - Haskell Wiki The above being said, if you perceive yourself to be "bad" at math, don't feed into it. If you are interested in using it and you apply yourself it will work out.

Why should I use Haskell?

Haskell is a general purpose programming language. So you can use it for anything, from scripting to game development - that being said, it provides you with some rather unique and cool benefits not found in many other places.

Code Examples

Fizzbuzz

fizzBuzz :: Integer -> String
fizzBuzz n | n `mod` 15 == 0 = "FizzBuzz"
           | n `mod` 5  == 0 = "Fizz"
           | n `mod` 3  == 0 = "Buzz"
           | otherwise       = show n

An infinite list of Fibonacci numbers

fibs = 0 : 1 : zipWith (+) fibs (tail fibs)

An infinite list of prime numbers

primes :: [Integer]
primes = sieve (2 : [3, 5..])
  where
    sieve (p:xs) = p : sieve [x|x <- xs, x `mod` p > 0]