Page Details
access: Public status: Fleeting publicUrl: https://www.haskell.org/ published: 2025-07-28 tag_page: Programming_Language/Haskell creationDate: 2025-07-16 modifiedDate: 2025-08-08 type: Tag_Page
It’s a functional, statically typed, lazy, compiled language.
Dev Quickstart
- Install development tools via GHCup
stack new haskell-test
(Stack hello world example)cd haskell-test
stack build
stack exec haskell-test-exe
- Cheatsheet:
curl -s cht.sh/haskell/:learn | less
Started learning some Haskell after thinking about Anthony Raynes (acidraynes) and looked at My Personal Website again.
Notes
Because it’s lazy you can have infinite lists! Values are computed when used.
Uses prefix notation and you can use infix of you put it between two ticks.
-- prefix
funcName par1 par2-- infix
`funcName` par2 par1
List Comprehensions
Something I’ve not encountered before is list comprehensions.
> [x*2 | x <- [2..5], x > 3]
ghci8,10] [
Breaking the expression down:
x*2
is the output of the list comprehension aka what to do with the list elements after the vertical pipe operator|
pipe operator, “for” (as in, “list ofx*2
forx
in[2..5]
) paraphrased from official docsx <- [2..5]
we assign a range of 2 to 5 tox
using the bind operator (<-
) (more in official docs), x > 3
is a predicate applied forx*2
. It is not a predicate for when bindingx
to the range, x is still[2, 3, 4, 5]
, not `[4, 5].
The format is very much like Set-builder notation in mathematics.
-- add two lists together
> [adjective ++ " " ++ noun | noun <- ["sham", "mentaller"], adjective <- ["sound", "sly"]]
ghci"sound sham","sly sham","sound mentaller","sly mentaller"]
[-- list comprehension as function
> vowelsAreForFls str = [c | c <- str, not (c `elem` ['a', 'e', 'i', 'o', 'u'])]
ghci> vowelsAreForFls "fools"
ghci"fls"
More: List comprehension - HaskellWiki
Links
- Try Haskell in the browser - Haskell Playground