-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add documentation for extended patterns
This commit update the manual to take into account the latest extensions of pattern matching, namely wildcard patterns, constant patterns, array patterns, pattern guards and or-patterns. Doing so, we also update the examples (in the manual and in the `examples` directory) to use pattern matching whenever it looks more idiomatic and make the code more readable.
- Loading branch information
Showing
12 changed files
with
104 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
# test = 'pass' | ||
|
||
# This is the naive, exponential version of fibonacci: don't call it on a big | ||
# value! | ||
let rec fibonacci = fun n => | ||
if n == 0 then | ||
0 | ||
else if n == 1 then | ||
1 | ||
else | ||
fibonacci (n - 1) + fibonacci (n - 2) | ||
# This is the naive, exponential version of fibonacci: don't call it on a large | ||
# number! | ||
let rec fibonacci = | ||
match { | ||
0 => 0, | ||
1 => 1, | ||
n => fibonacci (n - 1) + fibonacci (n - 2), | ||
} | ||
in | ||
fibonacci 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
# test = 'pass' | ||
|
||
# First projection, statically typed | ||
let fst : forall a b. a -> b -> a = fun x y => x in | ||
let first : forall a b. a -> b -> a = fun x y => x in | ||
# Evaluation function, statically typed | ||
let ev : forall a b. (a -> b) -> a -> b = fun f x => f x in | ||
let eval : forall a b. (a -> b) -> a -> b = fun f x => f x in | ||
let id : forall a. a -> a = fun x => x in | ||
(ev id (fst 5 10) == 5 : Bool) | ||
(eval id (first 5 10) == 5 : Bool) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters