Skip to content

Commit 6788440

Browse files
committed
Some modifications for haskell-to-p6
- { * } doesn't become { $_ }, it returns a Whatever - Remove the explicit smartmatch - Mention the defined-or operator
1 parent 557090c commit 6788440

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

doc/Language/haskell-to-p6.pod6

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ and Undefined objects. Plain type objects are undefined while instansiated objec
6060
sub parse-int(Str $s --> Int) { ... }
6161
6262
given parse-int($string) {
63-
when Int:D { * }
63+
when Int:D { $_ }
6464
when Int:U { 0 }
6565
}
6666
@@ -79,8 +79,8 @@ that specifically test for definedness.
7979
8080
# One way to do it
8181
given parse-int($string) {
82-
when * ~~ Int:D { * }
83-
when * ~~ Int:U { 0 }
82+
when Int:D { $_ }
83+
when Int:U { 0 }
8484
}
8585
8686
# Another way to do it
@@ -89,7 +89,10 @@ that specifically test for definedness.
8989
9090
9191
# A better way
92-
with parse-int($string) { * } else { 0 }
92+
with parse-int($string) { $_ } else { 0 }
93+
94+
# With the defined-or operator
95+
parse-int($string) // 0
9396
9497
The `with` operator that you see above is like `if`, except it explicitly tests for definedness and then
9598
passes the result to the following block. Similarly, `without` tests that the object is undefined and also

0 commit comments

Comments
 (0)