-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change type name Maybe to Option [Some/None]
- Loading branch information
1 parent
bdbb318
commit 5404317
Showing
26 changed files
with
1,150 additions
and
1,148 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import 'package:fpdart/fpdart.dart'; | ||
|
||
void main() { | ||
/// Create an instance of [Some] | ||
final option = Option.of(10); | ||
|
||
/// Create an instance of [None] | ||
final none = Option<int>.none(); | ||
|
||
/// Map [int] to [String] | ||
final map = option.map((a) => '$a'); | ||
|
||
/// Extract the value from [Option] | ||
final value = option.getOrElse(() => -1); | ||
|
||
/// Pattern matching | ||
final match = option.match( | ||
(a) => print('Some($a)'), | ||
() => print('None'), | ||
); | ||
|
||
/// Convert to [Either] | ||
final either = option.toEither(() => 'missing'); | ||
|
||
/// Chain computations | ||
final flatMap = option.flatMap((a) => Option.of(a + 10)); | ||
|
||
/// Return [None] if the function throws an error | ||
final tryCatch = Option.tryCatch(() => int.parse('invalid')); | ||
} |
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
Oops, something went wrong.