Com S 541 Lecture -*- Outline -*- * lexical matters in Haskell (Thompson 3.7, Davie 2.14, appendix C.2-3) ** identifiers and operators (Thompson 1.7, Davie 2.14.2) ------------------------------------------ IDENTIFIERS identifiers (non infix): examples pythag, fac, x, y notes 1. case matters 2. start with lower-case letter 3. must start with lower-case letter, unless constructor or a type identifier, Cons, Typ 4. can use letters, digits, primes and underscores (_) f', x_squared, x3'n_ ------------------------------------------ ------------------------------------------ OPERATORS operators (infix): examples +, -, !!, :, ++, == notes 1. Drawn from: !#$%&*+./<=>?@\^|: 2. A constructor if start with : 3. Any identifier can be made into an operator using backquotes 3 `div` 4 ------------------------------------------ ** layout (Thompson 3.7, 6.3, Davie 2.14.3) ------------------------------------------ LAYOUT MATTERS let x = 3 y = 4 in x + y ==> let {x = 3 ;y = 4 }in x + y ------------------------------------------ simplified rules: ; inserted at same indentation } inserted when indented to left You can write with the { and ; and } if you want, all on one line... Watch out, you can get syntax errors from bad indentation!