DEV Community

이관호(Gwanho LEE)
이관호(Gwanho LEE)

Posted on

Haskell Review · 2026-10-13

  • Types and values: True :: Bool, Just 7 :: Maybe Int. Bool and Maybe Int are types; True and Just 7 are values.
  • Functions and calls: double :: Integer -> Integer, double 3 :: Integer. Define quadrupling as quadruple x = double (double x).
  • Pattern matching: isZero :: Integer -> Bool. Define cases with isZero 0 = True and isZero _ = False.
  • Recursion: sumTo 0 = 0, sumTo n = n + sumTo (n - 1). Reduce the input until reaching the base case.
  • Type variables: a stands for a type. head :: [a] -> a returns one element; tail :: [a] -> [a] returns the remaining list.

With numbers specialized to Int:

head [True, False]       -- True       :: Bool
tail [True, False]       -- [False]    :: [Bool]
head [[1, 2], [3, 4]]    -- [1, 2]     :: [Int]
tail [[1, 2], [3, 4]]    -- [[3, 4]]   :: [[Int]]
Enter fullscreen mode Exit fullscreen mode

Connection to earlier lessons: for Maybe, pure wraps a value in Just; fmap applies an ordinary function, and <*> applies a wrapped function. >>= passes the inner value to a function returning Maybe and uses that result directly.

Next session: Helsinki MOOC Part 1, 2.6–2.7: Maybe and constructors. Implement intOrZero :: Maybe Int -> Int using pattern matching.

Reference: Haskell MOOC Part 1

Top comments (0)