Wearing the hair shirt Wearing the hair shirt - Microsoft Research

Wearing the hair shirt Wearing the hair shirt - Microsoft Research Wearing the hair shirt Wearing the hair shirt - Microsoft Research

research.microsoft.com
from research.microsoft.com More from this publisher
27.12.2013 Views

“Expression style” Define a function as an expression map = \f xs -> case xs of [] -> [] (x:xs) -> map f xs sign = \x -> if x>0 then 1 else if x==0 then 0 else -1

Fat vs thin Expression style •Let •Lambda •Case •If Declaration style •Where •Function arguments on lhs •Pattern-matching •Guards SLPJ’s conclusion syntactic redundancy is a big win Tony Hoare’s comment “I fear that Haskell is doomed to succeed”

“Expression style”<br />

Define a function as an expression<br />

map = \f xs -> case xs of<br />

[] -> []<br />

(x:xs) -> map f xs<br />

sign = \x -> if x>0 <strong>the</strong>n 1<br />

else if x==0 <strong>the</strong>n 0<br />

else -1

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!