You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

11 lines
397 B

  1. Defining a pair is easy.
  2. \begin{haskellcode}
  3. p :: (Int, Char) -- this is the type
  4. p = (2, 'y') -- this is how we construct the pair
  5. -- pattern matching against pairs
  6. sumPair :: (Int, Int) -> Int
  7. sumPair (x, y) = x + y
  8. \end{haskellcode}
  9. \pause
  10. Note: we use \code{(x, y)} notation for both the type and the definition! Those are still two different things. We can also have triples, quadruples etc.