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

Example (ICFP02 prog comp) Pattern match Pattern guard Guard Conditional Where clause sp_help item@(Item cur_loc cur_link _) wq vis | cur_length > limit -- Beyond limit = sp wq vis | Just vis_link = linkLength vis_link then -- Current link is no better sp wq vis else -- Current link is better emit vis item ++ sp wq vis' | otherwise -- Not visited yet = emit vis item ++ sp wq' vis' where vis’ = ... wq = ...

So much for syntax... What is important or interesting about Haskell?

Example (ICFP02 prog comp)<br />

Pattern<br />

match<br />

Pattern<br />

guard<br />

Guard<br />

Conditional<br />

Where<br />

clause<br />

sp_help item@(Item cur_loc cur_link _) wq vis<br />

| cur_length > limit -- Beyond limit<br />

= sp wq vis<br />

| Just vis_link = linkLength vis_link <strong>the</strong>n<br />

-- Current link is no better<br />

sp wq vis<br />

else<br />

-- Current link is better<br />

emit vis item ++ sp wq vis'<br />

| o<strong>the</strong>rwise -- Not visited yet<br />

= emit vis item ++ sp wq' vis'<br />

where<br />

vis’ = ...<br />

wq = ...

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

Saved successfully!

Ooh no, something went wrong!