Monads/Maybe monad: Difference between revisions

Content added Content deleted
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
m (Fix Perl 6 -> Raku in comments)
Line 953: Line 953:
{{works with|Rakudo|2019.11}}
{{works with|Rakudo|2019.11}}
It is exceptionally difficult to come up with a compelling valuable use for
It is exceptionally difficult to come up with a compelling valuable use for
a Maybe monad in Perl 6. Monads are most useful in languages that don't have
a Maybe monad in Raku. Monads are most useful in languages that don't have
exceptions and/or only allow a single point of entry/exit from a subroutine.
exceptions and/or only allow a single point of entry/exit from a subroutine.


Line 962: Line 962:


The task description asks for two functions that take an Int and return a Maybe
The task description asks for two functions that take an Int and return a Maybe
Int or Maybe Str, but those distinctions are nearly meaningless in Perl 6. See
Int or Maybe Str, but those distinctions are nearly meaningless in Raku. See
below.
below.


Line 976: Line 976:
$monad is both an Int '''and''' a Str. It exists in a sort-of quantum state
$monad is both an Int '''and''' a Str. It exists in a sort-of quantum state
where what-it-is depends on how-it-is-used. Bolting on some 'Monad' type to do
where what-it-is depends on how-it-is-used. Bolting on some 'Monad' type to do
this will only ''remove'' functionality that Perl 6 already has.
this will only ''remove'' functionality that Raku already has.


Ok, say you have a situation where you absolutely do not want an incalculable
Ok, say you have a situation where you absolutely do not want an incalculable