Skip to content

Commit 7b571fa

Browse files
k3ut0icoke
authored andcommitted
haskell partial application example in raku
1 parent 3ca674e commit 7b571fa

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

doc/Language/haskell-to-p6.rakudoc

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,30 @@ When using C<where>, note that the order of definition is important, just like i
326326

327327
TODO
328328

329-
=head2 Currying
329+
=head2 Currying / Partial Application
330330

331-
TODO
331+
Haskell functions are in curried form by default and as such they allow partial application directly.
332+
333+
=begin code :lang<haskell>
334+
plus : Int -> Int -> Int
335+
plus a b = a + b
336+
=end code
337+
338+
=begin code :lang<haskell>
339+
plusTwo = plus 2
340+
=end code
341+
342+
In raku, partial application can be achieved by C<assuming> method on any C<Callable> object.
332343

333-
.assuming vs currying
344+
=begin code
345+
sub plus(Int $i, Int $j --> Int) { return $i + $j; }
346+
=end code
347+
348+
=begin code
349+
my &plus-two = &plus.assuming(2, *);
350+
=end code
351+
352+
TODO
334353

335354
method chaining vs currying
336355

0 commit comments

Comments
 (0)